Add favicon support
authorBernie Innocenti <bernie@codewiz.org>
Fri, 8 Aug 2008 06:33:43 +0000 (12:18 +0545)
committerBernie Innocenti <bernie@codewiz.org>
Fri, 8 Aug 2008 06:33:43 +0000 (12:18 +0545)
geekigeeki.conf.py
geekigeeki.py

index eba3843c29478cc35545811f30576254235eb500..1080e49c9cc02c2cb6ceb6e859729a5c1f6d8dd5 100644 (file)
@@ -7,14 +7,27 @@ privileged_url = 'https://www.develer.com/~bernie/wiki'
 
 data_dir = '/home/bernie/public_html/wiki/data'
 
-css_url = ['../wikidata/geekigeeki.css']  # optional stylesheet links
+# default page links
+icon_url = 'hacker-favicon.ico'
+css_url = ['../wikidata/geekigeeki.css']
+
 history_url = '../wikigit/wiki.git'
 
 post_edit_hook = './post_edit_hook.sh'
 
 datetime_fmt = '%a %d %b %Y %I:%M %p'
-allow_edit = True                       # Is it possible to edit pages?
-show_hosts = True                       # show hostnames?
-nonexist_pfx = ''                       # prefix before nonexistent link (usually '?')
-image_maxwidth = 800                    # maximum image width in pixels
-debug_cgi = False                       # Set to True for CGI var dump
+
+# Is it possible to edit pages?
+allow_edit = True
+
+# show hostnames?
+show_hosts = True
+
+# prefix before nonexistent link (usually '?')
+nonexist_pfx = ''
+
+# maximum image width in pixels
+image_maxwidth = 800
+
+# Set to True for CGI var dump
+debug_cgi = False
index d7e1a5a9e0d28a466e8f40b5704df5d4ea77148f..44be2a46bcc3163307d0f65d62b7421b73c130f8 100755 (executable)
@@ -31,7 +31,7 @@ from os import path, environ
 word_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
 # FIXME: we accept stuff like foo/../bar and we shouldn't
 file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$")
-img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg)$", re.IGNORECASE)
+img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg|bmp|ico)$", re.IGNORECASE)
 url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$")
 link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})")
 
@@ -127,6 +127,17 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error'):
         print ' <meta name="robots" content="noindex,nofollow" />'
     for css in css_url:
         print ' <link rel="stylesheet" type="text/css" href="%s" />' % relative_url(css)
+    if icon_url:
+        print ' <link rel="icon" href="%s" />' % relative_url(icon_url)
+
+    if privileged_url is not None:
+        print ' <link rel="alternate" type="application/x-wiki" title="Edit this page" href="%s" \>' \
+            % (privileged_path() + '?edit=' + name)
+
+    if history_url is not None:
+        print ' <link rel="alternate" type="application/rss+xml" title="RSS" href="%s" />' \
+            % (history_url + '?a=rss')
+
     print '</head>'
 
     # Body
@@ -484,16 +495,16 @@ class WikiFormatter:
             + r"|(?P<html><(/|)(br|hr|div|form|iframe|input|span))"
             + r"|(?P<ent>[<>&])"
 
-            # Auto links
-            + r"|(?P<img>\b[a-zA-Z0-9_/-]+\.(png|gif|jpg|jpeg|bmp))" # LEGACY
-            + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)" # LEGACY
-            + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)" # LEGACY
-            + r"|(?P<email>[-\w._+]+\@[\w.-]+)" # LEGACY
+            # Auto links (LEGACY)
+            + r"|(?P<img>\b[a-zA-Z0-9_/-]+\.(png|gif|jpg|jpeg|bmp|ico))"
+            + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)"
+            + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)"
+            + r"|(?P<email>[-\w._+]+\@[\w.-]+)"
 
             # Lists, divs, spans
             + r"|(?P<li>^\s+[\*#] +)"
             + r"|(?P<pre>\{\{\{|\s*\}\}\})"
-            + r"|(?P<inl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})" #TODO
+            + r"|(?P<inl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})"
 
             # Tables
             + r"|(?P<tr>^\s*\|\|(=|)\s*)"