hgweb: Keep session variables (currently only style) in HTML forms, too.
authorThomas Arendsen Hein <thomas@intevation.de>
Wed, 11 Oct 2006 20:59:37 +0200
changeset 3362 887da2247b57
parent 3361 bc5985d53386
child 3363 ce8f31e0b3b8
hgweb: Keep session variables (currently only style) in HTML forms, too. Adjusted default and gitweb template for this.
mercurial/hgweb/hgweb_mod.py
templates/changelog.tmpl
templates/gitweb/changelog.tmpl
templates/gitweb/map
templates/gitweb/search.tmpl
templates/gitweb/shortlog.tmpl
templates/map
templates/search.tmpl
templates/shortlog.tmpl
--- a/mercurial/hgweb/hgweb_mod.py	Wed Oct 11 20:53:02 2006 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Oct 11 20:59:37 2006 +0200
@@ -708,6 +708,16 @@
                         req.form['node'] = [fn[:-len(ext)]]
                         req.form['type'] = [type_]
 
+        def sessionvars(**map):
+            fields = []
+            if req.form.has_key('style'):
+                style = req.form['style'][0]
+                if style != self.repo.ui.config('web', 'style', ''):
+                    fields.append(('style', style))
+
+            for name, value in fields:
+                yield dict(name=name, value=value)
+
         def queryprefix(**map):
             return req.url[-1] == '?' and ';' or '?'
 
@@ -754,6 +764,7 @@
                                                "header": header,
                                                "footer": footer,
                                                "rawfileheader": rawfileheader,
+                                               "sessionvars": sessionvars,
                                                "queryprefix": queryprefix,
                                                "getentries": getentries
                                                })
--- a/templates/changelog.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/changelog.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -16,6 +16,7 @@
 <h2>changelog for #repo|escape#</h2>
 
 <form action="#url#log">
+{sessionvars%hiddenformentry}
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
@@ -26,6 +27,7 @@
 #entries%changelogentry#
 
 <form action="#url#log">
+{sessionvars%hiddenformentry}
 <p>
 <label for="search2">search:</label>
 <input name="rev" id="search2" type="text" size="30">
--- a/templates/gitweb/changelog.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/gitweb/changelog.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -10,8 +10,8 @@
 </div>
 
 <form action="{url}log">
+{sessionvars%hiddenformentry}
 <div class="search">
-<input type="hidden" name="style" value="gitweb"  />
 <input type="text" name="rev"  />
 </div>
 </form>
--- a/templates/gitweb/map	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/gitweb/map	Wed Oct 11 20:59:37 2006 +0200
@@ -51,3 +51,4 @@
 archiveentry = ' | <a href="{url}archive/{node|short}{extension}">#type|escape#</a> '
 indexentry = '<tr class="parity#parity#"><td><a class="list" href="#url#"><b>#name|escape#</b></a></td><td>#description#</td><td>#contact|obfuscate#</td><td class="age">#lastchange|age# ago</td><td class="indexlinks"><a class="rss_logo" href="#url#rss-log">RSS</a> #archives%archiveentry#</td></tr>' 
 index = index.tmpl
+hiddenformentry = '<input type="hidden" name="#name#" value="#value|escape#" />'
--- a/templates/gitweb/search.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/gitweb/search.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -10,14 +10,15 @@
 <h2>searching for #query|escape#</h2>
 
 <form action="{url}log">
+{sessionvars%hiddenformentry}
 search:
-<input type="hidden" name="style" value="gitweb">
 <input name="rev" type="text" width="30" value="#query|escape#">
 </form>
 
 #entries#
 
 <form action="{url}log">
+{sessionvars%hiddenformentry}
 search:
 <input type="hidden" name="style" value="gitweb">
 <input name="rev" type="text" width="30">
--- a/templates/gitweb/shortlog.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/gitweb/shortlog.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -10,8 +10,8 @@
 </div>
 
 <form action="{url}log">
+{sessionvars%hiddenformentry}
 <div class="search">
-<input type="hidden" name="style" value="gitweb"  />
 <input type="text" name="rev"  />
 </div>
 </form>
--- a/templates/map	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/map	Wed Oct 11 20:59:37 2006 +0200
@@ -51,3 +51,4 @@
 archiveentry = '<a href="#url#archive/#node|short##extension|urlescape#">#type|escape#</a> '
 notfound = notfound.tmpl
 error = error.tmpl
+hiddenformentry = '<input type="hidden" name="#name#" value="#value|escape#" />'
--- a/templates/search.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/search.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -13,6 +13,7 @@
 <h2>searching for #query|escape#</h2>
 
 <form>
+{sessionvars%hiddenformentry}
 <p>
 search:
 <input name="rev" type="text" width="30" value="#query|escape#">
@@ -22,6 +23,7 @@
 #entries#
 
 <form>
+{sessionvars%hiddenformentry}
 <p>
 search:
 <input name="rev" type="text" width="30" value="#query|escape#">
--- a/templates/shortlog.tmpl	Wed Oct 11 20:53:02 2006 +0200
+++ b/templates/shortlog.tmpl	Wed Oct 11 20:59:37 2006 +0200
@@ -16,6 +16,7 @@
 <h2>shortlog for #repo|escape#</h2>
 
 <form action="#url#log">
+{sessionvars%hiddenformentry}
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
@@ -26,6 +27,7 @@
 #entries%shortlogentry#
 
 <form action="#url#log">
+{sessionvars%hiddenformentry}
 <p>
 <label for="search2">search:</label>
 <input name="rev" id="search2" type="text" size="30">