X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=make-news.py;h=d120b30e1de75765e10aa2dae5abfbc693db730b;hb=refs%2Fheads%2Fmaster;hp=29ebe9d65fef368bbdf021f20ea5670955f2b5be;hpb=17ba3d2cde1d5f71d7d730536b5d79d8bfcb1690;p=phdru.name%2Fphdru.name.git
diff --git a/make-news.py b/make-news.py
index 29ebe9d..d120b30 100755
--- a/make-news.py
+++ b/make-news.py
@@ -1,12 +1,15 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: koi8-r -*-
__author__ = "Oleg Broytman
-
""")
if lang == "en":
- new_text.append("""\
+ new_text.append("""\
News are also available in
Atom 1.0
and RSS 2.0
@@ -38,7 +40,7 @@ formats.
""")
elif lang == "ru":
- new_text.append("""\
+ new_text.append("""\
îÏ×ÏÓÔÅ×ÁÑ ÌÅÎÔÁ × ÆÏÒÍÁÔÁÈ
Atom 1.0
É RSS 2.0
.
@@ -53,39 +55,42 @@ $phd_site.respond(self)
write_if_changed(os.path.join(root, "news.tmpl"), ''.join(new_text))
-from atom_10 import atom_10
-from rss_20 import rss_20
-
namespace = {
- "title": "Oleg Broytman's Personal Page - News",
- "baseURL": "http://phdru.name/",
- "indexFile": "news.html",
- "description": "",
- "lang": lang,
- "author": "Oleg Broytman",
- "email": "phd@phdru.name",
- "generator": os.path.basename(sys.argv[0]),
- "posts": news_items,
+ "title": "Oleg Broytman's Personal Page - News",
+ "baseURL": "https://phdru.name/",
+ "indexFile": "news.html",
+ "description": "",
+ "lang": lang,
+ "author": "Oleg Broytman",
+ "email": "phd@phdru.name",
+ "generator": os.path.basename(sys.argv[0]),
+ "posts": news_items,
}
if lang == "ru":
- namespace["title"] = "Oleg Broytman's Personal Page - Russian News"
- namespace["baseURL"] = baseURL = "http://phdru.name/Russian/"
- for item in news_items:
- item.baseURL = baseURL
+ namespace["title"] = "Oleg Broytman's Personal Page - Russian News"
+ namespace["baseURL"] = baseURL = "https://phdru.name/Russian/"
+ for item in news_items:
+ item.baseURL = baseURL
+ if isinstance(item.title, bytes):
+ item.title = item.title.decode('koi8-r').encode('utf-8')
for item in news_items:
- href_parts = item.rel_link.split('/')
- if href_parts:
- if href_parts[0] == '.':
- category = "Home page"
- elif href_parts[0] == "..":
- category = href_parts[1]
- else:
- category = href_parts[0]
- if category: item.categoryList = [category]
-
-atom_tmpl = str(atom_10(searchList=[namespace]))
+ href_parts = item.rel_link.split('/')
+ if href_parts:
+ if href_parts[0] == '.':
+ category = "Home page"
+ elif href_parts[0] == "..":
+ category = href_parts[1]
+ else:
+ category = href_parts[0]
+ if category: item.categoryList = [category]
+
+atom_tmpl = atom_10(searchList=[namespace])
+rss_tmpl = rss_20(searchList=[namespace])
+
+atom_tmpl = str(atom_tmpl)
+rss_tmpl = str(rss_tmpl)
+
write_if_changed(os.path.join(root, "atom_10.xml"), atom_tmpl)
-rss_tmpl = str(rss_20(searchList=[namespace]))
write_if_changed(os.path.join(root, "rss_20.xml"), rss_tmpl)