From b2ac8298bf29db6c6e0abf6997add812ea690de5 Mon Sep 17 00:00:00 2001 From: matcornic Date: Thu, 27 Jul 2017 21:42:07 +0200 Subject: [PATCH] feat: support of Hugo 0.22+ #51 #48 #11 #50 --- archetypes/chapter.md | 13 +-- archetypes/default.md | 8 +- i18n/en.toml | 32 ++++++ i18n/fr.toml | 32 ++++++ i18n/nb.toml | 32 ++++++ layouts/404.html | 21 ++-- layouts/_default/list.html | 38 +++++-- layouts/_default/single.html | 10 ++ layouts/index.html | 80 +++++--------- layouts/index.json | 12 +++ layouts/partials/footer.html | 110 ++++++++++--------- layouts/partials/header.html | 99 +++++++++--------- layouts/partials/menu.html | 157 +++++++++++++++------------- layouts/partials/pagination.html | 9 ++ layouts/partials/search.html | 10 +- layouts/shortcodes/attachments.html | 33 ++++++ layouts/shortcodes/relref.html | 12 +++ static/css/hugo-theme.css | 1 - static/css/theme.css | 3 + static/js/hugo-learn.js | 10 +- static/js/learn.js | 142 +++++++------------------ static/js/search.js | 21 ++-- static/json/search.json | 1 - 23 files changed, 498 insertions(+), 388 deletions(-) create mode 100644 i18n/en.toml create mode 100644 i18n/fr.toml create mode 100644 i18n/nb.toml create mode 100644 layouts/index.json create mode 100644 layouts/partials/pagination.html create mode 100644 layouts/shortcodes/attachments.html create mode 100644 layouts/shortcodes/relref.html delete mode 100644 static/json/search.json diff --git a/archetypes/chapter.md b/archetypes/chapter.md index 1d975216f1..36bd987874 100644 --- a/archetypes/chapter.md +++ b/archetypes/chapter.md @@ -1,11 +1,12 @@ --- -title: "Some Chapter title" -weight: 0 -icon: "X. " # HTML code as prefix in the menu +title: "{{ replace .TranslationBaseName "-" " " | title }}" +date: {{ .Date }} +weight: 5 +pre: "X. " # HTML code as prefix in the menu +draft: true --- ### Chapter X -# Some Chapter title - -Lorem ipsum +Lorem Ipsum. +Notice `draft` is set to true. \ No newline at end of file diff --git a/archetypes/default.md b/archetypes/default.md index e47481e95a..7d8f53cf8f 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -1,7 +1,9 @@ --- -title: "Some Title" +title: "{{ replace .TranslationBaseName "-" " " | title }}" +date: {{ .Date }} weight: 5 -toc: true +draft: true --- -Lorem Ipsum +Lorem Ipsum. +Notice `draft` is set to true. \ No newline at end of file diff --git a/i18n/en.toml b/i18n/en.toml new file mode 100644 index 0000000000..fa8f514b92 --- /dev/null +++ b/i18n/en.toml @@ -0,0 +1,32 @@ +[Search-placeholder] +other = "Search..." + +[Clear-History] +other = "Clear History" + +[Page] +other = "Page" + +[Next-Pages] +other = "Next Pages" + +[Previous-Pages] +other = "Previous Pages" + +[pagination-on] +other = "on" + +[Attachments-label] +other = "Attachments" + +[title-404] +other = "Error" + +[message-404] +other = "Woops. Looks like this page doesn't exist." + +[Go-to-homepage] +other = "Go to homepage" + +[Edit-this-page] +other = "Edit page" \ No newline at end of file diff --git a/i18n/fr.toml b/i18n/fr.toml new file mode 100644 index 0000000000..9a3839119e --- /dev/null +++ b/i18n/fr.toml @@ -0,0 +1,32 @@ +[Search-placeholder] +other = "Rechercher..." + +[Clear-History] +other = "Supprimer l'historique" + +[Page] +other = "Page" + +[Next-Pages] +other = "Pages suivantes" + +[Previous-Pages] +other = "Pages précédentes" + +[pagination-on] +other = "sur" + +[Attachments-label] +other = "Documents joints" + +[title-404] +other = "Erreur" + +[message-404] +other = "Oups. On dirait que cette page n'existe pas " + +[Go-to-homepage] +other = "Vers la page d'accueil" + +[Edit-this-page] +other = "Modifier la page" \ No newline at end of file diff --git a/i18n/nb.toml b/i18n/nb.toml new file mode 100644 index 0000000000..e9b7b60930 --- /dev/null +++ b/i18n/nb.toml @@ -0,0 +1,32 @@ +[Search-placeholder] +other = "Søk..." + +[Clear-History] +other = "Fjern historikk" + +[Page] +other = "Side" + +[Next-Pages] +other = "Neste" + +[Previous-Pages] +other = "Forrige" + +[pagination-on] +other = "av" + +[Attachments-label] +other = "Vedlegg" + +[title-404] +other = "Feil" + +[message-404] +other = "Ups... Ser ikke ut som denne siden eksisterer." + +[Go-to-homepage] +other = "Gå til hovedsiden" + +[Edit-this-page] +other = "Editer" \ No newline at end of file diff --git a/layouts/404.html b/layouts/404.html index ba0ba4c5f9..18de1d167b 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -5,13 +5,14 @@ {{ partial "meta.html" . }} {{ partial "favicon.html" . }} {{ .Scratch.Add "title" "" }}{{ if eq .Site.Data.titles .Title }}{{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }}{{ else }}{{ .Scratch.Set "title" .Title}}{{end}} {{ .Scratch.Get "title" }} {{ partial "style.html" . }} - - - - - - - + + + + + + + + - - - - -
-
- -
-

Customize your own home page

-

- The site is working, change the URL in your browser to get to any custom page. But, don't forget to overwrite this index.html with your own. You typically have 3 choices : -

-
    -
  • 1. Create an overview page for your project
  • -
  • 2. Create an empty html page with this code in the head tag to redirect to one of your documentation page : <meta http-equiv="refresh" content="0; url=http://example.com/"/>
  • -
  • 3. Configure your server to automatically redirect home page to one your documentation page
  • -
-

-
-
- - +{{if .Site.Home.Content }} +{{.Site.Home.Content}} +{{else}} + {{if eq .Site.Language.Lang "fr"}} +

Personaliser la page d'accueil

+

+ Le site fonctionne. Ne pas oublier de personaliser cette page avec votre propre contenu. 2 façons de faire : +

+ + {{else}} +

Customize your own home page

+

+ The site is working. Don't forget to customize this homepage with your own. You typically have 2 choices : +

+ + {{end}} +

+{{ end }} +{{ partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/index.json b/layouts/index.json new file mode 100644 index 0000000000..367f3b3185 --- /dev/null +++ b/layouts/index.json @@ -0,0 +1,12 @@ +[{{ range $index, $page := .Site.Pages }} +{{- if ne $page.Type "json" -}} +{{- if and $index (gt $index 0) -}},{{- end }} +{ + "uri": "{{ $page.Permalink }}", + "title": "{{ htmlEscape $page.Title}}", + "tags": [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}], + "description": "{{ htmlEscape .Description}}", + "content": {{$page.Plain | jsonify}} +} +{{- end -}} +{{- end -}}] \ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index eedba9d357..760197f7ad 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,71 +1,67 @@ - - {{ $isChapter := .Params.chapter | default (eq .Kind "section")}} - {{ if $isChapter }} - - {{ end }} + {{ if .Params.chapter }} + + {{ end }} + - - - {{ if $.Site.Params.autoNav }} - {{ $.Scratch.Set "_sectionpages" (slice) }} - {{ if $.Site.Params.menu }} - {{ range $sname := $.Site.Params.menu }} - {{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }} - {{ end }} - {{ else }} - {{ range $sname, $spages := .Site.Sections }} - {{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }} - {{ end }} - {{ $.Scratch.Set "_sectionpages" (sort ($.Scratch.Get "_sectionpages") "Weight") }} - {{ end }} - {{ $.Scratch.Set "_allpages" (slice) }} - {{ range $.Scratch.Get "_sectionpages" }} - {{ if .Content }} - {{ $.Scratch.Add "_allpages" . }} - {{ end }} - {{ range index $.Site.Sections .Section }} - {{ $.Scratch.Add "_allpages" .Page }} - {{ end }} - {{ end }} - {{ end }} +
- - - - - - - + + + + + + + - - - - {{ partial "script.html" . }} + + + diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 2484f24439..cf1cf652ee 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,84 +1,83 @@ - + {{ .Hugo.Generator }} {{ partial "meta.html" . }} {{ partial "favicon.html" . }} - {{ .Scratch.Add "title" "" }}{{ if eq .Site.Data.titles .Title }}{{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }}{{ else }}{{ .Scratch.Set "title" .Title}}{{end}} - {{ .Scratch.Get "title" }} - - - - - - - - - - + {{ .Title }} :: {{ .Site.Title }} + + + + + + + + + + + + {{ partial "style.html" . }} - {{ $isChapter := .Params.chapter | default (eq .Kind "section")}} {{ partial "menu.html" . }}
- -
- -
+
+ {{if not .IsHome}}
- {{ if and .IsPage .Site.Params.editURL }} + {{ if and (or .IsPage .IsSection) .Site.Params.editURL }} {{ $File := .File }} {{ $Site := .Site }} {{with $File.Path }} - {{ end }} {{ end }} + {{$toc := (and (not .Params.disableToc) (not .Params.chapter))}} - {{ if .Params.toc }} + {{ if $toc }} {{ partial "toc.html" . }} {{ end }}
- -
- {{ if $isChapter }} -
{{ end }} -
- {{ if not $isChapter }} -

{{.Title}}

- {{ end }} + + {{ if .Params.chapter }} +
+ {{ end }} +
+ {{if and (not .IsHome) (not .Params.chapter) }} +

{{.Title}}

+ {{end}} + + {{define "breadcrumb"}} + {{$parent := .page.Parent }} + {{ if $parent }} + {{ $value := (printf "%s > %s" $parent.URL $parent.Title .value) }} + {{ template "breadcrumb" dict "page" $parent "value" $value }} + {{else}} + {{.value|safeHTML}} + {{end}} + {{end}} \ No newline at end of file diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 8e60b3b658..f3932d398e 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -1,87 +1,98 @@ -
- -
+
    - {{ if $.Site.Params.menu }} - {{ $.Scratch.Set "menuItems" $.Site.Params.menu }} - {{ else }} - {{ $.Scratch.Set "_pages" (slice) }} - {{ range $key, $value := .Site.Sections }} - {{ $sectionPage := $.Site.GetPage "section" $key }} - {{ if $sectionPage.Content }} - {{ $.Scratch.Add "_pages" $sectionPage }} - {{ else if gt $value.Len 0 }} - {{ $.Scratch.Add "_pages" (index $value 0).Page }} - {{ end }} - {{ end }} - {{ $.Scratch.Set "menuItems" (slice)}} - {{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }} - {{ $.Scratch.Add "menuItems" $value.Section }} - {{ end }} - {{ end }} - {{ $menuItems := $.Scratch.Get "menuItems" }} - {{ range $i, $key := $menuItems }} - {{ if ne $key "" }} - {{ $value := (index $.Site.Sections $key) }} - {{ $.Scratch.Set "_value" $value }} - {{ with $index := $.Site.GetPage "section" $key }} - {{ if .Content }} - {{ $.Scratch.Set "first" $index }} - {{ else if gt $value.Len 0}} - {{ $.Scratch.Set "first" (index $value 0).Page }} - {{ if gt $value.Len 1 }} - {{ $.Scratch.Set "_value" (after 1 $value) }} - {{ else }} - {{ $.Scratch.Set "_value" nil }} - {{ end }} - {{ end }} - {{ end }} - {{ $first := $.Scratch.Get "first" }} - {{ $value := $.Scratch.Get "_value" }} - -
  • - - - {{ if isset $first.Params "icon" }} - {{ printf $first.Params.icon | safeHTML }} - {{ end }} - {{ $first.Title }} - {{ if $.Site.Params.showVisitedLinks}} - - {{ end }} - - - {{ if gt $value.Len 0}} - - {{ end }} -
  • - {{ end }} - {{ end }} + {{if eq .Site.Params.ordersectionsby "title"}} + {{range .Site.Home.Sections.ByTitle}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks}} + {{end}} + {{else}} + {{range .Site.Home.Sections.ByWeight}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks}} + {{end}} + {{end}}
-
- {{ if .Site.Params.showVisitedLinks}} - Clear History - {{ end }} +
+ {{ if $showvisitedlinks}} + {{T "Clear-History"}} + {{ end }} +
+ + +{{ define "section-tree-nav" }} +{{ $showvisitedlinks := .showvisitedlinks }} +{{ $currentNode := .currentnode }} + {{with .sect}} + {{if .IsSection}} + {{safeHTML .Params.head}} +
  • + + + {{safeHTML .Params.Pre}}{{.Title}}{{safeHTML .Params.Post}} + {{ if $showvisitedlinks}} + + {{ end }} + + + {{ $numberOfPages := (add (len .Pages) (len .Sections)) }} + {{ if ne $numberOfPages 0 }} +
      + {{ .Scratch.Set "pages" .Pages }} + {{ if .Sections}} + {{ .Scratch.Set "pages" (.Pages | union .Sections) }} + {{end}} + {{ $pages := (.Scratch.Get "pages") }} + + {{if eq .Site.Params.ordersectionsby "title"}} + {{ range $pages.ByTitle }} + {{ if and .Params.hidden (not $.showhidden) }} + {{else}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }} + {{end}} + {{ end }} + {{else}} + {{ range $pages.ByWeight }} + {{ if and .Params.hidden (not $.showhidden) }} + {{else}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }} + {{end}} + {{ end }} + {{end}} +
    + {{ end }} +
  • + {{else}} + {{ if not .Params.Hidden }} +
  • + + {{safeHTML .Params.Pre}}{{.Title}}{{safeHTML .Params.Post}} + {{ if $showvisitedlinks}}{{end}} + + +
  • + {{ end }} + {{end}} + {{ end }} +{{ end }} + diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000000..d388676459 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/layouts/partials/search.html b/layouts/partials/search.html index c902dcc5ee..c53d3e7873 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -1,11 +1,11 @@ - - + + - + diff --git a/layouts/shortcodes/attachments.html b/layouts/shortcodes/attachments.html new file mode 100644 index 0000000000..3940d287f2 --- /dev/null +++ b/layouts/shortcodes/attachments.html @@ -0,0 +1,33 @@ +
    + + {{if eq .Page.File.BaseFileName "index"}} + {{$.Scratch.Add "filesName" "files"}} + {{else}} + {{$.Scratch.Add "filesName" (printf "%s.files" .Page.File.BaseFileName)}} + {{end}} + {{ range (readDir (printf "./content/%s%s" .Page.File.Dir ($.Scratch.Get "filesName")) ) }} + {{ $fileDir := replace $.Page.File.Dir "\\" "/" }} + {{if ($.Get "pattern")}} + {{if (findRE ($.Get "pattern") .Name)}} +
  • + + {{.Name}} + + ({{div .Size 1024 }} ko) +
  • + {{end}} + {{else}} +
  • + + {{.Name}} + + ({{div .Size 1024 }} ko) +
  • + {{end}} + {{end}} +
    + +{{.Inner}} \ No newline at end of file diff --git a/layouts/shortcodes/relref.html b/layouts/shortcodes/relref.html new file mode 100644 index 0000000000..5cb8116290 --- /dev/null +++ b/layouts/shortcodes/relref.html @@ -0,0 +1,12 @@ +{{- if in (.Get 0) "/_index.md" -}} + {{- $path := (trim (.Get 0) "_index.md") -}} + {{- with .Site.GetPage "section" (trim $path "/") -}} + {{- .URL -}} + {{- end -}} +{{- else -}} + {{- with .Site.GetPage "section" (.Get 0) }} + {{- .URL -}} + {{- else -}} + {{- .Get 0 | relref .Page -}} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/static/css/hugo-theme.css b/static/css/hugo-theme.css index c9ab135f34..33dbaa4a0e 100644 --- a/static/css/hugo-theme.css +++ b/static/css/hugo-theme.css @@ -172,7 +172,6 @@ h2 { font-size: 2.5rem; line-height: 110% !important; margin: 2.5rem 0 1.5rem 0; - text-transform: capitalize; } h3 { diff --git a/static/css/theme.css b/static/css/theme.css index 94fe7e2a9c..29948b0684 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -812,6 +812,9 @@ td { overflow: auto; position: relative; } +.hljs::selection, .hljs span::selection { + background: #b7b7b7; +} .lightbox-active #body { overflow: visible; } diff --git a/static/js/hugo-learn.js b/static/js/hugo-learn.js index b579d05bc5..27c2679e52 100644 --- a/static/js/hugo-learn.js +++ b/static/js/hugo-learn.js @@ -17,7 +17,7 @@ var getUrlParameter = function getUrlParameter(sPageURL) { }; // Execute actions on images generated from Markdown pages -var images = $("div#body-inner img"); +var images = $("div#body-inner img").not(".inline"); // Wrap image inside a featherlight (to get a full size view in a popup) images.wrap(function(){ var image =$(this); @@ -56,10 +56,10 @@ images.each(function(index){ }); // Stick the top to the top of the screen when scrolling -$("#top-bar").stick_in_parent( { - parent: ".sticky-parent", - spacer: ".sticky-spacer", -}); +//$("#top-bar").stick_in_parent( { +// parent: ".sticky-parent", +// spacer: ".sticky-spacer", +//}); jQuery(document).ready(function() { diff --git a/static/js/learn.js b/static/js/learn.js index 856c3320b8..f553fcabc6 100644 --- a/static/js/learn.js +++ b/static/js/learn.js @@ -25,11 +25,6 @@ function getScrollBarWidth() { return (w1 - w2); }; -function setMenuHeight() { - $('#sidebar .highlightable').height($('#sidebar').innerHeight() - $('#header-wrapper').height() - 40); - $('#sidebar .highlightable').perfectScrollbar('update'); -} - function fallbackMessage(action) { var actionMsg = ''; var actionKey = (action === 'cut' ? 'X' : 'C'); @@ -49,7 +44,6 @@ function fallbackMessage(action) { // for the window resize $(window).resize(function() { - setMenuHeight(); }); // debouncing function from John Hann @@ -83,10 +77,13 @@ $(window).resize(function() { jQuery(document).ready(function() { + jQuery('#sidebar .category-icon').on('click', function() { + $( this ).toggleClass("fa-angle-down fa-angle-right") ; + $( this ).parent().parent().children('ul').toggle() ; + return false; + }); + var sidebarStatus = searchStatus = 'open'; - $('#sidebar .highlightable').perfectScrollbar(); - // set the menu height - setMenuHeight(); jQuery('#overlay').on('click', function() { jQuery(document.body).toggleClass('sidebar-hidden'); @@ -139,7 +136,7 @@ jQuery(document).ready(function() { $(".highlightable").unhighlight({ element: 'mark' }).highlight(value, { element: 'mark' }); if (ajax && ajax.abort) ajax.abort(); - + jQuery('[data-search-clear]').on('click', function() { jQuery('[data-search-input]').val('').trigger('input'); sessionStorage.removeItem('search-input'); @@ -147,10 +144,19 @@ jQuery(document).ready(function() { }); }); + $.expr[":"].contains = $.expr.createPseudo(function(arg) { + return function( elem ) { + return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; + }; + }); + if (sessionStorage.getItem('search-value')) { - jQuery(document.body).removeClass('searchbox-hidden'); - jQuery('[data-search-input]').val(sessionStorage.getItem('search-value')); - jQuery('[data-search-input]').trigger('input'); + var searchValue = sessionStorage.getItem('search-value') + $(document.body).removeClass('searchbox-hidden'); + $('[data-search-input]').val(searchValue); + $('[data-search-input]').trigger('input'); + var searchedElem = $('#body-inner').find(':contains(' + searchValue + ')').get(0); + searchedElem && searchedElem.scrollIntoView(); } // clipboard @@ -218,100 +224,24 @@ jQuery(document).ready(function() { $('#top-bar a:not(:has(img)):not(.btn)').addClass('highlight'); $('#body-inner a:not(:has(img)):not(.btn)').addClass('highlight'); - $('#toc-menu').hover(function() { - $('.progress').stop(true, false, true).fadeToggle(100); - }); + var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0) + if (!touchsupport){ // browser doesn't support touch + $('#toc-menu').hover(function() { + $('.progress').stop(true, false, true).fadeToggle(100); + }); - $('.progress').hover(function() { - $('.progress').stop(true, false, true).fadeToggle(100); - }); - - /** - * Fix anchor scrolling that hides behind top nav bar - * Courtesy of https://stackoverflow.com/a/13067009/28106 - * - * We could use pure css for this if only heading anchors were - * involved, but this works for any anchor, including footnotes - **/ - (function(document, history, location) { - var HISTORY_SUPPORT = !!(history && history.pushState); - - var anchorScrolls = { - ANCHOR_REGEX: /^#[^ ]+$/, - OFFSET_HEIGHT_PX: 50, - - /** - * Establish events, and fix initial scroll position if a hash is provided. - */ - init: function() { - this.scrollToCurrent(); - window.addEventListener('hashchange', this.scrollToCurrent.bind(this)); - document.body.addEventListener('click', this.delegateAnchors.bind(this)); - }, - - /** - * Return the offset amount to deduct from the normal scroll position. - * Modify as appropriate to allow for dynamic calculations - */ - getFixedOffset: function() { - return this.OFFSET_HEIGHT_PX; - }, - - /** - * If the provided href is an anchor which resolves to an element on the - * page, scroll to it. - * @param {String} href - * @return {Boolean} - Was the href an anchor. - */ - scrollIfAnchor: function(href, pushToHistory) { - var match, rect, anchorOffset; - - if(!this.ANCHOR_REGEX.test(href)) { - return false; - } - - match = document.getElementById(href.slice(1)); - - if(match) { - rect = match.getBoundingClientRect(); - anchorOffset = window.pageYOffset + rect.top - this.getFixedOffset(); - window.scrollTo(window.pageXOffset, anchorOffset); - - // Add the state to history as-per normal anchor links - if(HISTORY_SUPPORT && pushToHistory) { - history.pushState({}, document.title, location.pathname + href); - } - } - - return !!match; - }, - - /** - * Attempt to scroll to the current location's hash. - */ - scrollToCurrent: function() { - this.scrollIfAnchor(window.location.hash); - }, - - /** - * If the click event's target was an anchor, fix the scroll position. - */ - delegateAnchors: function(e) { - var elem = e.target; - - if( - elem.nodeName === 'A' && - this.scrollIfAnchor(elem.getAttribute('href'), true) - ) { - e.preventDefault(); - } - } - }; - - window.addEventListener( - 'DOMContentLoaded', anchorScrolls.init.bind(anchorScrolls) - ); - })(window.document, window.history, window.location); + $('.progress').hover(function() { + $('.progress').stop(true, false, true).fadeToggle(100); + }); + } + if (touchsupport){ // browser does support touch + $('#toc-menu').click(function() { + $('.progress').stop(true, false, true).fadeToggle(100); + }); + $('.progress').click(function() { + $('.progress').stop(true, false, true).fadeToggle(100); + }); + } }); diff --git a/static/js/search.js b/static/js/search.js index 6fd9855b84..0afeacec1c 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -1,11 +1,19 @@ var lunrIndex, pagesIndex; +function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} + // Initialize lunrjs using our generated index file function initLunr() { + if (!endsWith(baseurl,"/")){ + baseurl = baseurl+'/' + }; + // First retrieve the index file - $.getJSON(baseurl + "/json/search.json") + $.getJSON(baseurl +"index.json") .done(function(index) { - pagesIndex = index; + pagesIndex = index; // Set up lunrjs by declaring the fields we use // Also provide their boost level for the ranking lunrIndex = new lunr.Index @@ -60,17 +68,12 @@ $( document ).ready(function() { return true; }, set: function (value) { - location.href=value.href; + location.href=value.uri; }, render: function (li, suggestion) { var uri = suggestion.uri.substring(1,suggestion.uri.length); - var indexOfIndex = uri.lastIndexOf("/index"); - if (indexOfIndex == -1) { - indexOfIndex = uri.length; - } - var href = uri.substring(uri.indexOf("/"), indexOfIndex); - suggestion.href = baseurl + href; + suggestion.href = baseurl + uri; var query = $("#search-by").val(); var numWords = 2; diff --git a/static/json/search.json b/static/json/search.json deleted file mode 100644 index fe51488c70..0000000000 --- a/static/json/search.json +++ /dev/null @@ -1 +0,0 @@ -[]