X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=inline;f=reindex_blog.py;h=0b7c2a6dd9fbf39af81f038f172c0b998470b84b;hb=e05121e618d19083c3626cf53cf74a2232d4c2da;hp=ab257d55848b0cfadd9b782752365c0dda5f902a;hpb=b0f6761ec25c37779fc4ba3a8b4ff1cda0a401ef;p=phdru.name%2Fphdru.name.git
diff --git a/reindex_blog.py b/reindex_blog.py
index ab257d5..0b7c2a6 100755
--- a/reindex_blog.py
+++ b/reindex_blog.py
@@ -2,9 +2,14 @@
# -*- coding: koi8-r -*-
__author__ = "Oleg Broytman "
-__copyright__ = "Copyright (C) 2006-2017 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
@@ -95,6 +100,8 @@ months_names_ru0 = ['', "
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]
@@ -234,7 +241,8 @@ def write_template(level, year, month, day, titles, tags=None):
first_tag = False
else:
new_text.append(' - ')
- new_text.append("""%s (%d)""" % (tag, tag, count))
+ new_text.append("""%s (%d)""" % (
+ encode_tag(tag), tag, count))
new_text.append('''
''')
@@ -362,7 +370,7 @@ linux
for i, (count, tag, links) in enumerate(all_tags):
new_text.append("""\
%s (%d)
-""" % (tag, tag, count))
+""" % (encode_tag(tag), tag, count))
first = all_tags[0][1]
if i == 0:
@@ -427,7 +435,9 @@ for i, (count, tag, links) in enumerate(all_tags):
#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("""\
@@ -482,6 +492,8 @@ class AbsURLHTMLParser(_HTMLParser):
self.accumulator += '