Patchwork hgweb: use css for stripey background in coal

login
register
mail settings
Submitter Anton Shestakov
Date June 25, 2015, 12:57 p.m.
Message ID <b76281b5f7a828d9403d.1435237043@neuro>
Download mbox | patch
Permalink /patch/9775/
State Accepted
Headers show

Comments

Anton Shestakov - June 25, 2015, 12:57 p.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1435235256 -28800
#      Thu Jun 25 20:27:36 2015 +0800
# Node ID b76281b5f7a828d9403d96a5e579eaafc3953492
# Parent  ff5172c830022b64cc5bd1bae36b2276e9dc6e5d
hgweb: use css for stripey background in coal

Since "b8ecc3830c89 or 25dae11bb044::c229a5e7511e" paper style used css for
stripes in background for browsing files, for listing branches/tags/bookmarks,
and so on.

Since coal borrows many paper templates (e.g. shortlogentry.tmpl), it actually
tried to do the same, but it didn't have the needed css classes. You can
compare https://selenic.com/hg?style=coal with
https://selenic.com/hg?style=paper and see how log view in coal style has plain
white background, unlike the one in paper style. This wasn't intended.

Let's copy css classes directly from style-paper.css and remove parity classes
from elements that don't need them anymore. This makes plain white background
have stripes again and makes coal/map even more similar to paper/map (which can
ease porting changes or %including paper/map in future).
Augie Fackler - June 25, 2015, 8:14 p.m.
On Thu, Jun 25, 2015 at 08:57:23PM +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1435235256 -28800
> #      Thu Jun 25 20:27:36 2015 +0800
> # Node ID b76281b5f7a828d9403d96a5e579eaafc3953492
> # Parent  ff5172c830022b64cc5bd1bae36b2276e9dc6e5d
> hgweb: use css for stripey background in coal

Queued, thanks.

