From: Oleg Broytman
Date: Tue, 21 May 2024 16:34:27 +0000 (+0300)
Subject: Fix(Makefile): All generated files depend on `phd.py`
X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;hp=ee424085d4a516ac2e599e66f023f05dd3a7b7b9;p=phdru.name%2Fphdru.name.git
Fix(Makefile): All generated files depend on `phd.py`
---
diff --git a/Makefile b/Makefile
index 5064363..f390912 100644
--- 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 $@
-%.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 >$@
@@ -30,7 +30,7 @@ phdru.name: blog news
.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
@@ -40,7 +40,7 @@ templates = $(shell find ../htdocs/phdru.name -type f -name \*.tmpl -print)
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
diff --git a/phd.py b/phd.py
index a68db56..0a6a4e5 100644
--- a/phd.py
+++ b/phd.py
@@ -31,7 +31,7 @@ class phd(Template):
if dirs_to_root:
root = "../"*dirs_to_root
else:
- root = ''
+ root = './'
self.root = root
path = '/'.join(directories) + '/' + \
self._fileBaseName.replace(".tmpl", ".html")
@@ -166,7 +166,7 @@ class phd(Template):
% quote_string(query)
def lurkmoar(self, query):
- return "https://lurkmore.to/%s" % quote_string(
+ return "http://lurklurk.com/%s" % quote_string(
query.replace(' ', '_'), ext_safe=',')
diff --git a/phd_site.tmpl b/phd_site.tmpl
index 65bb058..67eb341 100644
--- a/phd_site.tmpl
+++ b/phd_site.tmpl
@@ -139,8 +139,12 @@ $style
#end if
$body
+#from urllib import quote
+#def encode_tag(tag):
+$quote(tag.decode('utf-8').encode('koi8-r').replace(' ', '_'))
+#end def
#def link_tag($tag)
-$tag
+$tag
#end def
#if $Tag
diff --git a/reindex_blog.py b/reindex_blog.py
index 0f1a8f5..0b7c2a6 100755
--- a/reindex_blog.py
+++ b/reindex_blog.py
@@ -2,9 +2,14 @@
# -*- coding: koi8-r -*-
__author__ = "Oleg Broytman "
-__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
@@ -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("""\
@@ -545,7 +555,7 @@ for item in tuple(reversed(all_titles_tags))[:10]:
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: