*** tags-st-orig.py Wed Dec 21 09:53:32 2005 --- tags-static.py Wed Feb 27 10:47:35 2008 *************** *** 2,7 **** --- 2,25 ---- tags.py Creates a tagging environment for pyblosxom + ********* + Akk NOTE: this is derived from http://t3.dotgnu.info/code/tags.py + suppsoedly a version modified for static rendering. + Original is at http://joe.terrarum.net/projects.html + But I've had to modify it to get it to work. + Caveats and non-obvious points: + * Add tags as the second line of an entry, right under the title, + or it will be ignored. + * You may need to create the tag directories http://yoursite/tags/$tagname + yourself: pyblosxom may not do it for you. + * In addition to the config file entries discussed below, if you use + an extension other than .txt (or maybe even if you don't) you also + need to set py[ 'taggable_files' ] = [ "ext" ] + * In your story.html template, include $tag_links wherever you want + the tags line to go. But make "Tags: " or similar be part of + the pretext, so it won't be included on un-tagged entries. + ********* + Tagging is like having an entry belong to multiple categories. For example, an entry about Bike Riding in Pennsylvania can belong to both Biking and Pennsylvania. *************** *** 96,102 **** if(config['tag_url'][-1] == '/'): slash = '' TAG_URL_PATTERN = re.compile('^%s%s([^/]*)/?(index.[^/.]*)?' % (config['tag_url'], slash)) ! def cb_filelist(args): global TAG_URL_PATTERN request = args['request'] --- 114,124 ---- if(config['tag_url'][-1] == '/'): slash = '' TAG_URL_PATTERN = re.compile('^%s%s([^/]*)/?(index.[^/.]*)?' % (config['tag_url'], slash)) ! ! # ! # I *think* cb_filelist is only supposed to act on tag pages, e.g. ! # http://blogurl/tags/blahblah ! # def cb_filelist(args): global TAG_URL_PATTERN request = args['request'] *************** *** 149,154 **** --- 171,177 ---- tags = entry.getMetadata('tags').split(',') for tag in tags: + # temp_tags.append('' % (config['tag_url'], tag, tag)) temp_tags.append('' % (config['tag_url'], tag, tag)) formatted_tags.append(config['tagsep'].join(temp_tags)) *************** *** 162,168 **** tagbase = config['tag_url'].replace(config['base_url'], '') # for example, I have /tags/public/index.rss in there :) static_urls = config.get("static_urls", []) ! while tagbase[-1] == '/': tagbase = tagbase[:-1] entry = args['entry'] flavour = entry['flavour'] --- 185,191 ---- tagbase = config['tag_url'].replace(config['base_url'], '') # for example, I have /tags/public/index.rss in there :) static_urls = config.get("static_urls", []) ! while len(tagbase) > 0 and tagbase[-1] == '/': tagbase = tagbase[:-1] entry = args['entry'] flavour = entry['flavour'] *************** *** 178,185 **** tags = entry["tags"].split(',') for tag in tags: tagurl = "%s/%s/index.%s" % (tagbase, tag, flavour) ! if tagurl not in static_urls: ! print "rendering %s ..." % (tagurl); ! tools.render_url(config, tagurl) # vim: set ts=4 et : --- 201,212 ---- tags = entry["tags"].split(',') for tag in tags: tagurl = "%s/%s/index.%s" % (tagbase, tag, flavour) ! # Akk: I have no such variable static_urls. ! #if tagurl not in static_urls: ! # print "[tags] rendering %s ..." % (tagurl); ! # tools.render_url(config, tagurl) ! # But there was no "else" clause to do the static rendering, ! # so I added this: ! tools.render_url_statically(config, tagurl, "") # vim: set ts=4 et :