From 6adf227bb17bd543f336617c96adc54fee72a706 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 17 Mar 2006 14:01:15 +0000 Subject: [PATCH] Blog feeds. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@36 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- Makefile | 2 +- atom_10.tmpl | 4 ++-- make-news.py | 1 + reindex_blog.py | 43 ++++++++++++++++++++++++++++++++++++++++++- rss_20.tmpl | 2 +- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7bedccc..2669ac1 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ news: atom_10.py rss_20.py .PHONY: blog -blog: +blog: atom_10.py rss_20.py @./reindex_blog_ru diff --git a/atom_10.tmpl b/atom_10.tmpl index 8c601e0..23be768 100644 --- a/atom_10.tmpl +++ b/atom_10.tmpl @@ -1,9 +1,9 @@ $title - ${baseURL}news.html + $baseURL$indexFile - + ${posts[0].date}T00:00:00Z $author diff --git a/make-news.py b/make-news.py index e9ab91e..4f132f7 100755 --- a/make-news.py +++ b/make-news.py @@ -41,6 +41,7 @@ from rss_20 import rss_20 namespace = { "title": "Oleg Broytmann's Personal Page - News", "baseURL": "http://phd.pp.ru/", + "indexFile": "news.html", "description": "", "lang": lang, "author": "Oleg Broytmann", diff --git a/reindex_blog.py b/reindex_blog.py index da9f07a..7471743 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -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) diff --git a/rss_20.tmpl b/rss_20.tmpl index 1ead69c..5fa26ff 100644 --- a/rss_20.tmpl +++ b/rss_20.tmpl @@ -2,7 +2,7 @@ $title - ${baseURL}news.html + $baseURL$indexFile $description $lang $author <$email> -- 2.39.2