X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=reindex_blog.py;h=fd82c1839111ae59ddcd7a7e86eace33d7b9a715;hb=c6eb1e00be821ab12e0edaa622e75eff1ec8abd2;hp=0ba0804d4c1d458628744a4c9d8ba5f6c2781744;hpb=251dd1739e176805010998623456b6672283159e;p=phdru.name%2Fphdru.name.git diff --git a/reindex_blog.py b/reindex_blog.py index 0ba0804..fd82c18 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -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):

îÏ×ÏÓÔÅ×ÁÑ ÌÅÎÔÁ × ÆÏÒÍÁÔÁÈ -Atom 1.0 RSS 2.0 . + +Atom 1.0 ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ / +Atom 1.0 / +Atom 1.0 ÐÏÌÎÙÅ ÔÅËÓÔÙ +RSS 2.0 ÔÏÌØËÏ ÚÁÇÏÌÏ×ËÉ / +RSS 2.0 / +RSS 2.0 ÐÏÌÎÙÅ ÔÅËÓÔÙ.

""") @@ -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)