git » git-arr » commit d7f0e4a

views: Change the "repository" line into "git clone"

author Alberto Bertogli
2017-08-27 15:11:47 UTC
committer Alberto Bertogli
2017-08-27 15:16:56 UTC
parent 56b0b34930dd3a0ec90035ea2db381fda63a24f8

views: Change the "repository" line into "git clone"

We display the location of the repository, but the entire row is not
convenient for copy-pasting.

This patch changes the wording to "git clone" so the entire row can be
copied and pasted into a terminal.

There's a trick, because if we just changed the wording to:

  <td>git clone</td> <td>https://example.com/repo</td>

that would get copied as:

  git clone\thttps://example.com/repo

which does not work well when pasted into a terminal (as the \t gets
"eaten" in most cases).

So this patch changes the HTML to have a space after "clone":

  <td>git clone </td> <td>https://example.com/repo</td>

and the CSS to preserve the space, so the following gets copied:

  git clone \thttps://example.com/repo

which works when pasting on a terminal.

static/git-arr.css +4 -0
views/summary.html +1 -1

diff --git a/static/git-arr.css b/static/git-arr.css
index a4ecc02..b0f2de5 100644
--- a/static/git-arr.css
+++ b/static/git-arr.css
@@ -205,6 +205,10 @@ table.repo_info tr:hover {
 }
 table.repo_info td.category {
     font-weight: bold;
+    /* So we can copy-paste rows and preserve spaces, useful for the row:
+     *   git clone | url
+     */
+    white-space: pre-wrap;
 }
 table.repo_info td {
     vertical-align: top;
diff --git a/views/summary.html b/views/summary.html
index 5038ef5..d30e895 100644
--- a/views/summary.html
+++ b/views/summary.html
@@ -25,7 +25,7 @@
 % end
 % if repo.info.git_url:
     <tr>
-        <td class="category">repository</td>
+        <td class="category">git clone </td>
         <td>{{! '<br/>'.join(repo.info.git_url.split())}}</td>
     </tr>
 % end