mercurial/templates/paper/graph.tmpl
author Anton Shestakov <av6@dwimlabs.net>
Sun, 10 Dec 2017 15:56:22 +0800
changeset 35407 27ab3150cd50
parent 35255 ad0de63e1d6a
child 35409 f84b01257e06
permissions -rw-r--r--
hgweb: calculate <canvas> width and height client-side hgweb determines and passes to templates some variables related to graph appearance, like bg_height, canvaswidth and canvasheight. bg_height was and still is used for graph.scale() call in graph.tmpl, and the two latter variables were used in <canvas> element as width and height properties, and they were set before JS code got to run. Setting these properties server-side doesn't make a lot of sense, because a graph that has been scaled should calculate things like width and height on its own when being rendered. Let's move (re)sizing <canvas> to JavaScript (to Graph.render function) and stop parsing HTML with regular expressions just to know new width and height. That extra loop that only counts cols is required because <canvas> can't be resized after or in the process of rendering (or it gets cleared). Incidentally, SVG doesn't have this problem and I'm hoping to switch graph to using it in future. There also was truecanvasheight, but according to hg grep --all it was never used, see d490edc71146.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     1
{header}
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     2
<title>{repo|escape}: revision graph</title>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     3
<link rel="alternate" type="application/atom+xml"
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
     4
   href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}: log" />
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     5
<link rel="alternate" type="application/rss+xml"
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
     6
   href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}: log" />
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
     7
<!--[if IE]><script type="text/javascript" src="{staticurl|urlescape}excanvas.js"></script><![endif]-->
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     8
</head>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     9
<body>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    10
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    11
<div class="container">
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    12
<div class="menu">
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    13
<div class="logo">
13964
616ad3f6fd33 hgweb: support alternate logo url
Steven Stallion <sstallion@gmail.com>
parents: 13610
diff changeset
    14
<a href="{logourl}">
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    15
<img src="{staticurl|urlescape}{logoimg}" alt="mercurial" /></a>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    16
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    17
<ul>
25606
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    18
<li><a href="{url|urlescape}shortlog/{symrev}{sessionvars%urlparameter}">log</a></li>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    19
<li class="active">graph</li>
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    20
<li><a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></li>
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    21
<li><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></li>
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    22
<li><a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></li>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    23
</ul>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    24
<ul>
25606
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    25
<li><a href="{url|urlescape}rev/{symrev}{sessionvars%urlparameter}">changeset</a></li>
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    26
<li><a href="{url|urlescape}file/{symrev}{path|urlescape}{sessionvars%urlparameter}">browse</a></li>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    27
</ul>
12666
ead4e21f49f1 web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents: 10856
diff changeset
    28
<ul>
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    29
 <li><a href="{url|urlescape}help{sessionvars%urlparameter}">help</a></li>
12666
ead4e21f49f1 web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents: 10856
diff changeset
    30
</ul>
18200
b31266671918 hgweb: add (Atom) subscribe link to the main paper template pages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 17580
diff changeset
    31
<div class="atom-logo">
18526
9409aeaafdc1 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents: 18258
diff changeset
    32
<a href="{url|urlescape}atom-log" title="subscribe to atom feed">
23830
c4f6fc4eb01e hgweb: close <img> elements
Anton Shestakov <engored@ya.ru>
parents: 23829
diff changeset
    33
<img class="atom-logo" src="{staticurl|urlescape}feed-icon-14x14.png" alt="atom feed" />
18200
b31266671918 hgweb: add (Atom) subscribe link to the main paper template pages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 17580
diff changeset
    34
</a>
b31266671918 hgweb: add (Atom) subscribe link to the main paper template pages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 17580
diff changeset
    35
</div>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    36
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    37
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    38
<div class="main">
18258
bebb05a7e249 hgweb: add a "URL breadcrumb" to the index and repository pages
Angel Ezquerra <angel.ezquerra at gmail.com>
parents: 18200
diff changeset
    39