>
> Since "b8ecc3830c89 or 25dae11bb044::c229a5e7511e" paper style used css for
> stripes in background for browsing files, for listing branches/tags/bookmarks,
> and so on.
>
> Since coal borrows many paper templates (e.g. shortlogentry.tmpl), it actually
> tried to do the same, but it didn't have the needed css classes. You can
> compare https://selenic.com/hg?style=coal with
> https://selenic.com/hg?style=paper and see how log view in coal style has plain
> white background, unlike the one in paper style. This wasn't intended.
>
> Let's copy css classes directly from style-paper.css and remove parity classes
> from elements that don't need them anymore. This makes plain white background
> have stripes again and makes coal/map even more similar to paper/map (which can
> ease porting changes or %including paper/map in future).
>
> diff --git a/mercurial/templates/coal/map b/mercurial/templates/coal/map
> --- a/mercurial/templates/coal/map
> +++ b/mercurial/templates/coal/map
> @@ -43,7 +43,7 @@ navgraph = '{before%navgraphentry}{after
>  filenav = '{before%filenaventry}{after%filenaventry}'
>
>  direntry = '
> -  <tr class="fileline parity{parity}">
> +  <tr class="fileline">
>      <td class="name">
>        <a href="{url|urlescape}file/{symrev}{path|urlescape}{sessionvars%urlparameter}">
>          <img src="{staticurl|urlescape}coal-folder.png" alt="dir."/> {basename|escape}/
> @@ -57,7 +57,7 @@ direntry = '
>    </tr>'
>
>  fileentry = '
> -  <tr class="fileline parity{parity}">
> +  <tr class="fileline">
>      <td class="filename">
>        <a href="{url|urlescape}file/{symrev}/{file|urlescape}{sessionvars%urlparameter}">
>          <img src="{staticurl|urlescape}coal-file.png" alt="file"/> {basename|escape}
> @@ -73,11 +73,11 @@ filediff = ../paper/filediff.tmpl
>  filecomparison = ../paper/filecomparison.tmpl
>  filelog = ../paper/filelog.tmpl
>  fileline = '
> -  <div class="parity{parity} source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
> +  <div class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
>  filelogentry = ../paper/filelogentry.tmpl
>
>  annotateline = '
> -  <tr class="parity{parity}">
> +  <tr>
>      <td class="annotate">
>        <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}"
>           title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
> @@ -85,7 +85,7 @@ annotateline = '
>      <td class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</td>
>    </tr>'
>
> -diffblock = '<div class="source bottomline parity{parity}"><pre>{lines}</pre></div>'
> +diffblock = '<div class="source bottomline"><pre>{lines}</pre></div>'
>  difflineplus = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="plusline">{line|escape}</span>'
>  difflineminus = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="minusline">{line|escape}</span>'
>  difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>'
> @@ -156,7 +156,7 @@ fileannotatechild = '
>    </tr>'
>  tags = ../paper/tags.tmpl
>  tagentry = '
> -  <tr class="tagEntry parity{parity}">
> +  <tr class="tagEntry">
>      <td>
>        <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
>          {tag|escape}
> @@ -168,7 +168,7 @@ tagentry = '
>    </tr>'
>  bookmarks = ../paper/bookmarks.tmpl
>  bookmarkentry = '
> -  <tr class="tagEntry parity{parity}">
> +  <tr class="tagEntry">
>      <td>
>        <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
>          {bookmark|escape}
> @@ -180,7 +180,7 @@ bookmarkentry = '
>    </tr>'
>  branches = ../paper/branches.tmpl
>  branchentry = '
> -  <tr class="tagEntry parity{parity}">
> +  <tr class="tagEntry">
>      <td>
>        <a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}" class="{status}">
>          {branch|escape}
> @@ -219,7 +219,7 @@ filelogchild = '
>    </tr>'
>
>  indexentry = '
> -  <tr class="parity{parity}">
> +  <tr>
>      <td><a href="{url|urlescape}{sessionvars%urlparameter}">{name|escape}</a></td>
>      <td>{description}</td>
>      <td>{contact|obfuscate}</td>
> diff --git a/mercurial/templates/static/style-coal.css b/mercurial/templates/static/style-coal.css
> --- a/mercurial/templates/static/style-coal.css
> +++ b/mercurial/templates/static/style-coal.css
> @@ -97,8 +97,12 @@ a { text-decoration:none; }
>  .age { white-space:nowrap; }
>  .date { white-space:nowrap; }
>  .indexlinks { white-space:nowrap; }
> -.parity0 { background-color: #f0f0f0; }
> -.parity1 { background-color: white; }
> +.parity0,
> +.stripes4 > :nth-child(4n+1),
> +.stripes2 > :nth-child(2n+1) { background-color: #f0f0f0; }
> +.parity1,
> +.stripes4 > :nth-child(4n+3),
> +.stripes2 > :nth-child(2n+2) { background-color: white; }
>  .plusline { color: green; }
>  .minusline { color: #dc143c; } /* crimson */
>  .atline { color: purple; }
> diff --git a/tests/test-hgweb-descend-empties.t b/tests/test-hgweb-descend-empties.t
> --- a/tests/test-hgweb-descend-empties.t
> +++ b/tests/test-hgweb-descend-empties.t
> @@ -217,7 +217,7 @@ manifest with descending (coal)
>      <td class="permissions">drwxr-xr-x</td>
>    </tr>
>
> -  <tr class="fileline parity1">
> +  <tr class="fileline">
>    <td class="name">
>    <a href="/file/tip/a1?style=coal">
>    <img src="/static/coal-folder.png" alt="dir."/> a1/
> @@ -229,7 +229,7 @@ manifest with descending (coal)
>    <td class="size"></td>
>    <td class="permissions">drwxr-xr-x</td>
>    </tr>
> -  <tr class="fileline parity0">
> +  <tr class="fileline">
>    <td class="name">
>    <a href="/file/tip/b1?style=coal">
>    <img src="/static/coal-folder.png" alt="dir."/> b1/
> @@ -241,7 +241,7 @@ manifest with descending (coal)
>    <td class="size"></td>
>    <td class="permissions">drwxr-xr-x</td>
>    </tr>
> -  <tr class="fileline parity1">
> +  <tr class="fileline">
>    <td class="name">
>    <a href="/file/tip/d1?style=coal">
>    <img src="/static/coal-folder.png" alt="dir."/> d1/
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/templates/coal/map b/mercurial/templates/coal/map
--- a/mercurial/templates/coal/map
+++ b/mercurial/templates/coal/map
@@ -43,7 +43,7 @@  navgraph = '{before%navgraphentry}{after
 filenav = '{before%filenaventry}{after%filenaventry}'
 
 direntry = '
-  <tr class="fileline parity{parity}">
+  <tr class="fileline">
     <td class="name">
       <a href="{url|urlescape}file/{symrev}{path|urlescape}{sessionvars%urlparameter}">
         <img src="{staticurl|urlescape}coal-folder.png" alt="dir."/> {basename|escape}/
@@ -57,7 +57,7 @@  direntry = '
   </tr>'
 
 fileentry = '
-  <tr class="fileline parity{parity}">
+  <tr class="fileline">
     <td class="filename">
       <a href="{url|urlescape}file/{symrev}/{file|urlescape}{sessionvars%urlparameter}">
         <img src="{staticurl|urlescape}coal-file.png" alt="file"/> {basename|escape}
@@ -73,11 +73,11 @@  filediff = ../paper/filediff.tmpl
 filecomparison = ../paper/filecomparison.tmpl
 filelog = ../paper/filelog.tmpl
 fileline = '
-  <div class="parity{parity} source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
+  <div class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
 filelogentry = ../paper/filelogentry.tmpl
 
 annotateline = '
-  <tr class="parity{parity}">
+  <tr>
     <td class="annotate">
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
@@ -85,7 +85,7 @@  annotateline = '
     <td class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</td>
   </tr>'
 
-diffblock = '<div class="source bottomline parity{parity}"><pre>{lines}</pre></div>'
+diffblock = '<div class="source bottomline"><pre>{lines}</pre></div>'
 difflineplus = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="plusline">{line|escape}</span>'
 difflineminus = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="minusline">{line|escape}</span>'
 difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>'
@@ -156,7 +156,7 @@  fileannotatechild = '
   </tr>'
 tags = ../paper/tags.tmpl
 tagentry = '
-  <tr class="tagEntry parity{parity}">
+  <tr class="tagEntry">
     <td>
       <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
         {tag|escape}
@@ -168,7 +168,7 @@  tagentry = '
   </tr>'
 bookmarks = ../paper/bookmarks.tmpl
 bookmarkentry = '
-  <tr class="tagEntry parity{parity}">
+  <tr class="tagEntry">
     <td>
       <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
         {bookmark|escape}
@@ -180,7 +180,7 @@  bookmarkentry = '
   </tr>'
 branches = ../paper/branches.tmpl
 branchentry = '
-  <tr class="tagEntry parity{parity}">
+  <tr class="tagEntry">
     <td>
       <a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}" class="{status}">
         {branch|escape}
@@ -219,7 +219,7 @@  filelogchild = '
   </tr>'
 
 indexentry = '
-  <tr class="parity{parity}">
+  <tr>
     <td><a href="{url|urlescape}{sessionvars%urlparameter}">{name|escape}</a></td>
     <td>{description}</td>
     <td>{contact|obfuscate}</td>
diff --git a/mercurial/templates/static/style-coal.css b/mercurial/templates/static/style-coal.css
--- a/mercurial/templates/static/style-coal.css
+++ b/mercurial/templates/static/style-coal.css
@@ -97,8 +97,12 @@  a { text-decoration:none; }
 .age { white-space:nowrap; }
 .date { white-space:nowrap; }
 .indexlinks { white-space:nowrap; }
-.parity0 { background-color: #f0f0f0; }
-.parity1 { background-color: white; }
+.parity0,
+.stripes4 > :nth-child(4n+1),
+.stripes2 > :nth-child(2n+1) { background-color: #f0f0f0; }
+.parity1,
+.stripes4 > :nth-child(4n+3),
+.stripes2 > :nth-child(2n+2) { background-color: white; }
 .plusline { color: green; }
 .minusline { color: #dc143c; } /* crimson */
 .atline { color: purple; }
diff --git a/tests/test-hgweb-descend-empties.t b/tests/test-hgweb-descend-empties.t
--- a/tests/test-hgweb-descend-empties.t
+++ b/tests/test-hgweb-descend-empties.t
@@ -217,7 +217,7 @@  manifest with descending (coal)
     <td class="permissions">drwxr-xr-x</td>
   </tr>
   
-  <tr class="fileline parity1">
+  <tr class="fileline">
   <td class="name">
   <a href="/file/tip/a1?style=coal">
   <img src="/static/coal-folder.png" alt="dir."/> a1/
@@ -229,7 +229,7 @@  manifest with descending (coal)
   <td class="size"></td>
   <td class="permissions">drwxr-xr-x</td>
   </tr>
-  <tr class="fileline parity0">
+  <tr class="fileline">
   <td class="name">
   <a href="/file/tip/b1?style=coal">
   <img src="/static/coal-folder.png" alt="dir."/> b1/
@@ -241,7 +241,7 @@  manifest with descending (coal)
   <td class="size"></td>
   <td class="permissions">drwxr-xr-x</td>
   </tr>
-  <tr class="fileline parity1">
+  <tr class="fileline">
   <td class="name">
   <a href="/file/tip/d1?style=coal">
   <img src="/static/coal-folder.png" alt="dir."/> d1/