]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - reindex_blog.py
Blog feeds.
[phdru.name/phdru.name.git] / reindex_blog.py
index da9f07ae7f4c60290bdcc5f16c3a01b1bc7b7480..74717438d9e99d5629ae04266b10db48be40a595 100755 (executable)
@@ -258,8 +258,9 @@ $phd_pp_ru.respond(self)
    write_if_changed(index_name, ''.join(new_text))
 
 
-all_titles = []
 all_tags = {}
+all_titles = []
+all_titles_tags = []
 
 for year in sorted(years.keys()):
    year_titles = []
@@ -273,6 +274,7 @@ for year in sorted(years.keys()):
             for file, title, lead, tags in blog[key]:
                if file.endswith(".tmpl"): file = file[:-len("tmpl")] + "html"
                value = (year, month, day, file, title, lead)
+               all_titles_tags.append((year, month, day, file, title, lead, tags))
                all_titles.append(value)
                year_titles.append(value)
                month_titles.append(value)
@@ -357,3 +359,42 @@ new_text.append("""\
 $phd_pp_ru.respond(self)
 """)
 write_if_changed(os.path.join(blog_root, "tags", "index.tmpl"), ''.join(new_text))
+
+
+from atom_10 import atom_10
+from rss_20 import rss_20
+from news import NewsItem
+
+baseURL = "http://phd.pp.ru/Russian/blog/"
+
+items = []
+for item in tuple(reversed(all_titles_tags))[:10]:
+   year, month, day, file, title, lead, tags = item
+   if lead:
+      lead = lead + ' '
+   else:
+      lead = ''
+   item = NewsItem(
+      "%s-%s-%s" % (year, month, day),
+      "%s%s" % (lead, title),
+      "%s/%s/%s/%s" % (year, month, day, file)
+   )
+   items.append(item)
+   item.baseURL = baseURL
+   item.categoryList = tags
+
+namespace = {
+   "title": "Oleg Broytmann's blog",
+   "baseURL": baseURL,
+   "indexFile": "",
+   "description": "",
+   "lang": "ru",
+   "author": "Oleg Broytmann",
+   "email": "phd@phd.pp.ru",
+   "posts": items,
+}
+
+atom_tmpl = str(atom_10(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "atom_10.xml"), atom_tmpl)
+rss_tmpl = str(rss_20(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "rss_20.xml"), rss_tmpl)