]> git.phdru.name Git - phdru.name/phdru.name.git/blobdiff - reindex_blog.py
Added Lead.
[phdru.name/phdru.name.git] / reindex_blog.py
index 0ba0804d4c1d458628744a4c9d8ba5f6c2781744..fd82c1839111ae59ddcd7a7e86eace33d7b9a715 100755 (executable)
@@ -39,6 +39,11 @@ else:
 blog = {}
 years = {}
 
+# excerpts nd bodies are dictionaries mapping file => excerpt/body
+
+excerpts = {}
+bodies = {}
+
 # Walk the directory recursively
 for dirpath, dirs, files in os.walk(blog_root):
    d = os.path.basename(dirpath)
@@ -77,6 +82,10 @@ for dirpath, dirs, files in os.walk(blog_root):
 
          if day not in days: days.append(day)
 
+         file = file[:-len("tmpl")] + "html"
+         key = (year, month, day, file)
+         excerpts[key] = template.get_first_p()
+         bodies[key] = template.Body
 
 # Need to save the blog?
 if blog <> old_blog:
@@ -130,8 +139,12 @@ def write_template(level, year, month, day, titles, tags=None):
 #attr $Title = "Oleg Broytman's blog"
 #attr $Description = "Broytman Russian Blog Index Document"
 #attr $Copyright = %(cyear)s
-#attr $alternates = (("News [Atom 1.0]", "application/atom+xml", "atom_10.xml"),
-                     ("News [RSS 2.0]",  "application/rss+xml",  "rss_20.xml")
+#attr $alternates = (("Новости [Atom 1.0] только заголовки", "application/atom+xml", "atom_10_titles.xml"),
+                     ("Новости [Atom 1.0]", "application/atom+xml", "atom_10.xml"),
+                     ("Новости [Atom 1.0] полные тексты", "application/atom+xml", "atom_10_full.xml"),
+                     ("Новости [RSS 2.0] только заголовки",  "application/rss+xml",  "rss_20_titles.xml"),
+                     ("Новости [RSS 2.0]",  "application/rss+xml",  "rss_20.xml"),
+                     ("Новости [RSS 2.0] полные тексты",  "application/rss+xml",  "rss_20_full.xml"),
 )
 ##
 #def body_html
@@ -222,8 +235,14 @@ def write_template(level, year, month, day, titles, tags=None):
 <hr>
 
 <p class="head">Новостевая лента в форматах
-<A HREF="atom_10.xml">Atom 1.0 <img src="../../Graphics/atom_10.jpg" border=0></A>
-и <A HREF="rss_20.xml">RSS 2.0 <img src="../../Graphics/rss_20.jpg" border=0></A>.
+<img src="../../Graphics/atom_10.jpg" border=0>
+<A HREF="atom_10_titles.xml">Atom 1.0 только заголовки</A> /
+<A HREF="atom_10.xml">Atom 1.0</A> /
+<A HREF="atom_10_full.xml">Atom 1.0 полные тексты</A>
+и <img src="../../Graphics/rss_20.jpg" border=0>
+<A HREF="rss_20_titles.xml">RSS 2.0 только заголовки</A> /
+<A HREF="rss_20.xml">RSS 2.0</A> /
+<A HREF="rss_20_full.xml">RSS 2.0 полные тексты</A>.
 </p>
 """)
 
@@ -442,6 +461,8 @@ for item in tuple(reversed(all_titles_tags))[:10]:
    items.append(item)
    item.baseURL = baseURL
    item.categoryList = tags
+   item.excerpt = excerpts[(year, month, day, file)]
+   item.body = bodies[(year, month, day, file)]
 
 namespace = {
    "title": "Oleg Broytman's blog",
@@ -462,3 +483,19 @@ 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)
+
+for item in items:
+    item.excerpt = None
+
+atom_tmpl = str(atom_10(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "atom_10_titles.xml"), atom_tmpl)
+rss_tmpl = str(rss_20(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "rss_20_titles.xml"), rss_tmpl)
+
+for item in items:
+    item.content = item.body
+
+atom_tmpl = str(atom_10(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "atom_10_full.xml"), atom_tmpl)
+rss_tmpl = str(rss_20(searchList=[namespace]))
+write_if_changed(os.path.join(blog_root, "rss_20_full.xml"), rss_tmpl)