First working version of clickable tags

This commit is contained in:
Stefan Ritter 2012-01-21 02:47:45 +01:00
parent d82d649c04
commit ae794083b2

View File

@ -253,6 +253,7 @@ if post_display:
allentries_display = action.getvalue("a") allentries_display = action.getvalue("a")
feed_display = action.getvalue("feed") feed_display = action.getvalue("feed")
tag_display = action.getvalue("t")
if not month_display: if not month_display:
month_display = "" month_display = ""
@ -269,6 +270,9 @@ if not allentries_display:
if not feed_display: if not feed_display:
feed_display = "" feed_display = ""
if not tag_display:
tag_display = ""
ctitle = action.getvalue("ctitle") ctitle = action.getvalue("ctitle")
cname = action.getvalue("cname") cname = action.getvalue("cname")
ctext = action.getvalue("ctext") ctext = action.getvalue("ctext")
@ -324,6 +328,15 @@ if cname and ctext and ctitle:
# Read entries and store their title and timestamp # Read entries and store their title and timestamp
entries = [] entries = []
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)) entries_list = glob(os.path.join(entries_dir, "*." + entries_suffix))
for entry in entries_list: for entry in entries_list:
@ -625,7 +638,10 @@ else:
# Read tags # Read tags
tagline = content.readline().strip() tagline = content.readline().strip()
if re.match(line_start_plus, tagline): if re.match(line_start_plus, tagline):
tagline = tagline.replace("+", "") tagline_items = tagline.split("+")
tagline = ""
for tag in tagline_items:
tagline += "<a href=\"%s?t=%s\">%s</a> " % (blog_url, tag, tag)
if tags == "True": if tags == "True":
print(ind*4 + "<div class=\"tags\"><b>Tags:</b> %s</div>" % tagline) print(ind*4 + "<div class=\"tags\"><b>Tags:</b> %s</div>" % tagline)
else: else: