From patchwork Fri Jan 5 12:32:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 5] spartan: make actual changeset entries have backgrounds on /graph From: Anton Shestakov X-Patchwork-Id: 26562 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Fri, 05 Jan 2018 20:32:30 +0800 # HG changeset patch # User Anton Shestakov # Date 1515151325 -28800 # Fri Jan 05 19:22:05 2018 +0800 # Node ID ec07c21e5900ae499b45288dce7a4e9c9697e231 # Parent ae8bdf17326e47e59c7dba86c1ade962f7136ac6 spartan: make actual changeset entries have backgrounds on /graph This patch removes a separate container for backgrounds only and puts backgrounds on changeset elements themselves. This makes it so that JS code doesn't need to create background elements separately anymore. There's a bit of manipulating positions of elements: every changeset entry has a "fg" element that gets a higher z-index than element. This prioritizes text information, so that even if it somehow gets close to the graph drawn on (which has z-index of 5), it'll still be on top of it. This can happen if commit message has a long first line and browser window is narrow, for example. diff --git a/mercurial/templates/spartan/graph.tmpl b/mercurial/templates/spartan/graph.tmpl --- a/mercurial/templates/spartan/graph.tmpl +++ b/mercurial/templates/spartan/graph.tmpl @@ -31,7 +31,6 @@ navigate: {chang
-
      {nodes%graphentry}
    @@ -40,12 +39,6 @@ navigate: {chang var data = {jsdata|json}; var graph = new Graph(); graph.scale({bg_height}); - -graph.vertex = function(x, y, radius, color, parity, cur) \{ - Graph.prototype.vertex.apply(this, arguments); - return ['
  • ', '']; -} - graph.render(data); diff --git a/mercurial/templates/spartan/graphentry.tmpl b/mercurial/templates/spartan/graphentry.tmpl --- a/mercurial/templates/spartan/graphentry.tmpl +++ b/mercurial/templates/spartan/graphentry.tmpl @@ -1,6 +1,8 @@ -
  • - - {desc|strip|firstline|escape|nonempty} - -
    {date|rfc822date}, by {author|person}
    +
  • +
    + + {desc|strip|firstline|escape|nonempty} + +
    {date|rfc822date}, by {author|person}
    +
  • diff --git a/mercurial/templates/static/style.css b/mercurial/templates/static/style.css --- a/mercurial/templates/static/style.css +++ b/mercurial/templates/static/style.css @@ -95,23 +95,21 @@ canvas { margin: 0; } -ul#nodebgs { +ul#graphnodes { list-style: none inside none; padding: 0; margin: 0; - top: -0.7em; -} - -ul#graphnodes li, ul#nodebgs li { - height: 39px; } -ul#graphnodes { +ul#graphnodes li { + height: 37px; + overflow: visible; + padding-top: 2px; +} + +ul#graphnodes li .fg { position: absolute; z-index: 10; - top: -0.85em; - list-style: none inside none; - padding: 0; } ul#graphnodes li .info { diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t +++ b/tests/test-hgweb-commands.t @@ -2060,23 +2060,21 @@ Static files margin: 0; } - ul#nodebgs { + ul#graphnodes { list-style: none inside none; padding: 0; margin: 0; - top: -0.7em; - } - - ul#graphnodes li, ul#nodebgs li { - height: 39px; } - ul#graphnodes { + ul#graphnodes li { + height: 37px; + overflow: visible; + padding-top: 2px; + } + + ul#graphnodes li .fg { position: absolute; z-index: 10; - top: -0.85em; - list-style: none inside none; - padding: 0; } ul#graphnodes li .info { diff --git a/tests/test-hgweb-symrev.t b/tests/test-hgweb-symrev.t --- a/tests/test-hgweb-symrev.t +++ b/tests/test-hgweb-symrev.t @@ -946,9 +946,9 @@ Set up the repo shortlog files navigate: (0) tip - third - second - first + third + second + first navigate: (0) tip $ "$TESTDIR/get-with-headers.py" $LOCALIP:$HGPORT 'tags?style=spartan' | egrep $REVLINKS @@ -1026,8 +1026,8 @@ Set up the repo shortlog files navigate: (0) tip - second - first + second + first navigate: (0) tip $ "$TESTDIR/get-with-headers.py" $LOCALIP:$HGPORT 'file/xyzzy?style=spartan' | egrep $REVLINKS