]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Fix(Makefile): All generated files depend on `phd.py` master
authorOleg Broytman <phd@phdru.name>
Tue, 21 May 2024 16:34:27 +0000 (19:34 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 21 May 2024 16:34:27 +0000 (19:34 +0300)
Makefile
phd.py
phd_site.tmpl
reindex_blog.py

index 506436311a8e6ee7bc6640afbc953358f6a0bd3d..f3909120a78746264df3adb891932a4a96471345 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@
 %.py: %.tmpl
        umask 022; python2.7 `which cheetah` compile --encoding=koi8-r --settings='encoding="koi8-r"' --nobackup $< && compyle $@ && chmod +x $@
 
 %.py: %.tmpl
        umask 022; python2.7 `which cheetah` compile --encoding=koi8-r --settings='encoding="koi8-r"' --nobackup $< && compyle $@ && chmod +x $@
 
-%.html: %.tmpl phd_site.py
+%.html: %.tmpl phd.py phd_site.py
        umask 022; PYTHONPATH=. PYTHONIOENCODING=koi8-r:replace python2.7 `which cheetah` fill --encoding=koi8-r --settings='encoding="koi8-r"' --nobackup --stdout $< | iconv -c -f utf-8 -t koi8-r >$@
 
 
        umask 022; PYTHONPATH=. PYTHONIOENCODING=koi8-r:replace python2.7 `which cheetah` fill --encoding=koi8-r --settings='encoding="koi8-r"' --nobackup --stdout $< | iconv -c -f utf-8 -t koi8-r >$@
 
 
@@ -30,7 +30,7 @@ phdru.name: blog news
 
 
 .PHONY: blog
 
 
 .PHONY: blog
-blog: phd_site.py atom_10.py rss_20.py
+blog: phd.py phd_site.py atom_10.py rss_20.py
        ./reindex_blog_ru
        $(MAKE) html
 
        ./reindex_blog_ru
        $(MAKE) html
 
@@ -40,7 +40,7 @@ templates = $(shell find ../htdocs/phdru.name -type f -name \*.tmpl -print)
 htmls = $(patsubst %.tmpl,%.html,$(templates))
 
 .PHONY: html
 htmls = $(patsubst %.tmpl,%.html,$(templates))
 
 .PHONY: html
-html: phd_site.py $(htmls) special-templates sitemap
+html: phd.py phd_site.py $(htmls) special-templates sitemap
 
 
 .PHONY: news
 
 
 .PHONY: news
diff --git a/phd.py b/phd.py
index 4aa206c47fc1637a83cc65b1b6955a9efbc1fbdd..0a6a4e54de9415790155401a26dba3a57c95496f 100644 (file)
--- a/phd.py
+++ b/phd.py
@@ -31,7 +31,7 @@ class phd(Template):
         if dirs_to_root:
             root = "../"*dirs_to_root
         else:
         if dirs_to_root:
             root = "../"*dirs_to_root
         else:
-            root = ''
+            root = './'
         self.root = root
         path = '/'.join(directories) + '/' + \
             self._fileBaseName.replace(".tmpl", ".html")
         self.root = root
         path = '/'.join(directories) + '/' + \
             self._fileBaseName.replace(".tmpl", ".html")
index 65bb058a079d02463b720786570452ecbeac1367..67eb3412546901353bbb619c3e55bad2b3373f4b 100644 (file)
@@ -139,8 +139,12 @@ $style
 #end if
 </p>
 $body
 #end if
 </p>
 $body
+#from urllib import quote
+#def encode_tag(tag):
+$quote(tag.decode('utf-8').encode('koi8-r').replace(' ', '_'))
+#end def
 #def link_tag($tag)
 #def link_tag($tag)
-<a href="../../../tags/${tag}.html">$tag</a>
+<a href="../../../tags/${encode_tag(tag)}.html">$tag</a>
 #end def
 #if $Tag
 <hr width="90%">
 #end def
 #if $Tag
 <hr width="90%">
index 0f1a8f5f9b185fe34ccecbdf8f2b297f3bd0b3d0..0b7c2a6dd9fbf39af81f038f172c0b998470b84b 100755 (executable)
@@ -2,9 +2,14 @@
 # -*- coding: koi8-r -*-
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
 # -*- 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
 
 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 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
 
 
 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]
 
 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(' - ')
             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>
 ''')
       new_text.append('''
 </p>
 ''')
@@ -362,7 +370,7 @@ linux 
 for i, (count, tag, links) in enumerate(all_tags):
    new_text.append("""\
    <dt><a href="%s.html">%s (%d)</a></dt>
 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:
 
    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)
 """)
 #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>
 
 new_text.append("""\
 </dl>
@@ -545,7 +555,7 @@ for item in tuple(reversed(all_titles_tags))[:10]:
       url_path)
    items.append(item)
    item.baseURL = baseURL
       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:
    body = bodies[(year, month, day, file)]
    body = absolute_urls(body, baseURL + url_path)
    try: