From d9e740456bea7d4f17145db8fbccf7ccbbdbf3b3 Mon Sep 17 00:00:00 2001
From: Antoine Lambert <antoine.lambert@inria.fr>
Date: Wed, 13 Dec 2017 17:18:05 +0100
Subject: [PATCH] browse: Miscellaneous UI improvements

---
 swh/web/static/css/style.css                  |  9 +++++-
 swh/web/templates/content.html                |  7 ++++
 .../templates/includes/origins-search.html    | 10 ++----
 swh/web/templates/layout.html                 | 32 +++++++------------
 swh/web/templates/origin.html                 |  2 --
 swh/web/tests/browse/views/test_origin.py     |  1 -
 6 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/swh/web/static/css/style.css b/swh/web/static/css/style.css
index 21335844b..0be109da7 100644
--- a/swh/web/static/css/style.css
+++ b/swh/web/static/css/style.css
@@ -19,7 +19,6 @@ body {
     font-size: 1.7rem;
     line-height: 1.5;
     color: rgba(0, 0, 0, 0.55);
-    padding-top: 80px;  /* avoid fixed bootstrap navbar covers content */
     padding-bottom: 120px;
     min-height: 100%;
     margin: 0;
@@ -341,6 +340,12 @@ bread-crumbs ul {
     margin-bottom: 1px;
 }
 
+.swh-browse-bread-crumbs li:nth-child(n+2)::before {
+    content: "";
+    display: inline-block;
+    margin: 0 2px;
+}
+
 .swh-metadata-table-row {
     border-top: 1px solid #ddd !important;
 }
@@ -372,6 +377,8 @@ td.hljs-ln-code {
     color: #6C6C6C;
     background-color: #EAEAEA;
     border-color: #EAEAEA;
+    background-image: linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);
+    background-repeat: repeat-x;
 }
 
 .btn-swh:hover,
diff --git a/swh/web/templates/content.html b/swh/web/templates/content.html
index 193871f13..ce138d998 100644
--- a/swh/web/templates/content.html
+++ b/swh/web/templates/content.html
@@ -25,6 +25,10 @@
     return line_td;
   }
 
+  function removeHash () {
+    history.pushState("", document.title, window.location.pathname + window.location.search);
+  }
+
   // function to reset highlighting
   function reset_highlighted_lines() {
     first_hl_line = null;
@@ -86,6 +90,9 @@
           window.location.hash = '#L' + line;
           scrollToLine(evt.target);
         }
+      } else {
+        reset_highlighted_lines();
+        removeHash();
       }
     });
 
diff --git a/swh/web/templates/includes/origins-search.html b/swh/web/templates/includes/origins-search.html
index b98acd96c..219b4a0da 100644
--- a/swh/web/templates/includes/origins-search.html
+++ b/swh/web/templates/includes/origins-search.html
@@ -23,10 +23,8 @@
       <table class="table" id="origin-search-results">
         <thead>
           <tr>
-            <th>Origin id</th>
             <th>Origin type</th>
-            <th>Origin url</th>
-            <th></th>
+            <th>Origin browse url</th>
           </tr>
         </thead>
         <tbody></tbody>
@@ -53,11 +51,9 @@
     var table = $("#origin-search-results tbody");
     $.each(data, function(idx, elem){
       var tableRow = '<tr>';
-      tableRow += '<td>' + elem.id + '</td>';
       tableRow += '<td>' + elem.type + '</td>';
-      tableRow += '<td><a href="' + elem.url + '">' + elem.url + '</a></td>';
       var browse_url = origin_browse_url.replace('type', elem.type).replace('origin_url', elem.url);
-      tableRow += '<td><a href="' + browse_url + '">Browse</a></td>';
+      tableRow += '<td><a href="' + browse_url + '">' + browse_url + '</a></td>';
       tableRow += '</tr>';
       table.append(tableRow);
     });
@@ -114,7 +110,7 @@
     origin_patterns = patterns;
     var patterns_array = patterns.trim().replace(/\s+/g,' ').split(' ');
     var patterns_permut = []
-    heapsPermute(patterns_array, (p) => {patterns_permut.push(p.join('.*'));})
+    heapsPermute(patterns_array, function(p) {patterns_permut.push(p.join('.*'));})
     var regex = patterns_permut.join('|');
     var search_url = origins_search_url.replace('url_regexp', regex)
                                        .replace('limit_val', limit)
diff --git a/swh/web/templates/layout.html b/swh/web/templates/layout.html
index 525f39633..645c499ab 100644
--- a/swh/web/templates/layout.html
+++ b/swh/web/templates/layout.html
@@ -34,27 +34,19 @@
   </head>
   <body
     <a id="top"></a>
-    <div class="jumbotron">
-      <nav class="navbar navbar-default" id="swh-navbar-collapse">
-        <div class="navbar-header">
-          <button type="button" class="navbar-toggle collapsed"
-                  data-toggle="collapse" data-target="#swh-navbar-collapse" aria-expanded="false"> <!-- screen-reader -->
-	    <span class="sr-only">Toggle navigation menu</span>
-            <span class="icon-bar"></span>
-            <span class="icon-bar"></span>
-            <span class="icon-bar"></span>
-          </button>
-          <div class="logo">
-            <a class="navbar-brand" href="{% url 'swh-web-homepage' %}"> <!-- logo -->
-              <img alt="SWH Archive" src="{% static 'img/swh-logo-archive.png' %}" class="swh-logo" />
-            </a>
-            <a class="navbar-brand sitename" href="{% url 'swh-web-homepage' %}">
-              <span class="first-word">Software</span> <span class="second-word">Heritage</span>
-            </a>
-          </div>
+    <nav class="navbar navbar-default navbar-static-top" id="swh-navbar-collapse">
+      <div class="navbar-header">
+        <div class="logo">
+          <a class="navbar-brand" href="{% url 'swh-web-homepage' %}"> <!-- logo -->
+            <img alt="SWH Archive" src="{% static 'img/swh-logo-archive.png' %}" class="swh-logo" />
+          </a>
+          <a class="navbar-brand sitename" href="{% url 'swh-web-homepage' %}">
+            <span class="first-word">Software</span> <span class="second-word">Heritage</span>
+          </a>
         </div>
-      </nav>
-    </div>
+      </div>
+    </nav>
+
     <div class="container">
       <div class="container">
       </div>
diff --git a/swh/web/templates/origin.html b/swh/web/templates/origin.html
index 7931750ae..2b510978a 100644
--- a/swh/web/templates/origin.html
+++ b/swh/web/templates/origin.html
@@ -20,7 +20,6 @@
     <table class="table">
       <thead>
         <tr>
-          <th>Visit id</th>
           <th>Visit date</th>
           <th>Visit status</th>
           <th>Tree</th>
@@ -29,7 +28,6 @@
       <tbody>
         {% for v in visits %}
         <tr class="swh-origin-visit">
-          <td>{{ v.visit }}</td>
           <td>{{ v.fmt_date }}</td>
           <td>{{ v.status }}</td>
           <td><a href="{{ v.browse_url }}">{{ v.browse_url }}</a></td>
diff --git a/swh/web/tests/browse/views/test_origin.py b/swh/web/tests/browse/views/test_origin.py
index 6575cb49a..7b489e9e4 100644
--- a/swh/web/tests/browse/views/test_origin.py
+++ b/swh/web/tests/browse/views/test_origin.py
@@ -55,7 +55,6 @@ class SwhBrowseOriginTest(SWHWebTestBase, TestCase):
 
         self.assertEquals(resp.status_code, 200)
         self.assertTemplateUsed('origin.html')
-        self.assertContains(resp, '<td>%s</td>' % origin_info_test_data['id'])
         self.assertContains(resp, '<pre>%s</pre>' % origin_info_test_data['type'])
         self.assertContains(resp, '<pre><a href="%s">%s</a></pre>' %
                                   (origin_info_test_data['url'],
-- 
GitLab