<h2 class="breadcrumb"><a href="/">Mercurial</a> {pathdef%breadcrumb}</h2>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    40
<h3>graph</h3>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    41
32758
cba4461aa0a0 hgweb: consolidate search form for paper
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30766
diff changeset
    42
{searchform}
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    43
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    44
<div class="navigate">
25606
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    45
<a href="{url|urlescape}graph/{symrev}{lessvars%urlparameter}">less</a>
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    46
<a href="{url|urlescape}graph/{symrev}{morevars%urlparameter}">more</a>
10254
8d5de52431f2 hgweb: changenav: separate pages before and after the current position
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 9999
diff changeset
    47
| rev {rev}: {changenav%navgraph}
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    48
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    49
7725
6a888d491eaf coal/paper: switch to XHTML 1.1
Benoit Allard <benoit@aeteurope.nl>
parents: 7411
diff changeset
    50
<noscript><p>The revision graph only works with JavaScript-enabled browsers.</p></noscript>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    51
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    52
<div id="wrapper">
19453
ece3b329ad25 hgweb: make stripes in graph with CSS
Alexander Plavin <me@aplavin.ru>
parents: 18526
diff changeset
    53
<ul id="nodebgs" class="stripes2"></ul>
35407
27ab3150cd50 hgweb: calculate <canvas> width and height client-side
Anton Shestakov <av6@dwimlabs.net>
parents: 35255
diff changeset
    54
<canvas id="graph"></canvas>
35219
5857eb81c1f3 paper: render changesets server-side on /graph page
Anton Shestakov <av6@dwimlabs.net>
parents: 35160
diff changeset
    55
<ul id="graphnodes">{nodes%graphentry}</ul>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    56
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    57
30766
d7bf7d2bd5ab hgweb: support Content Security Policy
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27913
diff changeset
    58
<script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    59
<!-- hide script content
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    60
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    61
var data = {jsdata|json};
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    62
var graph = new Graph();
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    63
graph.scale({bg_height});
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    64
35160
69a865dc2ada hgweb: define locally used variables as actually local in mercurial.js
Anton Shestakov <av6@dwimlabs.net>
parents: 32758
diff changeset
    65
graph.vertex = function(x, y, radius, color, parity, cur) \{
35255
ad0de63e1d6a hgweb: move common vertex code to Graph.prototype
Anton Shestakov <av6@dwimlabs.net>
parents: 35219
diff changeset
    66
	Graph.prototype.vertex.apply(this, arguments);
ad0de63e1d6a hgweb: move common vertex code to Graph.prototype
Anton Shestakov <av6@dwimlabs.net>
parents: 35219
diff changeset
    67
	return ['<li class="bg"></li>', ''];
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    68
}
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    69
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    70
graph.render(data);
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    71
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    72
// stop hiding script -->
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    73
</script>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    74
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    75
<div class="navigate">
25606
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    76
<a href="{url|urlescape}graph/{symrev}{lessvars%urlparameter}">less</a>
3bb6f5f478a7 hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Anton Shestakov <av6@dwimlabs.net>
parents: 24041
diff changeset
    77
<a href="{url|urlescape}graph/{symrev}{morevars%urlparameter}">more</a>
10254
8d5de52431f2 hgweb: changenav: separate pages before and after the current position
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 9999
diff changeset
    78
| rev {rev}: {changenav%navgraph}
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    79
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    80
30766
d7bf7d2bd5ab hgweb: support Content Security Policy
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27913
diff changeset
    81
<script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
19783
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    82
    ajaxScrollInit(
20253
43cfad930d38 hgweb: avoid invalid infinity scroll request when overwritten web.style
Takumi IINO <trot.thunder@gmail.com>
parents: 19795
diff changeset
    83
            '{url|urlescape}graph/{rev}?revcount=%next%&style={style}',
19783
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    84
            {revcount}+60,
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    85
            function (htmlText, previousVal) \{ return previousVal + 60; },
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    86
            '#wrapper',
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    87
            '<div class="%class%" style="text-align: center;">%text%</div>',
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    88
            'graph'
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    89
    );
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    90
</script>
1c2a309bba4f paper: add infinite scrolling to graph by calling ajaxScrollInit at the page
Alexander Plavin <alexander@plav.in>
parents: 19453
diff changeset
    91
7411
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    92
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    93
</div>
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    94
b71ee3e00e81 coal/paper: move actual templates from coal to paper
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    95
{footer}