[commit: haddock] ghc-head, ghc-head1, master, wip/revert-ttg-2017-11-20, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13: QuickNav: Make docbase configurable (eb88b01)

git at git.haskell.org git at git.haskell.org
Mon Nov 20 21:10:38 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branches: ghc-head,ghc-head1,master,wip/revert-ttg-2017-11-20,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13
Link       : http://git.haskell.org/haddock.git/commitdiff/eb88b014c33e5a3d36e7b44885940f70289c00bf

>---------------------------------------------------------------

commit eb88b014c33e5a3d36e7b44885940f70289c00bf
Author: Alexander Biehl <abiehl at novomind.com>
Date:   Tue Aug 29 11:40:19 2017 +0200

    QuickNav: Make docbase configurable


>---------------------------------------------------------------

eb88b014c33e5a3d36e7b44885940f70289c00bf
 haddock-api/resources/html/index.js       | 14 ++++++++++++--
 haddock-api/src/Haddock/Backends/Xhtml.hs |  7 ++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/haddock-api/resources/html/index.js b/haddock-api/resources/html/index.js
index 6d5b2bf..109a106 100644
--- a/haddock-api/resources/html/index.js
+++ b/haddock-api/resources/html/index.js
@@ -1,3 +1,7 @@
+quickNav = (function() {
+
+var baseUrl;
+
 // alias preact's hyperscript reviver since it's referenced a lot:
 var h = preact.h;
 
@@ -256,7 +260,7 @@ var App = createClass({
 
     var renderItem = function(item) {
       return h('li', { class: 'search-result' },
-        this.navigationLink(item.link, {},
+        this.navigationLink(baseUrl + "/" + item.link, {},
           h(DocHtml, { html: item.display_html })
         )
       );
@@ -379,4 +383,10 @@ var NoResultsMsg = function(props) {
   return messages[(props.searchString || 'a').charCodeAt(0) % messages.length];
 };
 
-preact.render(h(App), document.body);
+return {
+  init: function(docBaseUrl) {
+    baseUrl = docBaseUrl || "";
+    preact.render(h(App), document.body);
+  }
+}
+})();
diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs
index 8046992..f85ee6b 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml.hs
@@ -194,7 +194,12 @@ bodyHtml doctitle iface
 
     script ! [src jsPreactFile, thetype "text/javascript"] << noHtml,
     script ! [src jsFuseFile, thetype "text/javascript"] << noHtml,
-    script ! [src jsIndexFile, thetype "text/javascript"] << noHtml
+    script ! [src jsIndexFile, thetype "text/javascript"] << noHtml,
+    script ! [thetype "text/javascript"]
+        -- NB: Within XHTML, the content of script tags needs to be
+        -- a <![CDATA[ section.
+      << primHtml
+          "//<![CDATA[\nquickNav.init();\n//]]>\n"
     ]
 
 moduleInfo :: Interface -> Html



More information about the ghc-commits mailing list