# -*- coding: koi8-r -*-
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2021 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2024 PhiloSoft Design"
import sys, os
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib import quote
+
from Cheetah.Template import Template
from Cheetah.compat import string_type
from blog_db import blog_root, load_blog, save_blog
from news import write_if_changed
+def encode_tag(tag):
+ return quote(tag.replace(' ', '_'))
def write_template(level, year, month, day, titles, tags=None):
path = [blog_root]
first_tag = False
else:
new_text.append(' - ')
- new_text.append("""<a href="tags/%s.html">%s (%d)</a>""" % (tag, tag, count))
+ new_text.append("""<a href="tags/%s.html">%s (%d)</a>""" % (
+ encode_tag(tag), tag, count))
new_text.append('''
</p>
''')
for i, (count, tag, links) in enumerate(all_tags):
new_text.append("""\
<dt><a href="%s.html">%s (%d)</a></dt>
-""" % (tag, tag, count))
+""" % (encode_tag(tag), tag, count))
first = all_tags[0][1]
if i == 0:
#end def
$phd_site.respond(self)
""")
- write_if_changed(os.path.join(blog_root, "tags", tag+".tmpl"), ''.join(tag_text))
+ write_if_changed(os.path.join(blog_root, "tags",
+ tag.replace(' ', '_') + ".tmpl"),
+ ''.join(tag_text))
new_text.append("""\
</dl>
url_path)
items.append(item)
item.baseURL = baseURL
- item.categoryList = tags
+ item.categoryList = [t.decode('koi8-r').encode('utf-8') for t in tags]
body = bodies[(year, month, day, file)]
body = absolute_urls(body, baseURL + url_path)
try: