[PATCH 3 of 3] Integrated plot in gitweb style templates
Francesco Degrassi
francesco.degrassi at emaze.net
Mon Aug 16 18:22:16 CDT 2010
mercurial/templates/gitweb/branches.tmpl | 1 +
mercurial/templates/gitweb/changelog.tmpl | 1 +
mercurial/templates/gitweb/changeset.tmpl | 1 +
mercurial/templates/gitweb/fileannotate.tmpl | 1 +
mercurial/templates/gitweb/filediff.tmpl | 1 +
mercurial/templates/gitweb/filelog.tmpl | 1 +
mercurial/templates/gitweb/filerevision.tmpl | 1 +
mercurial/templates/gitweb/graph.tmpl | 1 +
mercurial/templates/gitweb/manifest.tmpl | 1 +
mercurial/templates/gitweb/map | 3 +
mercurial/templates/gitweb/plot.tmpl | 135 +++++++++++++++++++++++++++
mercurial/templates/gitweb/search.tmpl | 1 +
mercurial/templates/gitweb/shortlog.tmpl | 1 +
mercurial/templates/gitweb/summary.tmpl | 1 +
mercurial/templates/gitweb/tags.tmpl | 1 +
tests/test-hgweb-commands.out | 2 +
16 files changed, 153 insertions(+), 0 deletions(-)
# HG changeset patch
# User Francesco Degrassi <francesco.degrassi at emaze.net>
# Date 1281997393 -7200
# Node ID b9658bf831fff7c884bb21f6eec2fead68b65166
# Parent 27ec8d64ac1ddfab62b4eec20464f6644661a871
Integrated plot in gitweb style templates
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/branches.tmpl
--- a/mercurial/templates/gitweb/branches.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/branches.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
branches |
<a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/changelog.tmpl
--- a/mercurial/templates/gitweb/changelog.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/changelog.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -23,6 +23,7 @@
<a href="{url}shortlog/{rev}{sessionvars%urlparameter}">shortlog</a> |
changelog |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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}
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/changeset.tmpl
--- a/mercurial/templates/gitweb/changeset.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/changeset.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog/{rev}{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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> |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/fileannotate.tmpl
--- a/mercurial/templates/gitweb/fileannotate.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/fileannotate.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a> |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/filediff.tmpl
--- a/mercurial/templates/gitweb/filediff.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/filediff.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a> |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/filelog.tmpl
--- a/mercurial/templates/gitweb/filelog.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/filelog.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/filerevision.tmpl
--- a/mercurial/templates/gitweb/filerevision.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/filerevision.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a> |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/graph.tmpl
--- a/mercurial/templates/gitweb/graph.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/graph.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -23,6 +23,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a> |
graph |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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>
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/manifest.tmpl
--- a/mercurial/templates/gitweb/manifest.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/manifest.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
files |
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/map Tue Aug 17 00:23:13 2010 +0200
@@ -10,6 +10,7 @@
naventry = '<a href="{url}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navshortentry = '<a href="{url}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navgraphentry = '<a href="{url}graph/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
+navplotentry = '<a href="{url}plot/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
filenaventry = '<a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
filedifflink = '<a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
filenodelink = '
@@ -38,6 +39,7 @@
nav = '{before%naventry} {after%naventry}'
navshort = '{before%navshortentry}{after%navshortentry}'
navgraph = '{before%navgraphentry}{after%navgraphentry}'
+navplot = '{before%navplotentry}{after%navplotentry}'
filenav = '{before%filenaventry}{after%filenaventry}'
fileellipses = '...'
@@ -205,6 +207,7 @@
</tr>'
shortlog = shortlog.tmpl
graph = graph.tmpl
+plot = plot.tmpl
tagtag = '<span class="tagtag" title="{name}">{name}</span> '
branchtag = '<span class="branchtag" title="{name}">{name}</span> '
inbranchtag = '<span class="inbranchtag" title="{name}">{name}</span> '
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/plot.tmpl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/templates/gitweb/plot.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -0,0 +1,135 @@
+{header}
+<title>{repo|escape}: Plot</title>
+<link rel="alternate" type="application/atom+xml"
+ href="{url}atom-log" title="Atom feed for {repo|escape}"/>
+<link rel="alternate" type="application/rss+xml"
+ href="{url}rss-log" title="RSS feed for {repo|escape}"/>
+<!--[if IE]><script type="text/javascript" src="{staticurl}excanvas.js"></script><![endif]-->
+</head>
+<body>
+
+<div class="page_header">
+<a href="{staticurl}../.." title="Mercurial" style="float: right;">Mercurial</a><a href="{url}summary{sessionvars%urlparameter}">{repo|escape}</a> / plot
+</div>
+
+<form action="{url}log">
+{sessionvars%hiddenformentry}
+<div class="search">
+<input type="text" name="rev" />
+</div>
+</form>
+<div class="page_nav">
+<a href="{url}summary{sessionvars%urlparameter}">summary</a> |
+<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
+<a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a> |
+<a href="{url}graph/{rev}{sessionvars%urlparameter}">graph</a> |
+plot |
+<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>
+<br/>
+<a href="{url}plot/{rev}{lessvars%urlparameter}">less</a>
+<a href="{url}plot/{rev}{morevars%urlparameter}">more</a>
+| {changenav%navplot}
+| <a href="{url}plot/{rev}{narrowervars%urlparameter}">narrower</a>
+<a href="{url}plot/{rev}{widervars%urlparameter}">wider</a><br/>
+</div>
+
+<div class="title"> </div>
+
+<noscript>The revision plot only works with JavaScript-enabled browsers.</noscript>
+
+<div id="wrapper">
+<canvas id="plot" width="500" height="600" style="position: relative; float: left; top:0px !important"></canvas>
+<div id="node_bgs" style="position:absolute; width: 100%; z-index: -1"></div>
+<div id="node_entries" style="position:absolute; z-index:100"></div>
+</div>
+
+
+<script type="text/javascript" src="{staticurl}plot.js"></script>
+<script type="text/javascript">
+<!-- Hide script
+
+var tpl_entry = '<div style="_STYLE" class="_CLASS"><span class="info firstline" style="display:block"><span class="desc">';
+tpl_entry += '<a class="list" href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID"><b>_DESC</b></a>';
+tpl_entry += ' (_NODEID)';
+tpl_entry += '</span><span> _TAGS</span></span>';
+tpl_entry += '<span class="info secondline">_DATE, by _USER</span></div>';
+
+var node_entries_data = [];
+var bg_entries_data = [];
+
+var addentry_callback = function(node, index, height) \{
+ var parity = index % 2;
+ var padding = 2;
+ var actual_height = height - 2*padding;
+ var nclass = "info"; // nclass +=" parity" + parity;
+ var nstyle = "display: block; padding: " + padding + "px; height: " + actual_height +"px";
+ var item = tpl_entry.replace(/_STYLE/, nstyle);
+ item = item.replace(/_CLASS/, nclass);
+ item = item.replace(/_PARITY/, 'parity' + parity);
+ item = item.replace(/_NODEID/, node.id);
+ item = item.replace(/_NODEID/, node.id);
+ item = item.replace(/_NODEID/, node.id);
+ item = item.replace(/_DESC/, node.desc);
+ item = item.replace(/_USER/, node.user);
+ item = item.replace(/_DATE/, node.age);
+
+ var tagspan = '';
+ if (node.tags.length || (node.branch != 'default' || node.tip)) \{
+ tagspan = '<span class="logtags">';
+ if (node.tip) \{
+ tagspan += '<span class="branchtag" title="' + node.branch + '">';
+ tagspan += node.branch + '</span> ';
+ } else if (!node.tip && node.branch != 'default') \{
+ tagspan += '<span class="inbranchtag" title="' + node.branch + '">';
+ tagspan += node.branch + '</span> ';
+ }
+ if (node.tags.length) \{
+ for (var t in node.tags) \{
+ var tag = node.tags[t];
+ tagspan += '<span class="tagtag">' + tag + '</span> ';
+ }
+ }
+ tagspan += '</span>';
+ }
+
+ item = item.replace(/_TAGS/, tagspan);
+ node_entries_data.push(item);
+ bg_entries_data.push('<div class="parity'+parity+'" style="height: '+ height + 'px"> </div>');
+}
+
+
+
+var data = {jsdata|json};
+var plot = new Plot();
+var canvas = document.getElementById('plot');
+
+plot.setNodeCallback(addentry_callback);
+plot.scale({plot_width},40);
+plot.render(data);
+
+if (plot.getMaxWidth() > canvas.width) \{
+ // If default width was not enough, resize and repeat rendering
+ canvas.width = plot.getMaxWidth();
+ plot.setNodeCallback(null); // skip generating node_entries, we already did
+ plot.render(data);
+}
+
+document.getElementById('node_entries').innerHTML = node_entries_data.join("");
+document.getElementById('node_bgs').innerHTML = bg_entries_data.join("");
+
+document.getElementById('node_entries').style.left = (plot.getMaxWidth() + 30) + "px";
+// stop hiding script -->
+</script>
+
+<div style="clear: both"></div>
+<div class="page_nav">
+<a href="{url}plot/{rev}{lessvars%urlparameter}">less</a>
+<a href="{url}plot/{rev}{morevars%urlparameter}">more</a>
+| {changenav%navplot}
+| <a href="{url}plot/{rev}{narrowervars%urlparameter}">narrower</a>
+<a href="{url}plot/{rev}{widervars%urlparameter}">wider</a>
+</div>
+
+{footer}
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/search.tmpl
--- a/mercurial/templates/gitweb/search.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/search.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -23,6 +23,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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}
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/shortlog.tmpl
--- a/mercurial/templates/gitweb/shortlog.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/shortlog.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -22,6 +22,7 @@
shortlog |
<a href="{url}log/{rev}{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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}
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/summary.tmpl
--- a/mercurial/templates/gitweb/summary.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/summary.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -23,6 +23,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
<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}
diff -r 27ec8d64ac1d -r b9658bf831ff mercurial/templates/gitweb/tags.tmpl
--- a/mercurial/templates/gitweb/tags.tmpl Tue Aug 17 00:16:24 2010 +0200
+++ b/mercurial/templates/gitweb/tags.tmpl Tue Aug 17 00:23:13 2010 +0200
@@ -16,6 +16,7 @@
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}plot{sessionvars%urlparameter}">plot</a> |
tags |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>
diff -r 27ec8d64ac1d -r b9658bf831ff tests/test-hgweb-commands.out
--- a/tests/test-hgweb-commands.out Tue Aug 17 00:16:24 2010 +0200
+++ b/tests/test-hgweb-commands.out Tue Aug 17 00:23:13 2010 +0200
@@ -589,6 +589,7 @@
<a href="/shortlog?style=gitweb">shortlog</a> |
<a href="/log?style=gitweb">changelog</a> |
<a href="/graph?style=gitweb">graph</a> |
+<a href="/plot?style=gitweb">plot</a> |
<a href="/tags?style=gitweb">tags</a> |
<a href="/branches?style=gitweb">branches</a> |
<a href="/file/1d22e65f027e?style=gitweb">files</a>
@@ -739,6 +740,7 @@
<a href="/shortlog?style=gitweb">shortlog</a> |
<a href="/log/2?style=gitweb">changelog</a> |
graph |
+<a href="/plot?style=gitweb">plot</a> |
<a href="/tags?style=gitweb">tags</a> |
<a href="/branches?style=gitweb">branches</a> |
<a href="/file/1d22e65f027e?style=gitweb">files</a>
More information about the Mercurial-devel
mailing list