changeset 1123:457c23af92bd

Use a template for the error message.
author Ollivier Robert <roberto@keltia.freenix.fr>
date Sat, 27 Aug 2005 23:44:15 -0700
parents fb008a1a0a32
children 725204f67d92
files mercurial/hgweb.py templates/map
diffstat 2 files changed, 19 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb.py	Sat Aug 27 23:44:02 2005 -0700
+++ b/mercurial/hgweb.py	Sat Aug 27 23:44:15 2005 -0700
@@ -69,10 +69,6 @@
         sys.stdout.write('Content-length: %d\n' % size)
     sys.stdout.write('\n')
 
-def httpnotfound(filename):
-    sys.stdout.write("Status: 404\r\n\r\n")
-    sys.stdout.write("File not found: (%s)" % (filename, ))
-
 def write(*things):
     for thing in things:
         if hasattr(thing, "__iter__"):
@@ -937,23 +933,6 @@
         self.cp.read(config)
 
     def run(self):
-        try:
-            virtual = os.environ["PATH_INFO"]
-        except:
-            virtual = ""
-
-        virtual = virtual.strip('/')
-
-        if len(virtual):
-            if self.cp.has_option("paths", virtual):
-                real = self.cp.get("paths", virtual)
-                h = hgweb(real)
-                h.run()
-                return
-            else:
-                httpnotfound(virtual)
-                return
-
         def header(**map):
             yield tmpl("header", **map)
 
@@ -992,4 +971,21 @@
 
                 parity = 1 - parity
 
+        try:
+            virtual = os.environ["PATH_INFO"]
+        except:
+            virtual = ""
+
+        virtual = virtual.strip('/')
+
+        if len(virtual):
+            if self.cp.has_option("paths", virtual):
+                real = self.cp.get("paths", virtual)
+                h = hgweb(real)
+                h.run()
+                return
+            else:
+                write(tmpl("notfound", repo = virtual))
+                return
+
         write(tmpl("index", entries=entries))
--- a/templates/map	Sat Aug 27 23:44:02 2005 -0700
+++ b/templates/map	Sat Aug 27 23:44:15 2005 -0700
@@ -37,4 +37,5 @@
 filelogparent = "<tr><td align="right">parent #rev#:&nbsp;</td><td><a href="?cmd=file;file=#file#;filenode=#node#">#node|short#</a></td></tr>"
 indexentry = "<tr class="parity#parity#"><td><a  href="#url#">#name#</a></td><td>#shortdesc#</td><td>#author# <i>#email|obfuscate#</i></td><td>#lastupdate|age# ago</td></tr>"
 index = index.tmpl
-archiveentry = "<a href="?cmd=archive;node=#node#;type=#type#">#type#</a> "
\ No newline at end of file
+archiveentry = "<a href="?cmd=archive;node=#node#;type=#type#">#type#</a> "
+notfound = notfound.tmpl