phd_pp_ru.py: phd_pp_ru.tmpl
@(umask 022; cheetah compile --nobackup $<)
+../htdocs/phd.pp.ru/news.tmpl: news_en
+ @(umask 022; PYTHONPATH=.; export PYTHONPATH; ./make-news.py en '' ../htdocs/phd.pp.ru/news.tmpl)
+
+../htdocs/phd.pp.ru/Russian/news.tmpl: news_ru
+ @(umask 022; PYTHONPATH=.; export PYTHONPATH; ./make-news.py ru Russian ../htdocs/phd.pp.ru/Russian/news.tmpl)
+
templates = $(shell find ../htdocs/phd.pp.ru -type f -name \*.tmpl -print)
htmls = $(patsubst %.tmpl,%.html,$(templates))
.PHONY: html
-html: phd_pp.py phd_pp_ru.py $(htmls)
+html: phd_pp.py phd_pp_ru.py ../htdocs/phd.pp.ru/news.tmpl ../htdocs/phd.pp.ru/Russian/news.tmpl $(htmls)
--- /dev/null
+#! /usr/local/bin/python -O
+
+__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"
+
+
+import sys, os
+from news import get_news, write_if_changed
+
+header, news_items = get_news(sys.argv[1])
+root_dir = sys.argv[2]
+
+new_text = [header]
+
+new_text.append("""
+<p class="head">
+ <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("""\
+ </ul>
+</p>
+#end def
+$phd_pp_ru.respond(self)
+""")
+
+write_if_changed(sys.argv[3], ''.join(new_text))
--- /dev/null
+"""News"""
+
+__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"
+__docformat__ = "epytext en"
+
+__all__ = ["get_news", "write_if_changed"]
+
+
+class NewsItem(object):
+ def __init__(self, date, title, rel_link):
+ self.date = date
+ self.title = title
+ self.rel_link = rel_link
+
+def get_news(lang):
+ """Get news
+
+ @param lang: langauge
+ @type lang: a string 'en' or 'ru'
+ @return: a tuple of (lnaguge-dependent header, a list of new items)
+
+ """
+ news_tmpl_file = open("news.tmpl-%s" % lang, 'r')
+ header = news_tmpl_file.read()
+ news_tmpl_file.close()
+
+ news_items_file = open("news_%s" % lang, 'r')
+ news_text = news_items_file.read()
+ news_items_file.close()
+
+ news_items = []
+ for line in news_text.split('\n'):
+ if not line: continue
+ date, rel_link, title = line.split(None, 2)
+ news_items.append(NewsItem(date, title, rel_link))
+
+ return header, news_items
+
+
+def write_if_changed(filename, new_text):
+ try:
+ infile = open(filename, 'r')
+ old_text = infile.read()
+ infile.close()
+ except IOError:
+ old_text = None
+
+ if old_text <> new_text:
+ print "Writing", filename
+ outfile = open(filename, 'w')
+ outfile.write(new_text)
+ outfile.close()
--- /dev/null
+#extends phd_pp_ru
+#implements respond
+#attr $Title = "Oleg BroytMann's Personal Page - News"
+#attr $Description = "BroytMann News Page Index Document"
+#attr $Copyright = 2004
+##
+#def body_html
+<H1>Most recently changed files</H1>
--- /dev/null
+#extends phd_pp_ru
+#implements respond
+#attr $Title = "Oleg BroytMann's Personal Page - News"
+#attr $Description = "BroytMann News Page Index Document"
+#attr $Copyright = 2004
+#attr $Prev = "index.html"
+##
+#def body_html
+<H1>Последние изменённые файлы</H1>
"июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"
]
-
-def write_if_changed(filename, new_text):
- try:
- infile = open(filename, 'r')
- old_text = infile.read()
- infile.close()
- except IOError:
- old_text = None
-
- if old_text <> new_text:
- print "Writing", filename
- outfile = open(filename, 'w')
- outfile.write(new_text)
- outfile.close()
+from news import write_if_changed
def write_template(level, year, month, day, titles, tags=None):