Commits

Anonymous committed f390b43

Logo and style

  • Participants
  • Parent commits 0f8fb5e

Comments (0)

Files changed (2)

 [DEFAULT]
 site_name = Sample wiki
 style_url = http://sheep.art.pl/misc/w.css
-
+logo_url = http://sheep.art.pl/misc/logo.png
 [hello]
 
 [hgstore]
         "base_url": None,
         "start_page": "FrontPage",
         "changes_page": "RecentChanges",
-        "style_url": "",
+        "style_url": None,
+        "logo_url": None,
     }
     class Section(object):
         def __init__(self, parser, section):
             start("404 Not found", wiki.default_headers)
             yield wiki.html_head(_(u'Creating "%s"...') % title)
             yield u"""<div class="message warning create">"""
-            yield _(u"<p>This page doesn't exist yet. It will be created when you save.</p>")
+            yield _(u"<p><b>Page not found!</b> This page doesn't exist yet. It will be created when you save.</p>")
             yield u"""</div>"""
         save_url = wiki.page_url(title, action="save")
         yield u"""<div class="content edit">"""
             yield cgi.escape(line)
         yield u"""</textarea><br>"""
         yield (u"""<label class="author">%s """
-              u"""<input name="author"></label>""" % u"name")
+              u"""<input name="author"></label>""" % _(u"Your name: "))
         yield (u"""<input class="save button" """
               u"""type="submit" value="%s">""" % "Save")
         yield u"""</p></form>"""
         yield u"""</div></body></html>"""
 
     def empty_action(wiki, env, start, form, title):
+        start("303 Redirect", 
+            [('Location', wiki.page_url(title, action="edit")),])
+        return
         start("404 Not found", wiki.default_headers)
+        create_link = u'<a href="%s" class="edit">%s</a>' % (
+            wiki.page_url(title, action="edit"), _(u"create"))
         yield wiki.html_head(title)
-        yield u"""<div class="message warning empty">%s""" % _(u"Page not found!")
-        yield u"""<a href="%s" class="edit">%s</a>""" % (
-            wiki.page_url(title, action="edit"), _(u"You can create it."))
+        yield u"""<div class="message warning empty">""" 
+        yield _(u"<p><b>Not found!</b> This page doesn't exist yet, ")
+        yield _("but you can %s it now.</p>") % create_link
         yield u"""</div></body></html>"""
 
 class Wiki(object):
 
     def html_head(self, title):
         html_title = cgi.escape(title)
+        logo_url = self.config["logo_url"]
+        if logo_url:
+            start_page = self.config["start_page"]
+            start_url = self.page_url(start_page)
+            logo = u'<a href="%s"><img src="%s" alt="[%s]"></a>' % (
+                start_url, self.config["logo_url"], 
+                cgi.escape(start_page, quote=True))
+        else:
+            logo = u''
         return u"\n".join([
                 u'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"''',
                 u'''http://www.w3.org/TR/html4/strict.dtd">''',
                 u'''<html><head><title>%s - %s</title>''' % (html_title, 
                     self.config["site_name"])
             ]+self.http_head+[
-                u'''</head><body><h1>%s</h1>''' % html_title
+                u'''</head><body><h1>%s%s</h1>''' % (logo, html_title)
             ])
 
     def html_footer(self, title):