hgweb: changenav: separate pages before and after the current position
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sat, 16 Jan 2010 02:33:06 +0100
changeset 10254 8d5de52431f2
parent 10252 0bc93fa2cf2b
child 10257 a9c0d6060827
hgweb: changenav: separate pages before and after the current position This should allow styles to customize more precisely navigation bar, for example inserting a cursor to show where we are in the navigation bar.
mercurial/hgweb/webutil.py
mercurial/templates/coal/map
mercurial/templates/gitweb/changelog.tmpl
mercurial/templates/gitweb/filelog.tmpl
mercurial/templates/gitweb/graph.tmpl
mercurial/templates/gitweb/map
mercurial/templates/gitweb/shortlog.tmpl
mercurial/templates/monoblue/changelog.tmpl
mercurial/templates/monoblue/filelog.tmpl
mercurial/templates/monoblue/graph.tmpl
mercurial/templates/monoblue/map
mercurial/templates/monoblue/shortlog.tmpl
mercurial/templates/paper/filelog.tmpl
mercurial/templates/paper/graph.tmpl
mercurial/templates/paper/map
mercurial/templates/paper/shortlog.tmpl
mercurial/templates/spartan/changelog.tmpl
mercurial/templates/spartan/filelog.tmpl
mercurial/templates/spartan/graph.tmpl
mercurial/templates/spartan/map
mercurial/templates/spartan/shortlog.tmpl
--- a/mercurial/hgweb/webutil.py	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/hgweb/webutil.py	Sat Jan 16 02:33:06 2010 +0100
@@ -32,31 +32,34 @@
         for f in seq(factor * 10):
             yield f
 
-    def nav(**map):
-        l = []
-        last = 0
-        for f in seq(1, pagelen):
-            if f < pagelen or f <= last:
-                continue
-            if f > limit:
-                break
-            last = f
-            if pos + f < limit:
-                l.append(("+%d" % f, hex(nodefunc(pos + f).node())))
-            if pos - f >= 0:
-                l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node())))
+    navbefore = []
+    navafter = []
 
-        try:
-            yield {"label": "(0)", "node": hex(nodefunc('0').node())}
+    last = 0
+    for f in seq(1, pagelen):
+        if f < pagelen or f <= last:
+            continue
+        if f > limit:
+            break
+        last = f
+        if pos + f < limit:
+            navafter.append(("+%d" % f, hex(nodefunc(pos + f).node())))
+        if pos - f >= 0:
+            navbefore.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node())))
 
+    navafter.append(("tip", "tip"))
+    try:
+        navbefore.insert(0, ("(0)", hex(nodefunc('0').node())))
+    except error.RepoError:
+        pass
+
+    def gen(l):
+        def f(**map):
             for label, node in l:
                 yield {"label": label, "node": node}
+        return f
 
-            yield {"label": "tip", "node": "tip"}
-        except error.RepoError:
-            pass
-
-    return nav
+    return (dict(before=gen(navbefore), after=gen(navafter)), )
 
 def _siblings(siblings=[], hiderev=None):
     siblings = [s for s in siblings if s.node() != nullid]
--- a/mercurial/templates/coal/map	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/coal/map	Sat Jan 16 02:33:06 2010 +0100
@@ -23,6 +23,11 @@
 changeset = ../paper/changeset.tmpl
 manifest = ../paper/manifest.tmpl
 
+nav = '{before%naventry} {after%naventry}'
+navshort = '{before%navshortentry}{after%navshortentry}'
+navgraph = '{before%navgraphentry}{after%navgraphentry}'
+filenav = '{before%filenaventry}{after%filenaventry}'
+
 direntry = '
   <tr class="fileline parity{parity}">
     <td class="name">
--- a/mercurial/templates/gitweb/changelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/gitweb/changelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -27,13 +27,13 @@
 <a href="{url}branches{sessionvars%urlparameter}">branches</a> |
 <a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>{archives%archiveentry}
 <br/>
-{changenav%naventry}<br/>
+{changenav%nav}<br/>
 </div>
 
 {entries%changelogentry}
 
 <div class="page_nav">
-{changenav%naventry}<br/>
+{changenav%nav}<br/>
 </div>
 
 {footer}
--- a/mercurial/templates/gitweb/filelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/gitweb/filelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -24,7 +24,7 @@
 <a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
 <a href="{url}rss-log/{node|short}/{file|urlescape}">rss</a>
 <br/>
-{nav%filenaventry}
+{nav%filenav}
 </div>
 
 <div class="title" >{file|urlescape}</div>
@@ -34,7 +34,7 @@
 </table>
 
 <div class="page_nav">
-{nav%filenaventry}
+{nav%filenav}
 </div>
 
 {footer}
--- a/mercurial/templates/gitweb/graph.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/gitweb/graph.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -29,7 +29,7 @@
 <br/>
 <a href="{url}graph/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}graph/{rev}{morevars%urlparameter}">more</a>
-| {changenav%navgraphentry}<br/>
+| {changenav%navgraph}<br/>
 </div>
 
 <div class="title">&nbsp;</div>
@@ -115,7 +115,7 @@
 <div class="page_nav">
 <a href="{url}graph/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}graph/{rev}{morevars%urlparameter}">more</a>
-| {changenav%navgraphentry}
+| {changenav%navgraph}
 </div>
 
 {footer}
--- a/mercurial/templates/gitweb/map	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/gitweb/map	Sat Jan 16 02:33:06 2010 +0100
@@ -34,6 +34,12 @@
       <a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
     </td>
   </tr>'
+
+nav = '{before%naventry} {after%naventry}'
+navshort = '{before%navshortentry}{after%navshortentry}'
+navgraph = '{before%navgraphentry}{after%navgraphentry}'
+filenav = '{before%filenaventry}{after%filenaventry}'
+
 fileellipses = '...'
 changelogentry = changelogentry.tmpl
 searchentry = changelogentry.tmpl
--- a/mercurial/templates/gitweb/shortlog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/gitweb/shortlog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -25,8 +25,7 @@
 <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
 <a href="{url}branches{sessionvars%urlparameter}">branches</a> |
 <a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>{archives%archiveentry}
-<br/>
-{changenav%navshortentry}<br/>
+<br/>{changenav%navshort}<br/>
 </div>
 
 <div class="title">&nbsp;</div>
@@ -35,7 +34,7 @@
 </table>
 
 <div class="page_nav">
-{changenav%navshortentry}
+{changenav%navshort}
 </div>
 
 {footer}
--- a/mercurial/templates/monoblue/changelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/monoblue/changelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -34,7 +34,7 @@
     </div>
 
     <div class="page-path">
-{changenav%naventry}
+{changenav%nav}
     </div>
 
 {footer}
--- a/mercurial/templates/monoblue/filelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/monoblue/filelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -43,7 +43,7 @@
     </table>
 
     <div class="page-path">
-    {nav%filenaventry}
+    {nav%filenav}
     </div>
 
 {footer}
--- a/mercurial/templates/monoblue/graph.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/monoblue/graph.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -112,7 +112,7 @@
     <div class="page-path">
         <a href="{url}graph/{rev}{lessvars%urlparameter}">less</a>
         <a href="{url}graph/{rev}{morevars%urlparameter}">more</a>
-        | {changenav%navgraphentry}
+        | {changenav%navgraph}
     </div>
 
 {footer}
--- a/mercurial/templates/monoblue/map	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/monoblue/map	Sat Jan 16 02:33:06 2010 +0100
@@ -32,6 +32,12 @@
       <a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
     </td>
   </tr>'
+
+nav = '{before%naventry} {after%naventry}'
+navshort = '{before%navshortentry}{after%navshortentry}'
+navgraph = '{before%navgraphentry}{after%navgraphentry}'
+filenav = '{before%filenaventry}{after%filenaventry}'
+
 fileellipses = '...'
 changelogentry = changelogentry.tmpl
 searchentry = changelogentry.tmpl
--- a/mercurial/templates/monoblue/shortlog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/monoblue/shortlog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -35,7 +35,7 @@
     </table>
 
     <div class="page-path">
-{changenav%navshortentry}
+    {changenav%navshort}
     </div>
 
 {footer}
--- a/mercurial/templates/paper/filelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/paper/filelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -46,7 +46,7 @@
 <div class="navigate">
 <a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a>
 <a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a>
-| {nav%filenaventry}</div>
+| {nav%filenav}</div>
 
 <table class="bigtable">
  <tr>
@@ -60,7 +60,7 @@
 <div class="navigate">
 <a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a>
 <a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a>
-| {nav%filenaventry}
+| {nav%filenav}
 </div>
 
 </div>
--- a/mercurial/templates/paper/graph.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/paper/graph.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -40,7 +40,7 @@
 <div class="navigate">
 <a href="{url}graph/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}graph/{rev}{morevars%urlparameter}">more</a>
