[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

debsources: [PATCH] Retain line context on 404s by appending the hash for specific links



Hi,

Attached is the following:

  commit a0a47c965d364fb41d1b0fde2480252a9c328479
  Author: Chris Lamb <lamby@debian.org>
  Date:   Sun Aug 21 11:39:25 2016 +0100
  
      Retain line context on 404s by appending the hash for specific links
      
      Signed-off-by: Chris Lamb <lamby@debian.org>
  
   debsources/app/sources/templates/sources/404_suggestions.html | 2 +-
   debsources/app/templates/footer.inc.html                      | 8 ++++++++
   2 files changed, 9 insertions(+), 1 deletion(-)


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org / chris-lamb.co.uk
       `-
From a0a47c965d364fb41d1b0fde2480252a9c328479 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Sun, 21 Aug 2016 11:39:25 +0100
Subject: [PATCH] Retain line context on 404s by appending the hash for
 specific links

Signed-off-by: Chris Lamb <lamby@debian.org>
---
 debsources/app/sources/templates/sources/404_suggestions.html | 2 +-
 debsources/app/templates/footer.inc.html                      | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/debsources/app/sources/templates/sources/404_suggestions.html b/debsources/app/sources/templates/sources/404_suggestions.html
index bf4609e..f1127f7 100644
--- a/debsources/app/sources/templates/sources/404_suggestions.html
+++ b/debsources/app/sources/templates/sources/404_suggestions.html
@@ -11,7 +11,7 @@ The file you are looking for might exist in one of the following
 versions:
 <ul>
 {% for s in suggestions %}
-  <li><a href="{{ url_for('.source', path_to=s) }}">{{ s }}</a></li>
+  <li><a href="{{ url_for('.source', path_to=s) }}" class="js-append-window-location-hash">{{ s }}</a></li>
 {% endfor %}
 </ul>
 </p>
diff --git a/debsources/app/templates/footer.inc.html b/debsources/app/templates/footer.inc.html
index 29d1d14..8636672 100644
--- a/debsources/app/templates/footer.inc.html
+++ b/debsources/app/templates/footer.inc.html
@@ -32,3 +32,11 @@
   Last update: {{ last_update }}.
 </p>
 </div>
+
+<script type="text/javascript">
+var elems = document.querySelectorAll('.js-append-window-location-hash');
+
+for (var i = 0; i < elems.length; ++i) {
+  elems[i].setAttribute('href', elems[i].getAttribute('href') + window.location.hash);
+}
+</script>
-- 
2.9.3


Reply to: