hgweb: provide means for handling query parameters
authorBrendan Cully <brendan@kublai.com>
Thu, 05 Oct 2006 14:27:14 -0700
changeset 3270 a7370503d800
parent 3269 6901d3545021
child 3271 36fa5db79dd5
hgweb: provide means for handling query parameters
mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Oct 05 20:03:38 2006 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Oct 05 14:27:14 2006 -0700
@@ -11,6 +11,7 @@
 import mimetypes
 from mercurial.demandload import demandload
 demandload(globals(), "re zlib ConfigParser mimetools cStringIO sys tempfile")
+demandload(globals(), 'urllib')
 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,streamclone,patch")
 demandload(globals(), "mercurial:templater")
 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile")
@@ -717,6 +718,23 @@
                         req.form['node'] = [fn[:-len(ext)]]
                         req.form['type'] = [type_]
 
+        def queryprefix(**map):
+            return req.url[-1] == '?' and ';' or '?'
+
+        def getentries(**map):
+            fields = {}
+            if req.form.has_key('style'):
+                style = req.form['style'][0]
+                if style != self.repo.ui.config('web', 'style', ''):
+                    fields['style'] = style
+
+            if fields:
+                fields = ['%s=%s' % (k, urllib.quote(v))
+                          for k, v in fields.iteritems()]
+                yield '%s%s' % (queryprefix(), ';'.join(fields))
+            else:
+                yield ''
+
         self.refresh()
 
         expand_form(req.form)
@@ -751,6 +769,8 @@
                                                "header": header,
                                                "footer": footer,
                                                "rawfileheader": rawfileheader,
+                                               "queryprefix": queryprefix,
+                                               "getentries": getentries
                                                })
 
         if not req.form.has_key('cmd'):