[Python-checkins] r50799 - sandbox/trunk/seealso/convert-python-faqs.py

andrew.kuchling python-checkins at python.org
Mon Jul 24 15:23:43 CEST 2006


Author: andrew.kuchling
Date: Mon Jul 24 15:23:42 2006
New Revision: 50799

Modified:
   sandbox/trunk/seealso/convert-python-faqs.py
Log:
Include breadcrumbs; write nav.yml files

Modified: sandbox/trunk/seealso/convert-python-faqs.py
==============================================================================
--- sandbox/trunk/seealso/convert-python-faqs.py	(original)
+++ sandbox/trunk/seealso/convert-python-faqs.py	Mon Jul 24 15:23:42 2006
@@ -44,6 +44,21 @@
     else:
         return default
 
+def write_nav (dir, urls):
+    f = open(os.path.join(dir, 'nav.yml'), 'w')
+    f.write("""--- !fragment
+# Type of template to use
+template: nav.html
+
+# Contents of the template
+global: 
+  nav : !sectionnav |
+""")
+    for dirname, title in urls:
+        title = yaml_escape(title)
+        f.write(' '*6 + title + ' ' + dirname + '\n')
+    f.close()
+
 def convert_question (filename):
     base = os.path.basename(filename).replace('.xml', '')
     # root is the 'html' element
@@ -100,7 +115,8 @@
 # The data to pass to the template
 local:
   content:
-    text: !htfile question.ht""")
+    breadcrumb: !breadcrumb nav.yml nav
+    text: !htfile question.ht\n""")
     f.close()
 
     
@@ -118,13 +134,18 @@
     # Write body of question
     f = open(os.path.join(idir, 'listing.ht'), 'w')
     f.write('<ul>\n')
+    urllist = []
     for a in entries:
         href = a.get("href")
         a.set("href", href.lstrip('/'))
         f.write('<li>%s</li>\n' % ET.tostring(a, 'utf-8'))
+        urllist.append((href, a.text))
+
     f.write('</ul>\n')
     f.close()
-	
+
+    write_nav(idir, urllist)	
+
     # Write .yml files
     f = open(os.path.join(idir, 'index.yml'), 'w')
     f.write("""--- !fragment
@@ -181,20 +202,15 @@
     f.write('</ul>\n')
     f.close()
 
-    f = open(os.path.join(DESTDIR, 'nav.yml'), 'w')
-    f.write("""--- !fragment
-# Type of template to use
-template: nav.html
-
-# Contents of the template
-global: 
-  nav : !sectionnav |
-      xxx index.html
-""")
-    f.close()
+    # Write navigation info
+    urllist = []
+    for cat in sorted(categories.keys()):
+        urllist.append((cat, cat.capitalize()))
+    write_nav(DESTDIR, urllist)
 
     f = open(os.path.join(DESTDIR, 'content.html'), 'w')
     f.write("""<n:invisible n:data="content" n:render="mapping">
+<div id="breadcrumb" n:data="breadcrumb" n:render="breadcrumb" />
 <n:slot name="text"></n:slot>
 </n:invisible>""")
     f.close()


More information about the Python-checkins mailing list