-| rev {rev}: {changenav%navgraphentry}
+| rev {rev}: {changenav%navgraph}
 </div>
 
 <noscript><p>The revision graph only works with JavaScript-enabled browsers.</p></noscript>
@@ -123,7 +123,7 @@
 <div class="navigate">
 <a href="{url}graph/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}graph/{rev}{morevars%urlparameter}">more</a>
-| rev {rev}: {changenav%navgraphentry}
+| rev {rev}: {changenav%navgraph}
 </div>
 
 </div>
--- a/mercurial/templates/paper/map	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/paper/map	Sat Jan 16 02:33:06 2010 +0100
@@ -23,6 +23,11 @@
 changeset = changeset.tmpl
 manifest = manifest.tmpl
 
+nav = '{before%naventry} {after%naventry}'
+navshort = '{before%navshortentry}{after%navshortentry}'
+navgraph = '{before%navgraphentry}{after%navgraphentry}'
+filenav = '{before%filenaventry}{after%filenaventry}'
+
 direntry = '
   <tr class="fileline parity{parity}">
     <td class="name">
--- a/mercurial/templates/paper/shortlog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/paper/shortlog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -42,7 +42,7 @@
 <div class="navigate">
 <a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a>
-| rev {rev}: {changenav%navshortentry}
+| rev {rev}: {changenav%navshort}
 </div>
 
 <table class="bigtable">
@@ -57,7 +57,7 @@
 <div class="navigate">
 <a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a>
 <a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a>
-| rev {rev}: {changenav%navshortentry}
+| rev {rev}: {changenav%navshort}
 </div>
 
 </div>
--- a/mercurial/templates/spartan/changelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/spartan/changelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -25,7 +25,7 @@
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
-navigate: <small class="navigate">{changenav%naventry}</small>
+navigate: <small class="navigate">{changenav%nav}</small>
 </p>
 </form>
 
@@ -36,7 +36,7 @@
 <p>
 <label for="search2">search:</label>
 <input name="rev" id="search2" type="text" size="30">
-navigate: <small class="navigate">{changenav%naventry}</small>
+navigate: <small class="navigate">{changenav%nav}</small>
 </p>
 </form>
 
--- a/mercurial/templates/spartan/filelog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/spartan/filelog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -21,7 +21,7 @@
 
 <h2>{file|escape} revision history</h2>
 
-<p>navigate: <small class="navigate">{nav%filenaventry}</small></p>
+<p>navigate: <small class="navigate">{nav%filenav}</small></p>
 
 {entries%filelogentry}
 
--- a/mercurial/templates/spartan/graph.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/spartan/graph.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -23,7 +23,7 @@
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
-navigate: <small class="navigate">{changenav%navgraphentry}</small>
+navigate: <small class="navigate">{changenav%navgraph}</small>
 </p>
 </form>
 
@@ -89,7 +89,7 @@
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
-navigate: <small class="navigate">{changenav%navgraphentry}</small>
+navigate: <small class="navigate">{changenav%navgraph}</small>
 </p>
 </form>
 
--- a/mercurial/templates/spartan/map	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/spartan/map	Sat Jan 16 02:33:06 2010 +0100
@@ -20,6 +20,11 @@
 changeset = changeset.tmpl
 manifest = manifest.tmpl
 
+nav = '{before%naventry} {after%naventry}'
+navshort = '{before%navshortentry}{after%navshortentry}'
+navgraph = '{before%navgraphentry}{after%navgraphentry}'
+filenav = '{before%filenaventry}{after%filenaventry}'
+
 direntry = '
   <tr class="parity{parity}">
     <td><tt>drwxr-xr-x</tt>&nbsp;
--- a/mercurial/templates/spartan/shortlog.tmpl	Fri Jan 15 21:32:53 2010 +0100
+++ b/mercurial/templates/spartan/shortlog.tmpl	Sat Jan 16 02:33:06 2010 +0100
@@ -25,7 +25,7 @@
 <p>
 <label for="search1">search:</label>
 <input name="rev" id="search1" type="text" size="30">
-navigate: <small class="navigate">{changenav%navshortentry}</small>
+navigate: <small class="navigate">{changenav%navshort}</small>
 </p>
 </form>
 
@@ -36,7 +36,7 @@
 <p>
 <label for="search2">search:</label>
 <input name="rev" id="search2" type="text" size="30">
-navigate: <small class="navigate">{changenav%navshortentry}</small>
+navigate: <small class="navigate">{changenav%navshort}</small>
 </p>
 </form>