lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject lucene-solr:master: SOLR-11540: eliminate the need for explicitly definied page-shortname and/or page-permalink attributes in our asciidoc source files
Date Wed, 25 Oct 2017 16:39:33 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 0b3c3000e -> 8a138908c


SOLR-11540: eliminate the need for explicitly definied page-shortname and/or page-permalink
attributes in our asciidoc source files


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8a138908
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8a138908
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8a138908

Branch: refs/heads/master
Commit: 8a138908c58593e2c7d3221d4f8624693afe2f5c
Parents: 0b3c300
Author: Chris Hostetter <hossman@apache.org>
Authored: Wed Oct 25 09:36:41 2017 -0700
Committer: Chris Hostetter <hossman@apache.org>
Committed: Wed Oct 25 09:36:41 2017 -0700

----------------------------------------------------------------------
 solr/solr-ref-guide/src/_includes/head.html     |  2 +-
 solr/solr-ref-guide/src/_includes/sidebar.html  |  6 ++--
 solr/solr-ref-guide/src/_layouts/default.html   |  4 ++-
 solr/solr-ref-guide/src/_layouts/page.html      |  9 +++---
 .../solr-ref-guide/src/_layouts/page_print.html |  2 +-
 .../tools/BuildNavAndPDFBody.java               | 30 +++++++++++++-------
 6 files changed, 33 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/src/_includes/head.html
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_includes/head.html b/solr/solr-ref-guide/src/_includes/head.html
index de0bd44..ac20a72 100755
--- a/solr/solr-ref-guide/src/_includes/head.html
+++ b/solr/solr-ref-guide/src/_includes/head.html
@@ -4,7 +4,7 @@
 <meta name="description" content="{% if page.description %}{{ page.description | strip_html
| strip_newlines | truncate: 160 }}{% endif %}">
 <meta name="keywords" content="{{page.tags}}{% if page.tags %}, {% endif %} {{page.keywords}}">
 {% comment %}NOTE: explicitly using the GUIDE version here (not solr) {% endcomment %}
-<title>{% if page.shortname != "index" %}{{ page.title }} | {% endif %}{{ site.site_title
}} {{ site.solr-attributes.solr-guide-version}}</title>
+<title>{% if page_id != "index" %}{{ page.title }} | {% endif %}{{ site.site_title
}} {{ site.solr-attributes.solr-guide-version}}</title>
 
 <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
 <!--<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">-->

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/src/_includes/sidebar.html
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_includes/sidebar.html b/solr/solr-ref-guide/src/_includes/sidebar.html
index d8c33f6..a87fe37 100755
--- a/solr/solr-ref-guide/src/_includes/sidebar.html
+++ b/solr/solr-ref-guide/src/_includes/sidebar.html
@@ -56,10 +56,10 @@
 
 <!-- set the 'active' class on the current page and ancestors -->
 <!-- this highlights the active parent class in the navgoco sidebar. this is critical
so that the parent expands when you're viewing a page. This must appear below the sidebar
code above. Otherwise, if placed inside customscripts.js, the script runs before the sidebar
code runs and the class never gets inserted.-->
-<script>$("#mysidebar a[href='{{ page.shortname }}.html']").parents('li').toggleClass("active",
true);</script>
+<script>$("#mysidebar a[href='{{ page_id }}.html']").parents('li').toggleClass("active",
true);</script>
 <!-- set the 'current' class on the current page and 'current-tree' on the current page
+ it's ancestors -->
 <!-- this can let us do css highlighting of the current page in the sidebar even if/when
the user clicks around in the sidebar causing other sidebar elements to be 'active' -->
 <script>
-  $("#mysidebar a[href='{{ page.shortname }}.html']").parent('li').toggleClass("current",
true);
-  $("#mysidebar a[href='{{ page.shortname }}.html']").parents('li').toggleClass("current-tree",
true);
+  $("#mysidebar a[href='{{ page_id }}.html']").parent('li').toggleClass("current", true);
+  $("#mysidebar a[href='{{ page_id }}.html']").parents('li').toggleClass("current-tree",
true);
 </script>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/src/_layouts/default.html
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_layouts/default.html b/solr/solr-ref-guide/src/_layouts/default.html
index 357dacf..d553b2a 100755
--- a/solr/solr-ref-guide/src/_layouts/default.html
+++ b/solr/solr-ref-guide/src/_layouts/default.html
@@ -1,4 +1,6 @@
 <!DOCTYPE html>
+{% comment %}NOTE: page_id is also definied in page.html{% endcomment %}
+{% assign page_id = page.url | split: '/' | last | remove: '.html' %}
 <head>
     {% include head.html %}
     <script>
@@ -31,7 +33,7 @@
 
     </script>
 </head>
-<body class="{{ site.solr-attributes.solr-guide-draft-status }}" id="{{ page.shortname
}}">
+<body class="{{ site.solr-attributes.solr-guide-draft-status }}" id="{{ page_id }}">
 {% include topnav.html %}
 <!-- Page Content -->
 <div class="container">

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/src/_layouts/page.html
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_layouts/page.html b/solr/solr-ref-guide/src/_layouts/page.html
index 137cd44..22f88e6 100755
--- a/solr/solr-ref-guide/src/_layouts/page.html
+++ b/solr/solr-ref-guide/src/_layouts/page.html
@@ -1,7 +1,8 @@
 ---
 layout: default
 ---
-
+{% comment %}NOTE: page_id is also definied in default.html{% endcomment %}
+{% assign page_id = page.url | split: '/' | last | remove: '.html' %}
 <div class="post-header">
    <h1 class="post-title-main">{{ page.title }}</h1>
 </div>
@@ -53,7 +54,7 @@ layout: default
     </div>
 
 <!-- Adds nav links on each page -->
-    {% assign scrollnav = site.data.scrollnav[page.shortname] %}
+    {% assign scrollnav = site.data.scrollnav[page_id] %}
     {% if scrollnav %}
     <div class="scrollnav">
       {% if scrollnav.prev %}
@@ -73,10 +74,10 @@ layout: default
 <div style="font-size: 1.6em; color: #d9411e; padding-top: 30px;">Comments on this
Page</div>
 <div class="paragraph"><p>We welcome feedback on Solr documentation. However,
we cannot provide application support via comments. If you need help, please send a message
to the <a href="https://lucene.apache.org/solr/resources.html#community">Solr User mailing
list</a>.</p></div>
 </div>
-<script type="text/javascript" src="https://comments.apache.org/show_comments.lua?site=solr-refguide&style=css/comments.css&page={{
page.shortname }}" async="true">
+<script type="text/javascript" src="https://comments.apache.org/show_comments.lua?site=solr-refguide&style=css/comments.css&page={{
page_id }}" async="true">
 </script>
 <noscript>
-<iframe width="100%" height="500" src="https://comments.apache.org/iframe.lua?site=solr-refguide&style=css/comments.css&page={{
page.shortname }}"></iframe>
+<iframe width="100%" height="500" src="https://comments.apache.org/iframe.lua?site=solr-refguide&style=css/comments.css&page={{
page_id }}"></iframe>
 </noscript>
 
 {% include footer.html %}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/src/_layouts/page_print.html
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/_layouts/page_print.html b/solr/solr-ref-guide/src/_layouts/page_print.html
index 9e04604..f42047d 100755
--- a/solr/solr-ref-guide/src/_layouts/page_print.html
+++ b/solr/solr-ref-guide/src/_layouts/page_print.html
@@ -3,7 +3,7 @@ layout: default_print
 comments: true
 ---
 <div class="post-header">
-    <h1 class="post-title-main" id="{{page.permalink | replace: '/', '' }}">{{ page.title
}}</h1>
+    <h1 class="post-title-main">{{ page.title }}</h1>
 </div>
 
 <div class="post-content">

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8a138908/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java b/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
index b1f0cf3..cb2361a 100644
--- a/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
+++ b/solr/solr-ref-guide/tools/BuildNavAndPDFBody.java
@@ -208,7 +208,7 @@ public class BuildNavAndPDFBody {
   /** Simple struct for modeling the key metadata for dealing with page navigation */
   public static final class Page {
     public final File file;
-    public final String title;
+    public final String title; // NOTE: has html escape codes in it
     public final String shortname;
     public final String permalink;
     public final List<String> kidShortnames;
@@ -218,23 +218,33 @@ public class BuildNavAndPDFBody {
     public final List<Page> kids;
     private final List<Page> mutableKids;
     public Page(File file, DocumentHeader header) {
+      if (! file.getName().endsWith(".adoc")) {
+        throw new RuntimeException(file + " has does not end in '.adoc' - this code can't
be used");
+      }
+      
       this.file = file;
       this.title = header.getDocumentTitle().getMain();
+
+      this.shortname = file.getName().replaceAll("\\.adoc$","");
+      this.permalink = this.shortname + ".html";
       
       // TODO: do error checking if attribute metadata we care about is missing
       Map<String,Object> attrs = header.getAttributes();
-      this.shortname = (String) attrs.get("page-shortname");
-      this.permalink = (String) attrs.get("page-permalink");
 
-      // TODO: SOLR-11531: we should eliminate these attributes and not depend on them in
jekyll, ...
-      // ...but for now at least be sure they are consistent with the filename
-      if (! file.getName().equals(shortname + ".adoc") ) {
-        throw new RuntimeException(file + " has a mismatched shortname: " + shortname);
+      // TODO: SOLR-11541: we should eliminate these attributes
+      // ...but for now at least be sure they are consistent
+      if (attrs.containsKey("page-shortname")) {
+        String explicit = (String) attrs.get("page-shortname");
+        if (! shortname.equals(explicit)) {
+          throw new RuntimeException(file + " ("+shortname+") has a mismatched page-shortname:
" + explicit);
+        }
       }
-      if (! permalink.equals(shortname + ".html") ) {
-        throw new RuntimeException(file + " has a mismatched permalink: " + permalink);
+      if (attrs.containsKey("page-permalink")) {
+        String explicit = (String) attrs.get("page-permalink");
+        if (! permalink.equals(explicit)) {
+          throw new RuntimeException(file + "("+permalink+") has a mismatched permalink:
" + explicit);
+        }
       }
-
       
       if (attrs.containsKey("page-children")) {
         String kidsString = ((String) attrs.get("page-children")).trim();


Mime
View raw message