Patchwork [3,of,5] hgweb: consolidate search form for gitweb

login
register
mail settings
Submitter Gregory Szorc
Date June 9, 2017, 9 p.m.
Message ID <47282854e7aff870a87c.1497042004@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21296/
State Accepted
Headers show

Comments

Gregory Szorc - June 9, 2017, 9 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1497040958 25200
#      Fri Jun 09 13:42:38 2017 -0700
# Node ID 47282854e7aff870a87c9e573d4ef5fdca5b894a
# Parent  08889384494e21be250fae4d9c7b8082df31c0b2
hgweb: consolidate search form for gitweb
Yuya Nishihara - June 11, 2017, 4:36 a.m.
On Fri, 09 Jun 2017 14:00:04 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1497040958 25200
> #      Fri Jun 09 13:42:38 2017 -0700
> # Node ID 47282854e7aff870a87c9e573d4ef5fdca5b894a
> # Parent  08889384494e21be250fae4d9c7b8082df31c0b2
> hgweb: consolidate search form for gitweb

> +searchform = '
> +  <form action="{url|urlescape}log">
> +    {sessionvars%hiddenformentry}
> +    <div class="search">
> +      <input type="text" name="rev"  />
> +    </div>
> +  </form>'

Same here. I'll add value="{query|escape}" in flight.

Patch

diff --git a/mercurial/templates/gitweb/changelog.tmpl b/mercurial/templates/gitweb/changelog.tmpl
--- a/mercurial/templates/gitweb/changelog.tmpl
+++ b/mercurial/templates/gitweb/changelog.tmpl
@@ -12,12 +12,7 @@ 
 <a href="/">Mercurial</a> {pathdef%breadcrumb} / changelog
 </div>
 
-<form action="{url|urlescape}log">
-{sessionvars%hiddenformentry}
-<div class="search">
-<input type="text" name="rev"  />
-</div>
-</form>
+{searchform}
 
 <div class="page_nav">
 <a href="{url|urlescape}summary{sessionvars%urlparameter}">summary</a> |
diff --git a/mercurial/templates/gitweb/graph.tmpl b/mercurial/templates/gitweb/graph.tmpl
--- a/mercurial/templates/gitweb/graph.tmpl
+++ b/mercurial/templates/gitweb/graph.tmpl
@@ -13,12 +13,8 @@ 
 <a href="/">Mercurial</a> {pathdef%breadcrumb} / graph
 </div>
 
-<form action="{url|urlescape}log">
-{sessionvars%hiddenformentry}
-<div class="search">
-<input type="text" name="rev"  />
-</div>
-</form>
+{searchform}
+
 <div class="page_nav">
 <a href="{url|urlescape}summary{sessionvars%urlparameter}">summary</a> |
 <a href="{url|urlescape}shortlog/{symrev}{sessionvars%urlparameter}">shortlog</a> |
diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -323,3 +323,11 @@  index = index.tmpl
 urlparameter = '{separator}{name}={value|urlescape}'
 hiddenformentry = '<input type="hidden" name="{name}" value="{value|escape}" />'
 breadcrumb = '&gt; <a href="{url|urlescape}">{name|escape}</a> '
+
+searchform = '
+  <form action="{url|urlescape}log">
+    {sessionvars%hiddenformentry}
+    <div class="search">
+      <input type="text" name="rev"  />
+    </div>
+  </form>'
diff --git a/mercurial/templates/gitweb/search.tmpl b/mercurial/templates/gitweb/search.tmpl
--- a/mercurial/templates/gitweb/search.tmpl
+++ b/mercurial/templates/gitweb/search.tmpl
@@ -11,12 +11,8 @@ 
 <a href="{logourl}" title="Mercurial" style="float: right;">Mercurial</a>
 <a href="/">Mercurial</a> {pathdef%breadcrumb} / search
 
-<form action="{url|urlescape}log">
-{sessionvars%hiddenformentry}
-<div class="search">
-<input type="text" name="rev" value="{query|escape}" />
-</div>
-</form>
+{searchform}
+
 </div>
 
 <div class="page_nav">
diff --git a/mercurial/templates/gitweb/shortlog.tmpl b/mercurial/templates/gitweb/shortlog.tmpl
--- a/mercurial/templates/gitweb/shortlog.tmpl
+++ b/mercurial/templates/gitweb/shortlog.tmpl
@@ -12,12 +12,8 @@ 
 <a href="/">Mercurial</a> {pathdef%breadcrumb} / shortlog
 </div>
 
-<form action="{url|urlescape}log">
-{sessionvars%hiddenformentry}
-<div class="search">
-<input type="text" name="rev"  />
-</div>
-</form>
+{searchform}
+
 <div class="page_nav">
 <a href="{url|urlescape}summary{sessionvars%urlparameter}">summary</a> |
 shortlog |
diff --git a/mercurial/templates/gitweb/summary.tmpl b/mercurial/templates/gitweb/summary.tmpl
--- a/mercurial/templates/gitweb/summary.tmpl
+++ b/mercurial/templates/gitweb/summary.tmpl
@@ -10,12 +10,9 @@ 
 <div class="page_header">
 <a href="{logourl}" title="Mercurial" style="float: right;">Mercurial</a>
 <a href="/">Mercurial</a> {pathdef%breadcrumb} / summary
-<form action="{url|urlescape}log">
-{sessionvars%hiddenformentry}
-<div class="search">
-<input type="text" name="rev"  />
-</div>
-</form>
+
+{searchform}
+
 </div>
 
 <div class="page_nav">
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1533,12 +1533,15 @@  Overviews
   <div class="page_header">
   <a href="https://mercurial-scm.org/" title="Mercurial" style="float: right;">Mercurial</a>
   <a href="/">Mercurial</a>  / summary
+  
+  
   <form action="/log">
   <input type="hidden" name="style" value="gitweb" />
   <div class="search">
   <input type="text" name="rev"  />
   </div>
   </form>
+  
   </div>
   
   <div class="page_nav">
@@ -1734,12 +1737,14 @@  Overviews
   <a href="/">Mercurial</a>  / graph
   </div>
   
+  
   <form action="/log">
   <input type="hidden" name="style" value="gitweb" />
   <div class="search">
   <input type="text" name="rev"  />
   </div>
   </form>
+  
   <div class="page_nav">
   <a href="/summary?style=gitweb">summary</a> |
   <a href="/shortlog/tip?style=gitweb">shortlog</a> |