[PATCH] hgweb: make graph page really Non-Javascript compliant

Ben benoit.allard at gmx.de
Mon Jun 23 22:32:18 UTC 2008


# HG changeset patch
# User Benoit Allard <benoit at aeteurope.nl>
# Date 1214259073 -7200
# Node ID fed3014b4f7227ccb031a9b47de88e278a6dba2b
# Parent  1fe6f365df2e0ed6dd56b5bd9993812378506174
hgweb: make graph page really Non-Javascript compliant

diff -r 1fe6f365df2e -r fed3014b4f72 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Mon Jun 23 15:02:52 2008 +0200
+++ b/mercurial/hgweb/webcommands.py	Tue Jun 24 00:11:13 2008 +0200
@@ -580,6 +580,34 @@
     rev = webutil.changectx(web.repo, req).rev()
     bg_height = 39

+    def changelist(limit=0, **map):
+            l = [] # build a list in forward order for efficiency
+            for i in xrange(downrev, uprev):
+                ctx = web.repo.changectx(i)
+                n = ctx.node()
+                showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
+
+                l.insert(0, {"parity": parity.next(),
+                             "author": ctx.user(),
+                             "parent": webutil.siblings(ctx.parents(), i - 1),
+                             "child": webutil.siblings(ctx.children(), i + 1),
+                             "changelogtag": showtags,
+                             "desc": ctx.description(),
+                             "date": ctx.date(),
+                             "files": web.listfilediffs(tmpl, ctx.files(), n),
+                             "rev": i,
+                             "node": hex(n),
+                             "tags": webutil.nodetagsdict(web.repo, n),
+                             "inbranch": webutil.nodeinbranch(web.repo, ctx),
+                             "branches": webutil.nodebranchdict(web.repo, ctx)
+                     })
+
+            if limit > 0:
+                l = l[:limit]
+
+            for e in l:
+                yield e
+
     max_rev = web.repo.changelog.count() - 1
     revcount = min(max_rev, int(req.form.get('revcount', [25])[0]))
     revnode = web.repo.changelog.node(rev)
@@ -591,6 +619,7 @@
     maxchanges = web.maxshortchanges or web.maxchanges
     count = web.repo.changelog.count()
     changenav = webutil.revnavgen(rev, maxchanges, count, web.repo.changectx)
+    parity = paritygen(web.stripecount, offset=downrev-uprev)

     tree = list(graphmod.graph(web.repo, rev, rev - revcount))
     canvasheight = (len(tree) + 1) * bg_height - 27;
@@ -610,4 +639,5 @@
                 lessrev=lessrev, revcountmore=revcount and 2 * revcount or 1,
                 revcountless=revcount / 2, downrev=downrev,
                 canvasheight=canvasheight, bg_height=bg_height,
-                jsdata=data, node=revnode_hex, changenav=changenav)
+                jsdata=data, node=revnode_hex, changenav=changenav,
+                entries=lambda **x:changelist(limit=0, **x))
diff -r 1fe6f365df2e -r fed3014b4f72 templates/coal/graph.tmpl
--- a/templates/coal/graph.tmpl	Mon Jun 23 15:02:52 2008 +0200
+++ b/templates/coal/graph.tmpl	Tue Jun 24 00:11:13 2008 +0200
@@ -40,7 +40,16 @@
 | {changenav%navgraphentry}
 </div>

-<div id="noscript">The revision graph only works with
JavaScript-enabled browsers.</div>
+<div id="noscript">
+<table class="bigtable">
+ <tr>
+  <th class="age">age</td>
+  <th class="author">author</td>
+  <th class="description">description</td>
+ </tr>
+{entries%shortlogentry}
+</table>
+</div>

 <div id="wrapper">
 <ul id="nodebgs"></ul>
@@ -50,8 +59,8 @@

 <script type="text/javascript" src="{staticurl}graph.js"></script>
 <script>
-
-document.getElementById('noscript').style.visibility = 'hidden';
+<!-- // hide script
+document.getElementById('noscript').style.display = 'none';

 data = {jsdata|json};
 graph = new Graph();
@@ -100,6 +109,7 @@
 }

 graph.render(data);
+// --> stop hiding
 </script>

 <div class="navigate">
diff -r 1fe6f365df2e -r fed3014b4f72 templates/gitweb/graph.tmpl
--- a/templates/gitweb/graph.tmpl	Mon Jun 23 15:02:52 2008 +0200
+++ b/templates/gitweb/graph.tmpl	Tue Jun 24 00:11:13 2008 +0200
@@ -32,7 +32,11 @@

 <div class="title">&nbsp;</div>

-<div id="noscript">The revision graph only works with
JavaScript-enabled browsers.</div>
+<div id="noscript">
+<table cellspacing="0">
+#entries%shortlogentry#
+</table>
+</div>

 <div id="wrapper">
 <ul id="nodebgs"></ul>
@@ -42,8 +46,8 @@

 <script type="text/javascript" src="#staticurl#graph.js"></script>
 <script>
-
-document.getElementById('noscript').style.visibility = 'hidden';
+<!-- // hide script
+document.getElementById('noscript').style.display = 'none';

 data = {jsdata|json};
 graph = new Graph();
@@ -112,6 +116,7 @@
 }

 graph.render(data);
+// stop hiding-->
 </script>

 <div class="page_nav">
diff -r 1fe6f365df2e -r fed3014b4f72 templates/graph.tmpl
--- a/templates/graph.tmpl	Mon Jun 23 15:02:52 2008 +0200
+++ b/templates/graph.tmpl	Tue Jun 24 00:11:13 2008 +0200
@@ -25,7 +25,9 @@
 </p>
 </form>

-<div id="noscript">The revision graph only works with
JavaScript-enabled browsers.</div>
+<div id="noscript">
+#entries%shortlogentry#
+</div>

 <div id="wrapper">
 <ul id="nodebgs"></ul>
@@ -35,8 +37,8 @@

 <script type="text/javascript" src="#staticurl#graph.js"></script>
 <script>
-
-document.getElementById('noscript').style.visibility = 'hidden';
+<!-- // hide script
+document.getElementById('noscript').style.display = 'none';

 data = {jsdata|json};
 graph = new Graph();
@@ -83,6 +85,7 @@
 }

 graph.render(data);
+//--> stop hiding
 </script>

 <form action="#url#log">


More information about the Mercurial-devel mailing list