]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Scripts to (re)build phd.pp.ru site.
authorOleg Broytman <phd@phdru.name>
Sat, 25 Feb 2006 12:58:59 +0000 (12:58 +0000)
committerOleg Broytman <phd@phdru.name>
Sat, 25 Feb 2006 12:58:59 +0000 (12:58 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@1 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

25 files changed:
dotfiles2html/dotfile2html.vim [new file with mode: 0644]
dotfiles2html/dotfiles2html.py [new file with mode: 0755]
dotfiles2html/fvwm2rc.head [new file with mode: 0644]
dotfiles2html/gvimrc.head [new file with mode: 0644]
dotfiles2html/init.py.head [new file with mode: 0644]
dotfiles2html/init_old.py.head [new file with mode: 0644]
dotfiles2html/mailcap.head [new file with mode: 0644]
dotfiles2html/mime.types.head [new file with mode: 0644]
dotfiles2html/muttrc.head [new file with mode: 0644]
dotfiles2html/procmailrc.head [new file with mode: 0644]
dotfiles2html/vimrc.head [new file with mode: 0644]
make+update [new file with mode: 0755]
make-all [new file with mode: 0755]
make-changed [new file with mode: 0755]
make-changed.py [new file with mode: 0755]
make-files [new file with mode: 0755]
make-index [new file with mode: 0755]
make-new [new file with mode: 0755]
phd_pp.py [new file with mode: 0644]
phd_pp_ru.py [new file with mode: 0644]
phd_pp_ru.tmpl [new file with mode: 0644]
reindex_blog.py [new file with mode: 0755]
reindex_blog_ru [new file with mode: 0755]
update-ALL [new file with mode: 0755]
update-all [new file with mode: 0755]

diff --git a/dotfiles2html/dotfile2html.vim b/dotfiles2html/dotfile2html.vim
new file mode 100644 (file)
index 0000000..20795ed
--- /dev/null
@@ -0,0 +1,15 @@
+" Convert the file to HTML
+highlight Constant gui=NONE guifg=NONE guibg=NONE
+highlight Special gui=NONE guibg=NONE
+highlight Normal gui=NONE guifg=NONE guibg=NONE
+highlight Error gui=NONE guifg=NONE guibg=NONE
+runtime syntax/2html.vim
+
+normal 1G
+1,/^$/d
+
+normal Gk
+normal 2dd
+
+write
+quitall
diff --git a/dotfiles2html/dotfiles2html.py b/dotfiles2html/dotfiles2html.py
new file mode 100755 (executable)
index 0000000..f13e4dc
--- /dev/null
@@ -0,0 +1,65 @@
+#! /usr/local/bin/python -O
+
+import os, shutil
+os.umask(0022) # octal; -rw-r--r--
+
+from m_lib.m_path import get_homedir
+home_dir = get_homedir()
+
+
+def add_headers(fname, prev, next):
+   head_fname = os.path.join(home_dir, fname + ".head")
+   head_file = open(head_fname, 'r')
+   head = head_file.read()
+   head_file.close()
+
+   html_fname = fname + ".html"
+   html_file = open(html_fname, 'r')
+   html = html_file.read()
+   html_file.close()
+
+   html_file = open(html_fname, 'w')
+   html_file.write("#extends phd_pp_ru\n")
+   html_file.write("#implements respond\n")
+   html_file.write("#attr $Title = \".%s\"\n" % fname)
+   html_file.write("#attr $Copyright = 2003\n")
+   if prev:
+      html_file.write("#attr $Prev = \"%s.html\"\n" % prev)
+   if next:
+      html_file.write("#attr $Next = \"%s.html\"\n" % next)
+   html_file.write("\n")
+   html_file.write("#def body_html\n")
+   html_file.write("#raw\n")
+   html_file.write(head)
+   html_file.write("\n")
+   html_file.write(html)
+   html_file.write("#end raw\n")
+   html_file.write("#end def\n")
+   html_file.write("$phd_pp_ru.respond(self)\n")
+   html_file.close()
+
+
+file_types = (("fvwm2rc", "fvwm"),
+      ("mailcap", "conf"), ("mime.types", "conf"),
+      ("muttrc", "muttrc"), ("procmailrc", "procmail"),
+      ("vimrc", "vim"), ("gvimrc", "vim"),
+      ("init.py", "python"), ("init_old.py", "python"))
+ft_len = len(file_types)
+
+for i, (fname, ftype) in enumerate(file_types):
+   if os.path.exists('.' + fname) and not os.path.exists(fname):
+      shutil.copy2('.' + fname, fname)
+   if os.path.exists(fname):
+      os.system("""exec gvim -f -c "set syntax=%s" -c ":source %s/dotfile2html.vim" "%s"
+         """ % (ftype, home_dir, fname))
+      if i == 0:
+         prev = None
+      else:
+         prev = file_types[i-1][0]
+      if i >= ft_len - 1:
+         next = None
+      else:
+         next = file_types[i+1][0]
+      add_headers(fname, prev, next)
+      os.rename(fname + ".html", fname + ".tmpl")
+      os.chmod(fname, 0644)
diff --git a/dotfiles2html/fvwm2rc.head b/dotfiles2html/fvwm2rc.head
new file mode 100644 (file)
index 0000000..6229d05
--- /dev/null
@@ -0,0 +1,8 @@
+<pre>
+<font color="#0000ff">#
+# User configuration file for <a href="http://www.fvwm.org/">Fvwm2</a>
+#
+# Text version <a href="fvwm2rc">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#</font>
diff --git a/dotfiles2html/gvimrc.head b/dotfiles2html/gvimrc.head
new file mode 100644 (file)
index 0000000..e89c7bf
--- /dev/null
@@ -0,0 +1,10 @@
+<pre>
+<font color="#0000ff">&quot;
+&quot; User configuration file for <a href="http://vim.sourceforge.net/">Vi IMproved (GUI version)</a>
+&quot;
+&quot; It is sourced after <a href="vimrc.html">.vimrc</a>
+&quot;
+&quot; Text version <a href="gvimrc">here</a>
+&quot;
+&quot; Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+&quot;</font>
diff --git a/dotfiles2html/init.py.head b/dotfiles2html/init.py.head
new file mode 100644 (file)
index 0000000..7379fa7
--- /dev/null
@@ -0,0 +1,18 @@
+<pre>
+<font color="#0000ff"># 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 <a href="init.py">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#
+</font>
diff --git a/dotfiles2html/init_old.py.head b/dotfiles2html/init_old.py.head
new file mode 100644 (file)
index 0000000..6096e17
--- /dev/null
@@ -0,0 +1,17 @@
+<pre>
+<font color="#0000ff"># 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 <a href="init_old.py">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#
+</font>
diff --git a/dotfiles2html/mailcap.head b/dotfiles2html/mailcap.head
new file mode 100644 (file)
index 0000000..640fab1
--- /dev/null
@@ -0,0 +1,7 @@
+<pre>
+<font color="#0000ff"># MIME types -&gt; viewers map.
+#
+# Text version <a href="mailcap">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#</font>
diff --git a/dotfiles2html/mime.types.head b/dotfiles2html/mime.types.head
new file mode 100644 (file)
index 0000000..585ea25
--- /dev/null
@@ -0,0 +1,8 @@
+<pre>
+<font color="#0000ff"># File extension -&gt; MIME type map.</font>
+<font color="#0000ff"># MIME type                                        Extension</font>
+#
+# Text version <a href="mime.types">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#</font>
diff --git a/dotfiles2html/muttrc.head b/dotfiles2html/muttrc.head
new file mode 100644 (file)
index 0000000..e81b8c8
--- /dev/null
@@ -0,0 +1,8 @@
+<pre>
+<font color="#0000ff">#
+# User configuration file for <a href="http://www.mutt.org/">Mutt</a>
+#
+# Text version <a href="muttrc">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#</font>
diff --git a/dotfiles2html/procmailrc.head b/dotfiles2html/procmailrc.head
new file mode 100644 (file)
index 0000000..e1b96b6
--- /dev/null
@@ -0,0 +1,8 @@
+<pre>
+<font color="#0000ff">#
+# User configuration file for <a href="http://www.procmail.org/">Procmail</a>
+#
+# Text version <a href="procmailrc">here</a>
+#
+# Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+#</font>
diff --git a/dotfiles2html/vimrc.head b/dotfiles2html/vimrc.head
new file mode 100644 (file)
index 0000000..4114047
--- /dev/null
@@ -0,0 +1,10 @@
+<pre>
+<font color="#0000ff">&quot;
+&quot; User configuration file for <a href="http://vim.sourceforge.net/">Vi IMproved</a>
+&quot;
+&quot; Text version <a href="vimrc">here</a>
+&quot;
+&quot; Generated by <a href="gvimrc.html">gvim</a> :runtime syntax/2html.vim
+&quot;
+&quot; A number of scripts mentioned in the file are available <a href="bin/">here</a>.
+&quot;</font>
diff --git a/make+update b/make+update
new file mode 100755 (executable)
index 0000000..52021ed
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+./make-changed && exec ./update-all
diff --git a/make-all b/make-all
new file mode 100755 (executable)
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 (executable)
index 0000000..a6c1b13
--- /dev/null
@@ -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 (executable)
index 0000000..86a251b
--- /dev/null
@@ -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 (executable)
index 0000000..43b9c01
--- /dev/null
@@ -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 (executable)
index 0000000..be9b6ab
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+exec ./make-files ./files/index.tmpl
diff --git a/make-new b/make-new
new file mode 100755 (executable)
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 (file)
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 '<a href="%s">%s</a>' % (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</p>\n<p>\n'.join(parts))
+
+      if self.Title:
+         title = "<h1>%s</h1>\n\n" % self.Title
+      else:
+         title = ''
+
+      body = '\n</p>\n\n<p class="head">\n'.join(new_paras)
+      return "%s<p>%s</p>" % (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 = "<h1>%s</h1>" % title
+
+      subtitle = parts["subtitle"].encode(encoding)
+      if subtitle:
+         subtitle = "<h2>%s</h2>" % subtitle
+
+      body = parts["body"].encode(encoding)
+      parts = [part for part in (title, subtitle, body) if part]
+      return "\n\n".join(parts)
diff --git a/phd_pp_ru.py b/phd_pp_ru.py
new file mode 100644 (file)
index 0000000..d569873
--- /dev/null
@@ -0,0 +1,260 @@
+#!/usr/bin/env python
+# -*- coding: koi8-r -*-
+
+"""
+Autogenerated by CHEETAH: The Python-Powered Template Engine
+ CHEETAH VERSION: 1.0
+ Generation time: Mon Jan  2 23:48:51 2006
+   Source file: phd_pp_ru.tmpl
+   Source file last modified: Mon Jan  2 23:48:44 2006
+"""
+
+__CHEETAH_genTime__ = 'Mon Jan  2 23:48:51 2006'
+__CHEETAH_src__ = 'phd_pp_ru.tmpl'
+__CHEETAH_version__ = '1.0'
+
+##################################################
+## DEPENDENCIES
+
+import sys
+import os
+import os.path
+from os.path import getmtime, exists
+import time
+import types
+import __builtin__
+from Cheetah.Template import Template
+from Cheetah.DummyTransaction import DummyTransaction
+from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
+from Cheetah.CacheRegion import CacheRegion
+import Cheetah.Filters as Filters
+import Cheetah.ErrorCatchers as ErrorCatchers
+from phd_pp import phd_pp
+import time
+
+##################################################
+## MODULE CONSTANTS
+
+try:
+    True, False
+except NameError:
+    True, False = (1==1), (1==0)
+VFFSL=valueFromFrameOrSearchList
+VFSL=valueFromSearchList
+VFN=valueForName
+currentTime=time.time
+
+##################################################
+## CLASSES
+
+class phd_pp_ru(phd_pp):
+    """
+    
+    Autogenerated by CHEETAH: The Python-Powered Template Engine
+    """
+
+    ##################################################
+    ## GENERATED METHODS
+
+
+    def __init__(self, *args, **KWs):
+        """
+        
+        """
+
+        phd_pp.__init__(self, *args, **KWs)
+
+    def respond(self,
+            trans=None,
+            VFFSL=valueFromFrameOrSearchList,
+            VFN=valueForName):
+
+
+        """
+        This is the main method generated by Cheetah
+        """
+
+        if not trans: trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            dummyTrans = True
+        else: dummyTrans = False
+        write = trans.response().write
+        SL = self._searchList
+        globalSetVars = self._globalSetVars
+        filter = self._currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- THIS PAGE IS AUTOMATICALLY GENERATED USING CheetahTemplate. DO NOT EDIT. -->
+<head>
+<meta HTTP-Equiv="Content-Type" content="text/html">
+<meta HTTP-Equiv="Content-Location" content="http://phd.pp.ru''')
+        __v = VFFSL(SL,"path",True)
+        if __v is not None: write(filter(__v, rawExpr='$path')) # from line 21, col 62.
+        write('">\n<meta HTTP-Equiv="Last-Modified" content="')
+        __v = VFFSL(SL,"last_modified_en",True)
+        if __v is not None: write(filter(__v, rawExpr='$last_modified_en')) # from line 22, col 43.
+        write('">\n<title>')
+        __v = VFFSL(SL,"Title",True)
+        if __v is not None: write(filter(__v, rawExpr='$Title')) # from line 23, col 8.
+        write('</title>\n')
+        if VFFSL(SL,"refresh",True):
+            write('<meta HTTP-Equiv="Refresh" content="')
+            __v = VFFSL(SL,"refresh",True)
+            if __v is not None: write(filter(__v, rawExpr='$refresh')) # from line 25, col 37.
+            write('">\n')
+        if VFFSL(SL,"Description",True):
+            write('<meta name="description" content="')
+            __v = VFFSL(SL,"Description",True)
+            if __v is not None: write(filter(__v, rawExpr='$Description')) # from line 28, col 35.
+            write('">\n')
+        if VFFSL(SL,"Keywords",True):
+            write('<meta name="keywords" content="')
+            __v = VFFSL(SL,"Keywords",True)
+            if __v is not None: write(filter(__v, rawExpr='$Keywords')) # from line 31, col 32.
+            write('">\n')
+        if VFFSL(SL,"Copyright",True):
+            full_copyright = VFFSL(SL,"copyright",False)(VFFSL(SL,"Copyright",True))
+            write('<meta name="author" content="Oleg BroytMann">\n<meta name="copyright" content="&copy; ')
+            __v = VFFSL(SL,"full_copyright",True)
+            if __v is not None: write(filter(__v, rawExpr='$full_copyright')) # from line 36, col 40.
+            write(' PhiloSoft Design">\n<link rel="copyright" href="." title="&copy; ')
+            __v = VFFSL(SL,"full_copyright",True)
+            if __v is not None: write(filter(__v, rawExpr='$full_copyright')) # from line 37, col 46.
+            write(' PhiloSoft Design">\n')
+        write('<meta name="generator" content="CheetahTemplate">\n<link rev="made" href="mailto:phd@phd.pp.ru">\n')
+        if VFFSL(SL,"root",True):
+            write('<link rel="top" href="')
+            __v = VFFSL(SL,"root",True)
+            if __v is not None: write(filter(__v, rawExpr='$root')) # from line 42, col 23.
+            write('">\n<link rel="up" href="../">\n')
+        if VFFSL(SL,"Prev",True):
+            write('<link rel="prev" href="')
+            __v = VFFSL(SL,"Prev",True)
+            if __v is not None: write(filter(__v, rawExpr='$Prev')) # from line 46, col 24.
+            write('">\n')
+        if VFFSL(SL,"Next",True):
+            write('<link rel="next" href="')
+            __v = VFFSL(SL,"Next",True)
+            if __v is not None: write(filter(__v, rawExpr='$Next')) # from line 49, col 24.
+            write('">\n')
+        write('<link rel="stylesheet" type="text/css" media="screen" href="')
+        __v = VFFSL(SL,"root",True)
+        if __v is not None: write(filter(__v, rawExpr='${root}')) # from line 51, col 61.
+        write('phd.css">\n')
+        if VFFSL(SL,"styles",True):
+            for media, style in VFFSL(SL,"styles",True):
+                write('<STYLE type="text/css" media="')
+                __v = VFFSL(SL,"media",True)
+                if __v is not None: write(filter(__v, rawExpr='$media')) # from line 54, col 31.
+                write('">\n<!--\n')
+                __v = VFFSL(SL,"style",True)
+                if __v is not None: write(filter(__v, rawExpr='$style')) # from line 56, col 1.
+                write('\n--></STYLE>\n')
+        write('''<meta name="MSSmartTagsPreventParsing" content="TRUE"> <!-- MUST DIE -->
+</head>
+<body bgcolor="#CCCCCC" text="#000000"
+      link="#0000bb"  vlink="#551a8b" alink="#ff0000">
+''')
+        __v = VFFSL(SL,"body",True)
+        if __v is not None: write(filter(__v, rawExpr='$body')) # from line 64, col 1.
+        write('\n')
+        if VFN(VFFSL(SL,"path",True),"endswith",False)("index.html"):
+            path = VFFSL(SL,"path",True)[:-len("index.html")]
+        write('<hr width="90%">\n')
+        if VFN(VFFSL(SL,"path",True),"startswith",False)("/Russian/"):
+            write('<p class="head" style="font-size: 60%">\xfc\xd4\xc1 \xd3\xd4\xd2\xc1\xce\xc9\xc3\xc1 <a href="http://phd.pp.ru')
+            __v = VFFSL(SL,"path",True)
+            if __v is not None: write(filter(__v, rawExpr='$path')) # from line 70, col 78.
+            write('">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('</a>\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 <a href="')
+            __v = VFFSL(SL,"_fileBaseName",True)
+            if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 71, col 74.
+            write('">')
+            __v = VFFSL(SL,"_fileBaseName",True)
+            if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 71, col 90.
+            write('</a>;\n\xf7\xd9 \xcd\xcf\xd6\xc5\xd4\xc5 \xd5\xda\xce\xc1\xd4\xd8 <a href="')
+            __v = VFFSL(SL,"root",True)
+            if __v is not None: write(filter(__v, rawExpr='${root}')) # from line 72, col 27.
+            write('about/">\xcf</a> <a href="')
+            __v = VFFSL(SL,"root",True)
+            if __v is not None: write(filter(__v, rawExpr='${root}')) # from line 72, col 57.
+            write('about/technical.html">\xd4\xc5\xc8\xce\xc9\xde\xc5\xd3\xcb\xc9\xc8</a> \xc1\xd3\xd0\xc5\xcb\xd4\xc1\xc8 \xdc\xd4\xcf\xc7\xcf \xd3\xc1\xca\xd4\xc1.\n</p>\n')
+        else:
+            write('<p class="head" style="font-size: 60%">This is the page <a href="http://phd.pp.ru')
+            __v = VFFSL(SL,"path",True)
+            if __v is not None: write(filter(__v, rawExpr='$path')) # from line 75, col 82.
+            write('">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('</a>.\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 <a href="')
+            __v = VFFSL(SL,"_fileBaseName",True)
+            if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 76, col 69.
+            write('">')
+            __v = VFFSL(SL,"_fileBaseName",True)
+            if __v is not None: write(filter(__v, rawExpr='$_fileBaseName')) # from line 76, col 85.
+            write('</a>;\nread more <a href="')
+            __v = VFFSL(SL,"root",True)
+            if __v is not None: write(filter(__v, rawExpr='${root}')) # from line 77, col 20.
+            write('about/">about</a> <a href="')
+            __v = VFFSL(SL,"root",True)
+            if __v is not None: write(filter(__v, rawExpr='${root}')) # from line 77, col 54.
+            write('about/technical.html">technical</a> aspects of the site.\n</p>\n')
+        write('</body>\n</html>')
+        
+        ########################################
+        ## 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 (file)
index 0000000..a488704
--- /dev/null
@@ -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
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- THIS PAGE IS AUTOMATICALLY GENERATED USING CheetahTemplate. DO NOT EDIT. -->
+<head>
+<meta HTTP-Equiv="Content-Type" content="text/html">
+<meta HTTP-Equiv="Content-Location" content="http://phd.pp.ru$path">
+<meta HTTP-Equiv="Last-Modified" content="$last_modified_en">
+<title>$Title</title>
+#if $refresh:
+<meta HTTP-Equiv="Refresh" content="$refresh">
+#end if
+#if $Description
+<meta name="description" content="$Description">
+#end if
+#if $Keywords
+<meta name="keywords" content="$Keywords">
+#end if
+#if $Copyright
+#set $full_copyright = $copyright($Copyright)
+<meta name="author" content="Oleg BroytMann">
+<meta name="copyright" content="&copy; $full_copyright PhiloSoft Design">
+<link rel="copyright" href="." title="&copy; $full_copyright PhiloSoft Design">
+#end if
+<meta name="generator" content="CheetahTemplate">
+<link rev="made" href="mailto:phd@phd.pp.ru">
+#if $root
+<link rel="top" href="$root">
+<link rel="up" href="../">
+#end if
+#if $Prev
+<link rel="prev" href="$Prev">
+#end if
+#if $Next
+<link rel="next" href="$Next">
+#end if
+<link rel="stylesheet" type="text/css" media="screen" href="${root}phd.css">
+#if $styles
+#for $media, $style in $styles
+<STYLE type="text/css" media="$media">
+<!--
+$style
+--></STYLE>
+#end for
+#end if
+<meta name="MSSmartTagsPreventParsing" content="TRUE"> <!-- MUST DIE -->
+</head>
+<body bgcolor="#CCCCCC" text="#000000"
+      link="#0000bb"  vlink="#551a8b" alink="#ff0000">
+$body
+#if $path.endswith("index.html")
+#set $path = $path[:-len("index.html")]
+#end if
+<hr width="90%">
+#if $path.startswith("/Russian/")
+<p class="head" style="font-size: 60%">Эта страница <a href="http://phd.pp.ru$path">http://phd.pp.ru$path</a>
+была сгенерирована $last_modified_ru из шаблона CheetahTemplate <a href="$_fileBaseName">$_fileBaseName</a>;
+Вы можете узнать <a href="${root}about/">о</a> <a href="${root}about/technical.html">технических</a> аспектах этого сайта.
+</p>
+#else
+<p class="head" style="font-size: 60%">This is the page <a href="http://phd.pp.ru$path">http://phd.pp.ru$path</a>.
+It was generated on $last_modified_en from CheetahTemplate <a href="$_fileBaseName">$_fileBaseName</a>;
+read more <a href="${root}about/">about</a> <a href="${root}about/technical.html">technical</a> aspects of the site.
+</p>
+#end if
+</body>
+</html>#slurp
diff --git a/reindex_blog.py b/reindex_blog.py
new file mode 100755 (executable)
index 0000000..be27835
--- /dev/null
@@ -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
+<H1>Журнал</H1>
+""" % {"cyear": year or 2005})
+
+   elif show_month:
+
+      index_tmpl.write("""\
+#extends phd_pp_ru
+#implements respond
+#attr $Title = "Oleg BroytMann's blog: %(year)s"
+#attr $Description = "BroytMann Russian Blog %(year)s Index Document"
+#attr $Copyright = %(cyear)s
+##
+#def body_html
+<H1>Журнал: %(year)s</H1>
+""" % {"year": year, "cyear": year or 2005})
+
+   else:
+
+      month = int(month)
+      index_tmpl.write("""\
+#extends phd_pp_ru
+#implements respond
+#attr $Title = "Oleg BroytMann's blog: %(month_abbr_en)s %(year)s"
+#attr $Description = "BroytMann Russian Blog %(month_name_en)s %(year)s Index Document"
+#attr $Copyright = %(cyear)s
+##
+#def body_html
+<H1>Журнал: %(month_name_ru0)s %(year)s</H1>
+""" % {
+      "year": year, "cyear": year or 2005,
+      "month_abbr_en": months_abbrs_en[month], "month_name_en": months_names_en[month],
+      "month_name_ru0": months_names_ru0[month],
+   })
+
+   save_titles = titles[:]
+   titles.reverse()
+   if cut:
+      titles = titles[:cut]
+
+   save_day = None
+   for key, tmpl, title, lead in titles:
+      year, month, day = key
+      href = []
+      if show_year:
+         href.append(year)
+      if show_month:
+         href.append(month)
+      href.append(day)
+      href.append(tmpl)
+      href = '/'.join(href)
+      if day[0] == '0': day = day[1:]
+      if save_day <> day:
+         if show_year:
+            index_tmpl.write('\n<h2>%s %s %s</h2>' % (day, months_names_ru[int(month)], year))
+         else:
+            index_tmpl.write('\n<h2>%s %s</h2>' % (day, months_names_ru[int(month)]))
+         save_day = day
+      if lead:
+         lead = lead + ' '
+      else:
+         lead = ''
+      index_tmpl.write('''
+<p class="head">
+   %s<a href="%s">%s</a>.
+</p>
+''' % (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('''
+<hr>
+
+<p class="years">
+''')
+      for year in sorted(years.keys()):
+         if first_year:
+            first_year = False
+         else:
+            index_tmpl.write(' - ')
+         index_tmpl.write('<a href="%s/">%s</a>' % (year, year))
+      index_tmpl.write('''
+</p>
+''')
+
+   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 (executable)
index 0000000..ced4032
--- /dev/null
@@ -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 (executable)
index 0000000..69ea955
--- /dev/null
@@ -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 (executable)
index 0000000..4423f10
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+cd ../htdocs && exec distribute -d phd.pp.ru