Add #navbar and #footer pragmas
authorBernie Innocenti <bernie@codewiz.org>
Mon, 22 Mar 2010 21:11:09 +0000 (18:11 -0300)
committerBernie Innocenti <bernie@codewiz.org>
Mon, 22 Mar 2010 21:11:09 +0000 (18:11 -0300)
geekigeeki.py

index a5ba6a2d388565ae9ac3f5dff29ca48f8126fb50..b00838ae923d45ac5320579096b7d6f1cebb1b8d 100755 (executable)
@@ -123,7 +123,7 @@ def send_guru(msg_text, msg_type):
     print('</pre><script type="text/javascript" src="%s" defer="defer"></script>' \
         % relative_url('sys/GuruMeditation.js'))
 
-def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False, mtime=None):
+def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False, mtime=None, navbar="on"):
     global title_done
     if title_done: return
 
@@ -163,6 +163,9 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal
     title_done = True
     send_guru(msg_text, msg_type)
 
+    if navbar != "on":
+        return
+
     # NAVBAR
     print('<nav><div class="nav">')
     print link_tag('FrontPage', config_get('site_icon', 'Home'), cssclass='navlink')
@@ -304,7 +307,7 @@ def handle_edit(pagename, form):
         send_httperror("403 Forbidden", pagename)
         return
 
-    pg = Page(form['q'].value)
+    pg  = Page(form['q'].value)
     if 'save' in form:
         if form['file'].value:
             pg.save(form['file'].file.read(), form['changelog'].value)
@@ -344,14 +347,15 @@ def page_list(dirname=None, search_re=None):
         search_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
     return sorted(filter(search_re.match, os.listdir(dirname or '.')))
 
-def send_footer(mtime=None):
+def send_footer(mtime=None, footer="sys/footer"):
     if config_get('debug_cgi', False):
         cgi.print_arguments()
         cgi.print_form(form)
         cgi.print_environ()
-    link_inline("sys/footer", kvargs = {
-        'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
-    })
+    if footer != "off":
+        link_inline(footer, kvargs = {
+            'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
+        })
     print("</body></html>")
 
 def _macro_ELAPSED_TIME(*args, **kvargs):
@@ -734,9 +738,10 @@ class Page:
             link_urls += [ [ "stylesheet", value ] ]
 
         send_title(self.page_name, self.split_title(),
-            msg_text=self.msg_text, msg_type=self.msg_type, writable=self.can_write(), mtime=self._mtime())
+            msg_text=self.msg_text, msg_type=self.msg_type, writable=self.can_write(), mtime=self._mtime(),
+            navbar=self.pragma("navbar", "on"))
         self.send_naked()
-        send_footer(mtime=self._mtime())
+        send_footer(mtime=self._mtime(), footer=self.pragma("footer", "sys/footer"))
 
     def send_editor(self, preview=None):
         send_title(None, 'Edit ' + self.split_title(), msg_text=self.msg_text, msg_type=self.msg_type)