]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - make-news.py
TODO: проставить в блоге ссылки на пред./след. посты
[phdru.name/phdru.name.git] / make-news.py
index 5d196bf9760b9e83adbf3c0af772db9c51485a99..f6929c78302ea54093506402c87e0b6bc5d589df 100755 (executable)
@@ -1,12 +1,8 @@
-#! /usr/local/bin/python -O
+#! /usr/bin/env python
 # -*- coding: koi8-r -*-
 
-__version__ = "$Revision$"[11:-2]
-__revision__ = "$Id$"[5:-2]
-__date__ = "$Date$"[7:-2]
-__author__ = "Oleg BroytMann <phd@phd.pp.ru>"
-__copyright__ = "Copyright (C) 2006 PhiloSoft Design"
-
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
 
 import sys, os
 from news import get_news, write_if_changed
@@ -19,16 +15,14 @@ header, news_items = get_news(lang)
 new_text = [header]
 
 new_text.append("""
-<p class="head">
-   <ul>
+<ul>
 """)
 
 for item in news_items:
-   new_text.append('      <li><a href="%s">%s - %s</a></li>\n' % (item.rel_link, item.date, item.title))
+   new_text.append('   <li><a href="%s">%s - %s</a></li>\n' % (item.rel_link, item.date, item.title))
 
 new_text.append("""\
-   </ul>
-</p>
+</ul>
 
 <p class="head">
 """)
@@ -51,7 +45,7 @@ elif lang == "ru":
 new_text.append("""\
 </p>
 #end def
-$phd_pp_ru.respond(self)
+$phd_site.respond(self)
 """)
 
 write_if_changed(os.path.join(root, "news.tmpl"), ''.join(new_text))
@@ -61,22 +55,23 @@ from atom_10 import atom_10
 from rss_20 import rss_20
 
 namespace = {
-   "title": "Oleg Broytmann's Personal Page - News",
-   "baseURL": "http://phd.pp.ru/",
+   "title": "Oleg Broytman's Personal Page - News",
+   "baseURL": "http://phdru.name/",
    "indexFile": "news.html",
    "description": "",
    "lang": lang,
-   "author": "Oleg Broytmann",
-   "email": "phd@phd.pp.ru",
+   "author": "Oleg Broytman",
+   "email": "phd@phdru.name",
    "generator": os.path.basename(sys.argv[0]),
    "posts": news_items,
 }
 
 if lang == "ru":
-   namespace["title"] = "Oleg Broytmann's Personal Page - Russian News"
-   namespace["baseURL"] = baseURL = "http://phd.pp.ru/Russian/"
+   namespace["title"] = "Oleg Broytman's Personal Page - Russian News"
+   namespace["baseURL"] = baseURL = "http://phdru.name/Russian/"
    for item in news_items:
       item.baseURL = baseURL
+      item.title = item.title.decode('koi8-r').encode('utf-8')
 
 for item in news_items:
    href_parts = item.rel_link.split('/')
@@ -89,7 +84,7 @@ for item in news_items:
          category = href_parts[0]
       if category: item.categoryList = [category]
 
-atom_tmpl = str(atom_10(searchList=[namespace]))
+atom_tmpl = unicode(atom_10(searchList=[namespace])).encode('koi8-r')
 write_if_changed(os.path.join(root, "atom_10.xml"), atom_tmpl)
-rss_tmpl = str(rss_20(searchList=[namespace]))
+rss_tmpl = unicode(rss_20(searchList=[namespace])).encode('koi8-r')
 write_if_changed(os.path.join(root, "rss_20.xml"), rss_tmpl)