Mercurial > hg
annotate mercurial/templates/spartan/graph.tmpl @ 35407:27ab3150cd50
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 10 Dec 2017 15:56:22 +0800 |
parents | ad0de63e1d6a |
children | 56854848e485 |
rev | line source |
---|---|
8431
5c1aabc58004
spartan: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8357
diff
changeset
|
1 {header} |
5c1aabc58004
spartan: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8357
diff
changeset
|
2 <title>{repo|escape}: graph</title> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
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:
18259
diff
changeset
|
4 href="{url|urlescape}atom-tags" title="Atom feed for {repo|escape}: tags"> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
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:
18259
diff
changeset
|
6 href="{url|urlescape}rss-tags" title="RSS feed for {repo|escape}: tags"> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
7 <!--[if IE]><script type="text/javascript" src="{staticurl|urlescape}excanvas.js"></script><![endif]--> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 </head> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 <body> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 <div class="buttons"> |
25794
902148444889
spartan: don't drop current revision in log/graph links
Anton Shestakov <av6@dwimlabs.net>
parents:
25603
diff
changeset
|
12 <a href="{url|urlescape}log/{symrev}{sessionvars%urlparameter}">changelog</a> |
902148444889
spartan: don't drop current revision in log/graph links
Anton Shestakov <av6@dwimlabs.net>
parents:
25603
diff
changeset
|
13 <a href="{url|urlescape}shortlog/{symrev}{sessionvars%urlparameter}">shortlog</a> |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
14 <a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a> |
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
15 <a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a> |
25603
1cac419ab831
hgweb: don't dereference symbolic revision in spartan style
Anton Shestakov <av6@dwimlabs.net>
parents:
18526
diff
changeset
|
16 <a href="{url|urlescape}file/{symrev}/{sessionvars%urlparameter}">files</a> |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
17 <a href="{url|urlescape}help{sessionvars%urlparameter}">help</a> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 </div> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 |
18259
7bf412b767fe
hgweb, spartan: add "URL breadcrumbs"
Angel Ezquerra <angel.ezquerra at gmail.com>
parents:
17580
diff
changeset
|
20 <h2><a href="/">Mercurial</a> {pathdef%breadcrumb} / graph</h2> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
22 <form action="{url|urlescape}log"> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 {sessionvars%hiddenformentry} |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 <p> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 <label for="search1">search:</label> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 <input name="rev" id="search1" type="text" size="30"> |
10254
8d5de52431f2
hgweb: changenav: separate pages before and after the current position
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9999
diff
changeset
|
27 navigate: <small class="navigate">{changenav%navgraph}</small> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 </p> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 </form> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 <noscript>The revision graph only works with JavaScript-enabled browsers.</noscript> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
32 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 <div id="wrapper"> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 <ul id="nodebgs"></ul> |
35407
27ab3150cd50
hgweb: calculate <canvas> width and height client-side
Anton Shestakov <av6@dwimlabs.net>
parents:
35255
diff
changeset
|
35 <canvas id="graph"></canvas> |
35222
66c11a66ad1a
spartan: render changesets server-side on /graph page
Anton Shestakov <av6@dwimlabs.net>
parents:
35160
diff
changeset
|
36 <ul id="graphnodes">{nodes%graphentry}</ul> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 </div> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
30766
d7bf7d2bd5ab
hgweb: support Content Security Policy
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27913
diff
changeset
|
39 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 <!-- hide script content |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 var data = {jsdata|json}; |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 var graph = new Graph(); |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 graph.scale({bg_height}); |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
45 |
35160
69a865dc2ada
hgweb: define locally used variables as actually local in mercurial.js
Anton Shestakov <av6@dwimlabs.net>
parents:
30766
diff
changeset
|
46 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:
35222
diff
changeset
|
47 Graph.prototype.vertex.apply(this, arguments); |
ad0de63e1d6a
hgweb: move common vertex code to Graph.prototype
Anton Shestakov <av6@dwimlabs.net>
parents:
35222
diff
changeset
|
48 return ['<li class="bg parity' + parity + '"></li>', '']; |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 } |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
50 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 graph.render(data); |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 // stop hiding script --> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 </script> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
55 |
18526
9409aeaafdc1
hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Thomas Arendsen Hein <thomas@intevation.de>
parents:
18259
diff
changeset
|
56 <form action="{url|urlescape}log"> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
57 {sessionvars%hiddenformentry} |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 <p> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 <label for="search1">search:</label> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 <input name="rev" id="search1" type="text" size="30"> |
10254
8d5de52431f2
hgweb: changenav: separate pages before and after the current position
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9999
diff
changeset
|
61 navigate: <small class="navigate">{changenav%navgraph}</small> |
7338
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
62 </p> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 </form> |
fecfe4392e94
hgweb: move old style to spartan/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 |
8431
5c1aabc58004
spartan: use newer template syntax everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8357
diff
changeset
|
65 {footer} |