From ae794083b2caae0551bfa357594a7a27e684bd58 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Sat, 21 Jan 2012 02:47:45 +0100 Subject: First working version of clickable tags --- blogthon.cgi | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/blogthon.cgi b/blogthon.cgi index 9217901..786db74 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -253,6 +253,7 @@ if post_display: allentries_display = action.getvalue("a") feed_display = action.getvalue("feed") +tag_display = action.getvalue("t") if not month_display: month_display = "" @@ -269,6 +270,9 @@ if not allentries_display: if not feed_display: feed_display = "" +if not tag_display: + tag_display = "" + ctitle = action.getvalue("ctitle") cname = action.getvalue("cname") ctext = action.getvalue("ctext") @@ -324,7 +328,16 @@ if cname and ctext and ctitle: # Read entries and store their title and timestamp entries = [] -entries_list = glob(os.path.join(entries_dir, "*." + entries_suffix)) +if tag_display != "": + entries_list = [] + tagfile = open(os.path.join(entries_dir, "tags"), "r") + tagindex = pickle.load(tagfile) + tagfile.close() + for tag in tagindex: + if tag[0] == tag_display: + entries_list.append(tag[1]) +else: + entries_list = glob(os.path.join(entries_dir, "*." + entries_suffix)) for entry in entries_list: title = entry.replace(entries_dir, "", 1) @@ -625,7 +638,10 @@ else: # Read tags tagline = content.readline().strip() if re.match(line_start_plus, tagline): - tagline = tagline.replace("+", "") + tagline_items = tagline.split("+") + tagline = "" + for tag in tagline_items: + tagline += "%s " % (blog_url, tag, tag) if tags == "True": print(ind*4 + "
Tags: %s
" % tagline) else: -- cgit v1.2.3