]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Blog feeds.
authorOleg Broytman <phd@phdru.name>
Fri, 17 Mar 2006 14:01:15 +0000 (14:01 +0000)
committerOleg Broytman <phd@phdru.name>
Fri, 17 Mar 2006 14:01:15 +0000 (14:01 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@36 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

Makefile
atom_10.tmpl
make-news.py
reindex_blog.py
rss_20.tmpl

index 7bedccc0e325932c5d5b91453c568a041c386381..2669ac11253b5b2d143e4f1992f12b93c4930d88 100644 (file)
--- 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
 
 
index 8c601e03589220f30ac5e1b61c5b2ddc2b3815a2..23be7680308897c2f177033ca384ca9ae61c96c7 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="koi8-r"?>
 <feed xmlns="http://www.w3.org/2005/Atom">
   <title>$title</title>
-  <id>${baseURL}news.html</id>
+  <id>$baseURL$indexFile</id>
   <link rel="self" type="application/atom+xml" href="${baseURL}atom_10.xml" />
-  <link rel="alternate" type="text/html" href="${baseURL}news.html" />
+  <link rel="alternate" type="text/html" href="$baseURL$indexFile" />
   <updated>${posts[0].date}T00:00:00Z</updated>
   <author>
     <name>$author</name>
index e9ab91e175b77b1b57e86bbd3038e890ef79f1df..4f132f7cb4f5813d1b355850c8874796622e29de 100755 (executable)
@@ -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",
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)
index 1ead69cf5e141421027a3379f238a659b2fb568d..5fa26fff59fac2b5668f4cea64f44a5b75b41963 100644 (file)
@@ -2,7 +2,7 @@
 <rss version="2.0">
   <channel>
     <title>$title</title>
-    <link>${baseURL}news.html</link>
+    <link>$baseURL$indexFile</link>
     <description>$description</description>
     <language>$lang</language>
     <webMaster>$author &lt;$email&gt;</webMaster>