You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bm...@apache.org on 2021/10/09 11:30:53 UTC

[shiro-site] branch jbake updated: fix 'edit on github' links.

This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch jbake
in repository https://gitbox.apache.org/repos/asf/shiro-site.git


The following commit(s) were added to refs/heads/jbake by this push:
     new b029ff2  fix 'edit on github' links.
     new ace488a  Merge pull request #110 from bmarwell/jbake
b029ff2 is described below

commit b029ff2f8150e547af7efff8f5083a97d922c9ae
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Sat Oct 9 13:31:51 2021 +0200

    fix 'edit on github' links.
---
 jbake/assets/js/shiro.js   | 7 +------
 jbake/jbake.properties     | 4 ++++
 jbake/templates/footer.ftl | 8 +++++++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/jbake/assets/js/shiro.js b/jbake/assets/js/shiro.js
index 3de1d33c..054a7f5 100644
--- a/jbake/assets/js/shiro.js
+++ b/jbake/assets/js/shiro.js
@@ -1,15 +1,10 @@
 function addPageEditLink() {
 
-    var ghRepo = "apache/shiro-site";
-    var ghRelHref = "https://github.com/" + ghRepo + "/edit/main/";
-
     var ghEditPageElement = document.getElementById('ghEditPage');
     var editThisPageElement = document.getElementById('editThisPage');
 
     if (ghEditPageElement && ghEditPageElement.value && editThisPageElement) {
-        var relGHPage = ghEditPageElement.value;
-
-        var ghEditHref = ghRelHref + relGHPage;
+        var ghEditHref = ghEditPageElement.value;
         let editPageLink = document.createElement('a');
         editPageLink.setAttribute('href', ghEditHref);
         editPageLink.setAttribute('rel', 'nofollow');
diff --git a/jbake/jbake.properties b/jbake/jbake.properties
index e2e1739..a39e0d6 100644
--- a/jbake/jbake.properties
+++ b/jbake/jbake.properties
@@ -16,3 +16,7 @@ template.lend_a_hand.file=lend_a_hand.ftl
 
 db.store=plocal
 db.path=cache
+
+# set this to the "browse code" path without a commit id, e.g.
+# https://github.com/apache/shiro-site/tree/{branch}/{optional_subdirs}/content
+github.editlink.baseurl=https://github.com/apache/shiro-site/edit/jbake/jbake/content
diff --git a/jbake/templates/footer.ftl b/jbake/templates/footer.ftl
index ab964e2..93ee1c9 100644
--- a/jbake/templates/footer.ftl
+++ b/jbake/templates/footer.ftl
@@ -19,7 +19,13 @@
         </div>
 
         <div class="d-flex justify-content-end col-md-4" id="editThisPage">
-          <#if (content.file)??><input type="hidden" id="ghEditPage" value="${content.sourceuri}"/></#if>
+          <#if (content.sourceuri)??>
+            <#assign
+              extension="${content.file[content.file?last_index_of('.')..]}"
+              sourcefile="${content.sourceuri?replace('.html', extension)}"
+            />
+          <input type="hidden" id="ghEditPage" value="${config.github_editlink_baseurl}/${sourcefile}"/>
+          </#if>
         </div>
 
         <div class="d-flex col-md-2 justify-content-end" style="position: relative">