From: Oleg Broytman
+#
+# User configuration file for Fvwm2
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
diff --git a/dotfiles2html/gvimrc.head b/dotfiles2html/gvimrc.head
new file mode 100644
index 0000000..e89c7bf
--- /dev/null
+++ b/dotfiles2html/gvimrc.head
@@ -0,0 +1,10 @@
+
+"
+" User configuration file for Vi IMproved (GUI version)
+"
+" It is sourced after .vimrc
+"
+" Text version here
+"
+" Generated by gvim :runtime syntax/2html.vim
+"
diff --git a/dotfiles2html/init.py.head b/dotfiles2html/init.py.head
new file mode 100644
index 0000000..7379fa7
--- /dev/null
+++ b/dotfiles2html/init.py.head
@@ -0,0 +1,18 @@
+
+# This is startup file for interactive python.
+# It is not automatically loaded by python interpreter.
+# To instruct the interpreter to load it insert the following commands
+# into your .profile (use whatever syntax and initialization file
+# is appropriate for your shell):
+#
+# PYTHONSTARTUP=$HOME/init.py # or where you have really put it
+# export PYTHONSTARTUP
+#
+# Due to nested_scopes and pydoc.help(*args, **kwds) this file only works with
+# Python 2.1 or higher. For Python 1.5.2 and 2.0 use init_old.py.
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
+
diff --git a/dotfiles2html/init_old.py.head b/dotfiles2html/init_old.py.head
new file mode 100644
index 0000000..6096e17
--- /dev/null
+++ b/dotfiles2html/init_old.py.head
@@ -0,0 +1,17 @@
+
+# This is startup file for interactive python.
+# It is not automatically loaded by python interpreter.
+# To instruct the interpreter to load it insert the following commands
+# into your .profile (use whatever syntax and initialization file
+# is appropriate for your shell):
+#
+# PYTHONSTARTUP=$HOME/init_old.py # or where you have really put it
+# export PYTHONSTARTUP
+#
+# This is special version for Python 1.5.2 and Python 2.0.
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
+
diff --git a/dotfiles2html/mailcap.head b/dotfiles2html/mailcap.head
new file mode 100644
index 0000000..640fab1
--- /dev/null
+++ b/dotfiles2html/mailcap.head
@@ -0,0 +1,7 @@
+
+# MIME types -> viewers map.
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
diff --git a/dotfiles2html/mime.types.head b/dotfiles2html/mime.types.head
new file mode 100644
index 0000000..585ea25
--- /dev/null
+++ b/dotfiles2html/mime.types.head
@@ -0,0 +1,8 @@
+
+# File extension -> MIME type map.
+# MIME type Extension
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
diff --git a/dotfiles2html/muttrc.head b/dotfiles2html/muttrc.head
new file mode 100644
index 0000000..e81b8c8
--- /dev/null
+++ b/dotfiles2html/muttrc.head
@@ -0,0 +1,8 @@
+
+#
+# User configuration file for Mutt
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
diff --git a/dotfiles2html/procmailrc.head b/dotfiles2html/procmailrc.head
new file mode 100644
index 0000000..e1b96b6
--- /dev/null
+++ b/dotfiles2html/procmailrc.head
@@ -0,0 +1,8 @@
+
+#
+# User configuration file for Procmail
+#
+# Text version here
+#
+# Generated by gvim :runtime syntax/2html.vim
+#
diff --git a/dotfiles2html/vimrc.head b/dotfiles2html/vimrc.head
new file mode 100644
index 0000000..4114047
--- /dev/null
+++ b/dotfiles2html/vimrc.head
@@ -0,0 +1,10 @@
+
+"
+" User configuration file for Vi IMproved
+"
+" Text version here
+"
+" Generated by gvim :runtime syntax/2html.vim
+"
+" A number of scripts mentioned in the file are available here.
+"
diff --git a/make+update b/make+update
new file mode 100755
index 0000000..52021ed
--- /dev/null
+++ b/make+update
@@ -0,0 +1,2 @@
+#! /bin/sh
+./make-changed && exec ./update-all
diff --git a/make-all b/make-all
new file mode 100755
index 0000000..7bc7b88
--- /dev/null
+++ b/make-all
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+find ../htdocs/phd.pp.ru -type f -name \*.tmpl -print0 | \
+ xargs -r0 ./make-files
diff --git a/make-changed b/make-changed
new file mode 100755
index 0000000..a6c1b13
--- /dev/null
+++ b/make-changed
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+find ../htdocs/phd.pp.ru -type f -name \*.tmpl -print | \
+ ./make-changed.py | xargs -r ./make-files
diff --git a/make-changed.py b/make-changed.py
new file mode 100755
index 0000000..86a251b
--- /dev/null
+++ b/make-changed.py
@@ -0,0 +1,22 @@
+#! /usr/local/bin/python -O
+
+import sys, os
+
+main_tmpl_mtime = os.path.getmtime("phd_pp_ru.tmpl")
+main_prog_mtime = os.path.getmtime("phd_pp.py")
+
+for line in sys.stdin:
+ line = line.strip()
+ src_mtime = os.path.getmtime(line)
+
+ dest = line.replace(".tmpl", ".html")
+ try:
+ dest_mtime = os.path.getmtime(dest)
+ except OSError:
+ make = True
+ else:
+ make = (src_mtime > dest_mtime) or \
+ (main_tmpl_mtime > dest_mtime) or (main_prog_mtime > dest_mtime)
+
+ if make:
+ print line
diff --git a/make-files b/make-files
new file mode 100755
index 0000000..43b9c01
--- /dev/null
+++ b/make-files
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+umask 022
+PYTHONPATH=.
+export PYTHONPATH
+
+if [ phd_pp_ru.tmpl -nt phd_pp_ru.py ]; then
+ cheetah compile --nobackup phd_pp_ru.tmpl
+fi
+
+exec cheetah fill --nobackup "$@"
diff --git a/make-index b/make-index
new file mode 100755
index 0000000..be9b6ab
--- /dev/null
+++ b/make-index
@@ -0,0 +1,2 @@
+#! /bin/sh
+exec ./make-files ./files/index.tmpl
diff --git a/make-new b/make-new
new file mode 100755
index 0000000..f3c359b
--- /dev/null
+++ b/make-new
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+find ../htdocs/phd.pp.ru -type f -name \*.tmpl -mtime -1 -print0 | \
+ xargs -r0 ./make-files
diff --git a/phd_pp.py b/phd_pp.py
new file mode 100644
index 0000000..08b6bf6
--- /dev/null
+++ b/phd_pp.py
@@ -0,0 +1,86 @@
+import os, re, time
+from Cheetah.Template import Template
+
+
+# Copied from ZWiki
+
+urlchars = r'[A-Za-z0-9/:@_%~#=&\.\-\?\+\$,]+'
+urlendchar = r'[A-Za-z0-9/]'
+url = r'["=]?((about|gopher|http|https|ftp|mailto|file):%s)' % \
+ (urlchars+urlendchar)
+
+def _url2href(match):
+ url = match.group(0)
+ return '%s' % (url, url)
+
+
+full_dirs = len(os.getcwd().split('/')) + 1
+
+class phd_pp(Template):
+ def __init__(self, *args, **kw):
+ Template.__init__(self, *args, **kw)
+ directories = self._fileDirName.split('/')[full_dirs:] # remove directories up to "./files"
+ dirs_to_root = len(directories)
+ if dirs_to_root:
+ root = "../"*dirs_to_root
+ else:
+ root = ''
+ self.root = root
+ path = '/'.join(directories) + '/' + \
+ self._fileBaseName.replace(".tmpl", ".html")
+ if path[0] <> '/': path = '/' + path
+ self.path = path
+
+ def copyright(self, start_year):
+ this_year = time.localtime()[0]
+ if start_year >= this_year:
+ return this_year
+ if start_year == this_year - 1:
+ return "%s, %s" % (start_year, this_year)
+ return "%s-%s" % (start_year, this_year)
+
+ def body(self):
+ if hasattr(self, "body_html"):
+ return self.body_html()
+ if hasattr(self, "body_text"):
+ return self.text2html()
+ if hasattr(self, "body_rst"):
+ return self.rst2html()
+
+ def text2html(self):
+ body = re.sub(url, _url2href, self.body_text())
+
+ paragraphs = body.split("\n\n")
+
+ new_paras = []
+ for p in paragraphs:
+ parts = p.split("\n ")
+ parts[0] = parts[0].strip()
+ new_paras.append('\n
\n'.join(parts)) + + if self.Title: + title = "
\n'.join(new_paras) + return "%s
%s
" % (title, body) + + def rst2html(self): + from docutils.core import publish_parts + from locale import getpreferredencoding + encoding = getpreferredencoding() + + parts = publish_parts(self.body_rst(), writer_name="html") + + title = parts["title"].encode(encoding) or self.Title + if title: + title = "\xfc\xd4\xc1 \xd3\xd4\xd2\xc1\xce\xc9\xc3\xc1 http://phd.pp.ru') + __v = VFFSL(SL,"path",True) + if __v is not None: write(filter(__v, rawExpr='$path')) # from line 70, col 101. + write('\n\xc2\xd9\xcc\xc1 \xd3\xc7\xc5\xce\xc5\xd2\xc9\xd2\xcf\xd7\xc1\xce\xc1 ') + __v = VFFSL(SL,"last_modified_ru",True) + if __v is not None: write(filter(__v, rawExpr='$last_modified_ru')) # from line 71, col 20. + write(' \xc9\xda \xdb\xc1\xc2\xcc\xcf\xce\xc1 CheetahTemplate ') + __v = VFFSL(SL,"_fileBaseName",True) + if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 71, col 90. + write(';\n\xf7\xd9 \xcd\xcf\xd6\xc5\xd4\xc5 \xd5\xda\xce\xc1\xd4\xd8 \xcf \xd4\xc5\xc8\xce\xc9\xde\xc5\xd3\xcb\xc9\xc8 \xc1\xd3\xd0\xc5\xcb\xd4\xc1\xc8 \xdc\xd4\xcf\xc7\xcf \xd3\xc1\xca\xd4\xc1.\n
\n') + else: + write('This is the page http://phd.pp.ru') + __v = VFFSL(SL,"path",True) + if __v is not None: write(filter(__v, rawExpr='$path')) # from line 75, col 105. + write('.\nIt was generated on ') + __v = VFFSL(SL,"last_modified_en",True) + if __v is not None: write(filter(__v, rawExpr='$last_modified_en')) # from line 76, col 21. + write(' from CheetahTemplate ') + __v = VFFSL(SL,"_fileBaseName",True) + if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 76, col 85. + write(';\nread more about technical aspects of the site.\n
\n') + write('\n') + + ######################################## + ## END - generated method body + + return dummyTrans and trans.response().getvalue() or "" + + ################################################## + ## GENERATED ATTRIBUTES + + + Title = '' + + Description = None + + Keywords = None + + Copyright = None + + Prev = None + + Next = None + + refresh = None + + last_modified_en = time.strftime("%a, %d %b %Y %T GMT", time.gmtime()) + + last_modified_ru = time.strftime("%d.%m.%Y × %T", time.localtime()) + + styles = None + + __str__ = respond + + _mainCheetahMethod_for_phd_pp_ru= 'respond' + + +# CHEETAH was developed by Tavis Rudd, Mike Orr, Ian Bicking and Chuck Esterbrook; +# with code, advice and input from many other volunteers. +# For more information visit http://www.CheetahTemplate.org + +################################################## +## if run from command line: +if __name__ == '__main__': + phd_pp_ru().runAsMainProgram() + diff --git a/phd_pp_ru.tmpl b/phd_pp_ru.tmpl new file mode 100644 index 0000000..a488704 --- /dev/null +++ b/phd_pp_ru.tmpl @@ -0,0 +1,81 @@ +#encoding koi8-r +#extends phd_pp +#implements respond +#attr $Title = '' +#attr $Description = None +#attr $Keywords = None +#attr $Copyright = None +#attr $Prev = None +#attr $Next = None +#attr $refresh = None +#import time +#attr $last_modified_en = time.strftime("%a, %d %b %Y %T GMT", time.gmtime()) +#attr $last_modified_ru = time.strftime("%d.%m.%Y × %T", time.localtime()) +#attr $styles = None + + + + + + + +üÔÁ ÓÔÒÁÎÉÃÁ http://phd.pp.ru$path +ÂÙÌÁ ÓÇÅÎÅÒÉÒÏ×ÁÎÁ $last_modified_ru ÉÚ ÛÁÂÌÏÎÁ CheetahTemplate $_fileBaseName; +÷Ù ÍÏÖÅÔÅ ÕÚÎÁÔØ Ï ÔÅÈÎÉÞÅÓËÉÈ ÁÓÐÅËÔÁÈ ÜÔÏÇÏ ÓÁÊÔÁ. +
+#else +This is the page http://phd.pp.ru$path. +It was generated on $last_modified_en from CheetahTemplate $_fileBaseName; +read more about technical aspects of the site. +
+#end if + +#slurp diff --git a/reindex_blog.py b/reindex_blog.py new file mode 100755 index 0000000..be27835 --- /dev/null +++ b/reindex_blog.py @@ -0,0 +1,212 @@ +#! /usr/local/bin/python -O +# -*- coding: koi8-r -*- + +import sys, os +from glob import glob + +try: + import cPickle as pickle +except ImportError: + import pickle + +from Cheetah.Template import Template + +blog_filename = sys.argv[1] +try: + blog_file = open(blog_filename, "rb") +except IOError: + blog = {} +else: + blog = pickle.load(blog_file) + blog_file.close() + +years = {} +months = sys.argv[2:] +isdir = os.path.isdir + +if not months: + for year in os.listdir(os.curdir): + if isdir(year): + years[year] = {} + for month in os.listdir(year): + m = os.path.join(year, month) + if isdir(m): + months.append(m) + +days = [] +for month in months: + year, m = month.split(os.sep) + if month not in years: + years[year] = {} + years[year][m] = days_of_month = [] + for day in os.listdir(month): + d = os.path.join(month, day) + if isdir(d): + days.append(d) + days_of_month.append(d) + +for day in days: + for tmpl in glob(os.path.join(day, "*.tmpl")): + template = Template(file=tmpl) + title_parts = template.Title.split() + title = ' '.join(title_parts[6:]) + lead = getattr(template, "Lead", None) + + if title: + day_parts = day.split(os.sep) + blog[tuple(day_parts)] = (title, os.path.basename(tmpl), lead) + +blog_file = open(blog_filename, "wb") +pickle.dump(blog, blog_file, pickle.HIGHEST_PROTOCOL) +blog_file.close() + + +import locale +locale.setlocale(locale.LC_ALL, '') +from calendar import _localized_day, _localized_month + +locale.setlocale(locale.LC_TIME, 'C') +months_names_en = list(_localized_month('%B')) +months_abbrs_en = list(_localized_month('%b')) + +locale.setlocale(locale.LC_TIME, '') +months_names_ru = [month.lower() for month in _localized_month('%B')] + +months_names_ru0 = ['', "ÑÎ×ÁÒØ", "ÆÅ×ÒÁÌØ", "ÍÁÒÔ", "ÁÐÒÅÌØ", "ÍÁÊ", "ÉÀÎØ", + "ÉÀÌØ", "Á×ÇÕÓÔ", "ÓÅÎÔÑÂÒØ", "ÏËÔÑÂÒØ", "ÎÏÑÂÒØ", "ÄÅËÁÂÒØ" +] + + +def write_template(show_year, show_month, year, month, titles, cut=None, show_years=False): + index_tmpl = open(os.path.join(year, month, "index.tmpl"), 'w') + if show_year: + index_tmpl.write("""\ +#extends phd_pp_ru +#implements respond +#attr $Title = "Oleg BroytMann's blog" +#attr $Description = "BroytMann Russian Blog Index Document" +#attr $Copyright = %(cyear)s +## +#def body_html ++ %s%s. +
+''' % (lead, href, title)) + + if show_years: + years = {} + for key, tmpl, title, lead in save_titles: + year, month, day = key + years[year] = True + first_year = True + index_tmpl.write(''' ++''') + for year in sorted(years.keys()): + if first_year: + first_year = False + else: + index_tmpl.write(' - ') + index_tmpl.write('%s' % (year, year)) + index_tmpl.write(''' +
+''') + + index_tmpl.write("""\ +#end def +$phd_pp_ru.respond(self) +""") + index_tmpl.close() + + +def translate(tmpl): + if tmpl == "index.tmpl": tmpl = '' + if tmpl.endswith(".tmpl"): tmpl = tmpl[:-len("tmpl")] + "html" + return tmpl + + +all_titles = [] +for key in sorted(blog.keys()): + title, tmpl, lead = blog[key] + all_titles.append((key, translate(tmpl), title, lead)) + +for year in sorted(years.keys()): + year_titles = [] + months = years[year] + for month in sorted(months.keys()): + month_titles = [] + for day in sorted(months[month]): + day_parts = day.split(os.sep) + key = tuple(day_parts) + if key in blog: + title, tmpl, lead = blog[key] + tmpl = translate(tmpl) + year_titles.append((key, tmpl, title, lead)) + month_titles.append((key, tmpl, title, lead)) + write_template(False, False, year, month, month_titles) + write_template(False, True, year, '', year_titles) +write_template(True, True, '', '', all_titles, 5, True) diff --git a/reindex_blog_ru b/reindex_blog_ru new file mode 100755 index 0000000..ced4032 --- /dev/null +++ b/reindex_blog_ru @@ -0,0 +1,7 @@ +#! /bin/sh + +LC_TIME=ru_RU.KOI8-R +export LC_TIME + +cd ../htdocs/phd.pp.ru/Russian/blog && \ +exec ../../../../phd.pp.ru/reindex_blog.py ../../../../phd.pp.ru/index_ru "$@" diff --git a/update-ALL b/update-ALL new file mode 100755 index 0000000..69ea955 --- /dev/null +++ b/update-ALL @@ -0,0 +1,3 @@ +#! /bin/sh +cd ../htdocs && distribute -d phd.pp.ru && ssh oper.med.ru bin/sc && \ +cd "$HOME" && rsync -avPz oper.med.ru:.sitecopy . && exec distribute .sitecopy diff --git a/update-all b/update-all new file mode 100755 index 0000000..4423f10 --- /dev/null +++ b/update-all @@ -0,0 +1,2 @@ +#! /bin/sh +cd ../htdocs && exec distribute -d phd.pp.ru