From 1baceb1c62c5c208917b7d22b3cb4635df0ef072 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:14:11 -0400 Subject: [PATCH 01/12] refactor(baseof): refactors base header and footer to their own partials --- layouts/partials/footer.html | 151 +------------------------ layouts/partials/header.html | 189 +------------------------------- layouts/partials/site_head.html | 188 +++++++++++++++++++++++++++++++ layouts/partials/site_js.html | 151 +++++++++++++++++++++++++ 4 files changed, 342 insertions(+), 337 deletions(-) create mode 100644 layouts/partials/site_head.html create mode 100644 layouts/partials/site_js.html diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f1e4f02d..ead0993c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,154 +1,5 @@ - {{ $scr := $.Scratch }} +{{ partial "site_js.html" . }} - {{/* Config LaTeX math rendering. */}} - {{ if or .Params.math site.Params.math }} - {{ $mathjax_config := resources.Get "js/mathjax-config.js" }} - - {{ end }} - - {{/* Attempt to load local vendor JS, otherwise load from CDN. */}} - {{ $js := site.Data.assets.js }} - {{ if not ($scr.Get "use_cdn") }} - - {{ else }} - {{ printf "" (printf $js.jQuery.url $js.jQuery.version) $js.jQuery.sri | safeHTML }} - {{ printf "" (printf $js.imagesLoaded.url $js.imagesLoaded.version) $js.imagesLoaded.sri | safeHTML }} - {{ printf "" (printf $js.isotope.url $js.isotope.version) $js.isotope.sri | safeHTML }} - {{ printf "" (printf $js.fancybox.url $js.fancybox.version) $js.fancybox.sri | safeHTML }} - - {{ if or .Params.diagram site.Params.diagram }} - {{ printf "" (printf $js.mermaid.url $js.mermaid.version) $js.mermaid.sri | safeHTML }} - {{ end }} - - {{ if $.Scratch.Get "highlight_enabled" }} - {{ $v := $js.highlight.version }} - {{ printf "" (printf $js.highlight.url $v) $js.highlight.sri | safeHTML }} - {{ range site.Params.highlight_languages }} - - {{ end }} - {{ end }} - - {{/* LaTeX math rendering. */}} - {{ if or .Params.math site.Params.math }} - {{ printf "" (printf $js.mathJax.url $js.mathJax.version) $js.mathJax.sri | safeHTML }} - {{ end }} - {{ end }} - - {{/* Maps JS. */}} - {{ if eq site.Params.map 1 }} - - {{ if ($scr.Get "use_cdn") }} - {{ printf "" (printf $js.gmaps.url $js.gmaps.version) $js.gmaps.sri | safeHTML }} - {{ end }} - {{ else if and (or (eq site.Params.map 2) (eq site.Params.map 3)) ($scr.Get "use_cdn") }} - {{ printf "" (printf $js.leaflet.url $js.leaflet.version) $js.leaflet.sri | safeHTML }} - {{ end }} - - {{/* Comments JS. */}} - {{ $comments_enabled := and site.DisqusShortname (not (or site.Params.disable_comments $.Params.disable_comments)) }} - {{ if and $comments_enabled (site.Params.comment_count | default true) }} - - {{ end }} - - {{/* Initialise code highlighting. */}} - {{ if $.Scratch.Get "highlight_enabled" }} - - {{ end }} - - {{ if ne site.Params.search.engine 0 }} - {{/* Configure search engine. */}} - - {{ end }} - - {{/* Load hash anchors for documentation pages. */}} - {{ if eq .Type "docs" }} - {{ printf "" (printf $js.anchor.url $js.anchor.version) $js.anchor.sri | safeHTML }} - - {{ end }} - - {{ if eq site.Params.search.engine 1 }} - {{/* Fuse search result template. */}} - - {{ else if eq site.Params.search.engine 2 }} - {{/* Algolia search result template. */}} - - {{ end }} - - {{/* Fuse search engine. */}} - {{ if and (eq site.Params.search.engine 1) ($scr.Get "use_cdn") }} - {{ printf "" (printf $js.fuse.url $js.fuse.version) $js.fuse.sri | safeHTML }} - {{ printf "" (printf $js.mark.url $js.mark.version) $js.mark.sri | safeHTML }} - {{ end }} - - {{/* Algolia search engine. */}} - {{ if eq site.Params.search.engine 2 }} - {{ if ($scr.Get "use_cdn") }} - {{ printf "" (printf $js.instantsearch.url $js.instantsearch.version) $js.instantsearch.sri | safeHTML }} - {{ end }} - - {{ end }} - - {{ $js_comment := printf "/* Source Themes Academic v%s | https://sourcethemes.com/academic/ */\n" site.Data.academic.version }} - {{ $js_bundle_head := $js_comment | resources.FromString "js/bundle-head.js" }} - {{ $js_linebreak := "\n" | resources.FromString "js/linebreak.js" }}{{/* Fix no line break after Bootstrap JS causing error. */}} - {{ $js_academic := resources.Get "js/academic.js" }} - {{ $js_academic_search := resources.Get "js/academic-search.js" }} - {{ $js_algolia_search := resources.Get "js/algolia-search.js" }} - {{ $js_bootstrap := resources.Get "js/vendor/bootstrap.min.js" }} - {{ $js_bundle := slice $js_bootstrap $js_linebreak $js_academic }} - {{ if eq site.Params.search.engine 1 }} - {{ $js_bundle = $js_bundle | append $js_academic_search }} - {{ else if eq site.Params.search.engine 2 }} - {{ $js_bundle = $js_bundle | append $js_algolia_search }} - {{ end }} - {{ range site.Params.plugins_js }} - {{ $js_bundle = $js_bundle | append (resources.Get (printf "js/%s.js" .)) }} - {{ end }} - {{ $js_bundle := $js_bundle | resources.Concat "js/academic-bundle-pre.js" | minify }} - {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/academic.min.js" | fingerprint "md5" }} - diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ac962639..1b64903b 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,192 +1,7 @@ - - - - - +{{ partial "site_head.html" . }} - {{ $scr := .Scratch }} - - {{/* Attempt to load superuser. */}} - {{ $superuser_name := "" }} - {{ $superuser_username := "" }} - {{ $superuser_role := "" }} - {{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }} - {{ $superuser_name = .Params.name }} - {{ $superuser_username = path.Base (path.Split .Path).Dir }} - {{ $superuser_role = .Params.role }} - {{ end }} - {{ $scr.Set "superuser_username" $superuser_username }}{{/* For access from page_author.html. */}} - - {{ with $superuser_name }}{{ end }} - - {{/* Generate page description. */}} - {{ $desc := "" }} - {{ if .Params.summary }} - {{ $desc = .Params.summary }} - {{ else if .Params.abstract }} - {{ $desc = .Params.abstract }} - {{ else if .IsPage }} - {{ $desc = .Summary }} - {{ else if site.Params.description }} - {{ $desc = site.Params.description }} - {{ else }} - {{ $desc = $superuser_role }} - {{ end }} - - - {{ range .Translations }} - - {{ end }} - - - {{ partial "functions/parse_theme" . }} - {{ $css := site.Data.assets.css }} - {{ $js := site.Data.assets.js }} - {{ if ne ($scr.Get "primary") "#fff" }} - - {{ end }} - - {{/* Attempt to load local vendor CSS, otherwise load from CDN. */}} - {{ $scr.Set "vendor_css_filename" "main.min.css" }} - {{ $scr.Set "vendor_js_filename" "main.min.js" }} - {{ if and (fileExists (printf "static/css/vendor/%s" ($scr.Get "vendor_css_filename"))) (fileExists (printf "static/js/vendor/%s" ($scr.Get "vendor_js_filename"))) }} - {{ $scr.Set "use_cdn" 0 }} - - {{ else }} - {{ $scr.Set "use_cdn" 1 }} - {{ printf "" (printf $css.academicons.url $css.academicons.version) $css.academicons.sri | safeHTML }} - {{ printf "" (printf $css.fontAwesome.url $css.fontAwesome.version) $css.fontAwesome.sri | safeHTML }} - {{ printf "" (printf $css.fancybox.url $css.fancybox.version) $css.fancybox.sri | safeHTML }} - - {{/* Default to enabling highlighting, but allow the user to override it in .Params or site.Params. - Use $scr to store "highlight_enabled", so that we can read it again in footer.html. */}} - {{ $scr.Set "highlight_enabled" true }} - {{ if isset .Params "highlight" }} - {{ $scr.Set "highlight_enabled" .Params.highlight }} - {{ else if isset site.Params "highlight" }} - {{ $scr.Set "highlight_enabled" site.Params.highlight }} - {{ end }} - {{ if ($scr.Get "highlight_enabled") }} - {{ $v := $css.highlight.version }} - {{ with site.Params.highlight_style }} - {{ printf "" (printf $css.highlight.url $css.highlight.version .) | safeHTML }} - {{ printf "" (printf $css.highlight.url $css.highlight.version .) | safeHTML }} - {{ else }} - {{ if eq ($scr.Get "light") true }} - {{ printf "" (printf $css.highlight.url $css.highlight.version "github") | safeHTML }} - {{ printf "" (printf $css.highlight.url $css.highlight.version "dracula") | safeHTML }} - {{ else }} - {{ printf "" (printf $css.highlight.url $css.highlight.version "github") | safeHTML }} - {{ printf "" (printf $css.highlight.url $css.highlight.version "dracula") | safeHTML }} - {{ end }} - {{ end }} - {{ end }} - - {{ if or (eq site.Params.map 2) (eq site.Params.map 3) }} - {{ printf "" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} - {{ end }} - - {{ if eq site.Params.search.engine 2 }} - {{ printf "" (printf $css.instantsearch.url $css.instantsearch.version) $css.instantsearch.sri | safeHTML }} - {{ printf "" (printf $css.instantsearchTheme.url $css.instantsearchTheme.version) $css.instantsearchTheme.sri | safeHTML }} - {{ end }} - - {{ end }} - - {{/* We cannot use SRI with Google Fonts because the CSS is dynamically generated according to the user agent. */}} - {{ with ($scr.Get "google_fonts") }} - - {{ end }} - - {{ $css_options := (dict "targetPath" "css/academic.css" "outputStyle" "compressed") }} - {{ $sass_template := resources.Get "sass/main.scss" }} - {{ $style := $sass_template | resources.ExecuteAsTemplate "main_parsed.scss" . | toCSS $css_options | minify | fingerprint "md5" }} - - - {{ if site.Params.plugins_css }} - {{ $css_comment := printf "/* Source Themes Academic v%s | https://sourcethemes.com/academic/ */\n" site.Data.academic.version }} - {{ $css_bundle_head := $css_comment | resources.FromString "css/bundle-head.css" }} - {{ $css_bundle := slice }} - {{ range site.Params.plugins_css }} - {{ $css_bundle = $css_bundle | append (resources.Get (printf "css/%s.css" .)) }} - {{ end }} - {{ $css_bundle := $css_bundle | resources.Concat "css/academic-bundle-pre.css" | minify }} - {{ $css_bundle := slice $css_bundle_head $css_bundle | resources.Concat "css/academic.css" | fingerprint "md5" }} - - {{ end }} - - {{ if not site.IsServer }} - {{ if site.GoogleAnalytics }} - - - {{ if ($scr.Get "use_cdn") }} - {{ printf "" (printf $js.autotrack.url $js.autotrack.version) $js.autotrack.sri | safeHTML }} - {{ end }} - {{ end }} - {{ end }} - - {{ with .OutputFormats.Get "RSS" }} - - - {{ end }} - - - - - - - - {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} - {{ $og_image := "" }} - {{ $twitter_card := "summary_large_image" }} - {{ if $featured_image }} - {{ $og_image = $featured_image.Permalink }} - {{ else if .Params.header.image }} - {{ $og_image = printf "img/%s" .Params.header.image | absURL }} - {{ else if site.Params.sharing_image }} - {{ $og_image = printf "img/%s" site.Params.sharing_image | absURL }} - {{ else if site.Params.avatar }} - {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }} - {{ $twitter_card = "summary" }} - {{ else }} - {{ $og_image = "img/icon-192.png" | absURL }} - {{ $twitter_card = "summary" }} - {{ end }} - - {{ with site.Params.twitter }} - - - {{ end }} - - - - - {{- with $og_image }}{{end}} - - {{ if .IsPage }} - {{ if not .PublishDate.IsZero }} - {{ else if not .Date.IsZero }}{{ end }} - {{ if not .Lastmod.IsZero }}{{ end }} - {{ else }} - {{ if not .Date.IsZero }}{{ end }} - {{ end }} - - {{ partial "cookie_consent" . }} - {{ partial "head_custom" . }} - - {{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }} - - - + {{ partial "search" . }} diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html new file mode 100644 index 00000000..da523cbf --- /dev/null +++ b/layouts/partials/site_head.html @@ -0,0 +1,188 @@ + + + + + + + + {{ $scr := .Scratch }} + + {{/* Attempt to load superuser. */}} + {{ $superuser_name := "" }} + {{ $superuser_username := "" }} + {{ $superuser_role := "" }} + {{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }} + {{ $superuser_name = .Params.name }} + {{ $superuser_username = path.Base (path.Split .Path).Dir }} + {{ $superuser_role = .Params.role }} + {{ end }} + {{ $scr.Set "superuser_username" $superuser_username }}{{/* For access from page_author.html. */}} + + {{ with $superuser_name }}{{ end }} + + {{/* Generate page description. */}} + {{ $desc := "" }} + {{ if .Params.summary }} + {{ $desc = .Params.summary }} + {{ else if .Params.abstract }} + {{ $desc = .Params.abstract }} + {{ else if .IsPage }} + {{ $desc = .Summary }} + {{ else if site.Params.description }} + {{ $desc = site.Params.description }} + {{ else }} + {{ $desc = $superuser_role }} + {{ end }} + + + {{ range .Translations }} + + {{ end }} + + + {{ partial "functions/parse_theme" . }} + {{ $css := site.Data.assets.css }} + {{ $js := site.Data.assets.js }} + {{ if ne ($scr.Get "primary") "#fff" }} + + {{ end }} + + {{/* Attempt to load local vendor CSS, otherwise load from CDN. */}} + {{ $scr.Set "vendor_css_filename" "main.min.css" }} + {{ $scr.Set "vendor_js_filename" "main.min.js" }} + {{ if and (fileExists (printf "static/css/vendor/%s" ($scr.Get "vendor_css_filename"))) (fileExists (printf "static/js/vendor/%s" ($scr.Get "vendor_js_filename"))) }} + {{ $scr.Set "use_cdn" 0 }} + + {{ else }} + {{ $scr.Set "use_cdn" 1 }} + {{ printf "" (printf $css.academicons.url $css.academicons.version) $css.academicons.sri | safeHTML }} + {{ printf "" (printf $css.fontAwesome.url $css.fontAwesome.version) $css.fontAwesome.sri | safeHTML }} + {{ printf "" (printf $css.fancybox.url $css.fancybox.version) $css.fancybox.sri | safeHTML }} + + {{/* Default to enabling highlighting, but allow the user to override it in .Params or site.Params. + Use $scr to store "highlight_enabled", so that we can read it again in footer.html. */}} + {{ $scr.Set "highlight_enabled" true }} + {{ if isset .Params "highlight" }} + {{ $scr.Set "highlight_enabled" .Params.highlight }} + {{ else if isset site.Params "highlight" }} + {{ $scr.Set "highlight_enabled" site.Params.highlight }} + {{ end }} + {{ if ($scr.Get "highlight_enabled") }} + {{ $v := $css.highlight.version }} + {{ with site.Params.highlight_style }} + {{ printf "" (printf $css.highlight.url $css.highlight.version .) | safeHTML }} + {{ printf "" (printf $css.highlight.url $css.highlight.version .) | safeHTML }} + {{ else }} + {{ if eq ($scr.Get "light") true }} + {{ printf "" (printf $css.highlight.url $css.highlight.version "github") | safeHTML }} + {{ printf "" (printf $css.highlight.url $css.highlight.version "dracula") | safeHTML }} + {{ else }} + {{ printf "" (printf $css.highlight.url $css.highlight.version "github") | safeHTML }} + {{ printf "" (printf $css.highlight.url $css.highlight.version "dracula") | safeHTML }} + {{ end }} + {{ end }} + {{ end }} + + {{ if or (eq site.Params.map 2) (eq site.Params.map 3) }} + {{ printf "" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} + {{ end }} + + {{ if eq site.Params.search.engine 2 }} + {{ printf "" (printf $css.instantsearch.url $css.instantsearch.version) $css.instantsearch.sri | safeHTML }} + {{ printf "" (printf $css.instantsearchTheme.url $css.instantsearchTheme.version) $css.instantsearchTheme.sri | safeHTML }} + {{ end }} + + {{ end }} + + {{/* We cannot use SRI with Google Fonts because the CSS is dynamically generated according to the user agent. */}} + {{ with ($scr.Get "google_fonts") }} + + {{ end }} + + {{ $css_options := (dict "targetPath" "css/academic.css" "outputStyle" "compressed") }} + {{ $sass_template := resources.Get "sass/main.scss" }} + {{ $style := $sass_template | resources.ExecuteAsTemplate "main_parsed.scss" . | toCSS $css_options | minify | fingerprint "md5" }} + + + {{ if site.Params.plugins_css }} + {{ $css_comment := printf "/* Source Themes Academic v%s | https://sourcethemes.com/academic/ */\n" site.Data.academic.version }} + {{ $css_bundle_head := $css_comment | resources.FromString "css/bundle-head.css" }} + {{ $css_bundle := slice }} + {{ range site.Params.plugins_css }} + {{ $css_bundle = $css_bundle | append (resources.Get (printf "css/%s.css" .)) }} + {{ end }} + {{ $css_bundle := $css_bundle | resources.Concat "css/academic-bundle-pre.css" | minify }} + {{ $css_bundle := slice $css_bundle_head $css_bundle | resources.Concat "css/academic.css" | fingerprint "md5" }} + + {{ end }} + + {{ if not site.IsServer }} + {{ if site.GoogleAnalytics }} + + + {{ if ($scr.Get "use_cdn") }} + {{ printf "" (printf $js.autotrack.url $js.autotrack.version) $js.autotrack.sri | safeHTML }} + {{ end }} + {{ end }} + {{ end }} + + {{ with .OutputFormats.Get "RSS" }} + + + {{ end }} + + + + + + + + {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} + {{ $og_image := "" }} + {{ $twitter_card := "summary_large_image" }} + {{ if $featured_image }} + {{ $og_image = $featured_image.Permalink }} + {{ else if .Params.header.image }} + {{ $og_image = printf "img/%s" .Params.header.image | absURL }} + {{ else if site.Params.sharing_image }} + {{ $og_image = printf "img/%s" site.Params.sharing_image | absURL }} + {{ else if site.Params.avatar }} + {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }} + {{ $twitter_card = "summary" }} + {{ else }} + {{ $og_image = "img/icon-192.png" | absURL }} + {{ $twitter_card = "summary" }} + {{ end }} + + {{ with site.Params.twitter }} + + + {{ end }} + + + + + {{- with $og_image }}{{end}} + + {{ if .IsPage }} + {{ if not .PublishDate.IsZero }} + {{ else if not .Date.IsZero }}{{ end }} + {{ if not .Lastmod.IsZero }}{{ end }} + {{ else }} + {{ if not .Date.IsZero }}{{ end }} + {{ end }} + + {{ partial "cookie_consent" . }} + {{ partial "head_custom" . }} + + {{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }} + + diff --git a/layouts/partials/site_js.html b/layouts/partials/site_js.html new file mode 100644 index 00000000..3ffbfa48 --- /dev/null +++ b/layouts/partials/site_js.html @@ -0,0 +1,151 @@ + {{ $scr := $.Scratch }} + + {{/* Config LaTeX math rendering. */}} + {{ if or .Params.math site.Params.math }} + {{ $mathjax_config := resources.Get "js/mathjax-config.js" }} + + {{ end }} + + {{/* Attempt to load local vendor JS, otherwise load from CDN. */}} + {{ $js := site.Data.assets.js }} + {{ if not ($scr.Get "use_cdn") }} + + {{ else }} + {{ printf "" (printf $js.jQuery.url $js.jQuery.version) $js.jQuery.sri | safeHTML }} + {{ printf "" (printf $js.imagesLoaded.url $js.imagesLoaded.version) $js.imagesLoaded.sri | safeHTML }} + {{ printf "" (printf $js.isotope.url $js.isotope.version) $js.isotope.sri | safeHTML }} + {{ printf "" (printf $js.fancybox.url $js.fancybox.version) $js.fancybox.sri | safeHTML }} + + {{ if or .Params.diagram site.Params.diagram }} + {{ printf "" (printf $js.mermaid.url $js.mermaid.version) $js.mermaid.sri | safeHTML }} + {{ end }} + + {{ if $.Scratch.Get "highlight_enabled" }} + {{ $v := $js.highlight.version }} + {{ printf "" (printf $js.highlight.url $v) $js.highlight.sri | safeHTML }} + {{ range site.Params.highlight_languages }} + + {{ end }} + {{ end }} + + {{/* LaTeX math rendering. */}} + {{ if or .Params.math site.Params.math }} + {{ printf "" (printf $js.mathJax.url $js.mathJax.version) $js.mathJax.sri | safeHTML }} + {{ end }} + {{ end }} + + {{/* Maps JS. */}} + {{ if eq site.Params.map 1 }} + + {{ if ($scr.Get "use_cdn") }} + {{ printf "" (printf $js.gmaps.url $js.gmaps.version) $js.gmaps.sri | safeHTML }} + {{ end }} + {{ else if and (or (eq site.Params.map 2) (eq site.Params.map 3)) ($scr.Get "use_cdn") }} + {{ printf "" (printf $js.leaflet.url $js.leaflet.version) $js.leaflet.sri | safeHTML }} + {{ end }} + + {{/* Comments JS. */}} + {{ $comments_enabled := and site.DisqusShortname (not (or site.Params.disable_comments $.Params.disable_comments)) }} + {{ if and $comments_enabled (site.Params.comment_count | default true) }} + + {{ end }} + + {{/* Initialise code highlighting. */}} + {{ if $.Scratch.Get "highlight_enabled" }} + + {{ end }} + + {{ if ne site.Params.search.engine 0 }} + {{/* Configure search engine. */}} + + {{ end }} + + {{/* Load hash anchors for documentation pages. */}} + {{ if eq .Type "docs" }} + {{ printf "" (printf $js.anchor.url $js.anchor.version) $js.anchor.sri | safeHTML }} + + {{ end }} + + {{ if eq site.Params.search.engine 1 }} + {{/* Fuse search result template. */}} + + {{ else if eq site.Params.search.engine 2 }} + {{/* Algolia search result template. */}} + + {{ end }} + + {{/* Fuse search engine. */}} + {{ if and (eq site.Params.search.engine 1) ($scr.Get "use_cdn") }} + {{ printf "" (printf $js.fuse.url $js.fuse.version) $js.fuse.sri | safeHTML }} + {{ printf "" (printf $js.mark.url $js.mark.version) $js.mark.sri | safeHTML }} + {{ end }} + + {{/* Algolia search engine. */}} + {{ if eq site.Params.search.engine 2 }} + {{ if ($scr.Get "use_cdn") }} + {{ printf "" (printf $js.instantsearch.url $js.instantsearch.version) $js.instantsearch.sri | safeHTML }} + {{ end }} + + {{ end }} + + {{ $js_comment := printf "/* Source Themes Academic v%s | https://sourcethemes.com/academic/ */\n" site.Data.academic.version }} + {{ $js_bundle_head := $js_comment | resources.FromString "js/bundle-head.js" }} + {{ $js_linebreak := "\n" | resources.FromString "js/linebreak.js" }}{{/* Fix no line break after Bootstrap JS causing error. */}} + {{ $js_academic := resources.Get "js/academic.js" }} + {{ $js_academic_search := resources.Get "js/academic-search.js" }} + {{ $js_algolia_search := resources.Get "js/algolia-search.js" }} + {{ $js_bootstrap := resources.Get "js/vendor/bootstrap.min.js" }} + {{ $js_bundle := slice $js_bootstrap $js_linebreak $js_academic }} + {{ if eq site.Params.search.engine 1 }} + {{ $js_bundle = $js_bundle | append $js_academic_search }} + {{ else if eq site.Params.search.engine 2 }} + {{ $js_bundle = $js_bundle | append $js_algolia_search }} + {{ end }} + {{ range site.Params.plugins_js }} + {{ $js_bundle = $js_bundle | append (resources.Get (printf "js/%s.js" .)) }} + {{ end }} + {{ $js_bundle := $js_bundle | resources.Concat "js/academic-bundle-pre.js" | minify }} + {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/academic.min.js" | fingerprint "md5" }} + From 5878e91a16a5fcae75398c0f139ad9004412b3ce Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:29:54 -0400 Subject: [PATCH 02/12] refactor(baseof): created custom head and footer js placeholders --- layouts/partials/custom_head.html | 4 ++++ layouts/partials/custom_js.html | 4 ++++ layouts/partials/head_custom.html | 0 layouts/partials/site_head.html | 3 ++- layouts/partials/site_js.html | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/custom_head.html create mode 100644 layouts/partials/custom_js.html delete mode 100644 layouts/partials/head_custom.html diff --git a/layouts/partials/custom_head.html b/layouts/partials/custom_head.html new file mode 100644 index 00000000..b256694e --- /dev/null +++ b/layouts/partials/custom_head.html @@ -0,0 +1,4 @@ +{{/* No changes should be made to this file. */}} +{{/* Instead, create or modify your sites layout/partials/custom_head.html. */}} + +{{/* This partial is included in themes/academic/layout/partials/site_head.html. */}} diff --git a/layouts/partials/custom_js.html b/layouts/partials/custom_js.html new file mode 100644 index 00000000..5214b744 --- /dev/null +++ b/layouts/partials/custom_js.html @@ -0,0 +1,4 @@ +{{/* No changes should be made to this file. */}} +{{/* Instead, create or modify your sites layout/partials/custom_js.html. */}} + +{{/* This partial is included in themes/academic/layout/partials/site_js.html. */}} diff --git a/layouts/partials/head_custom.html b/layouts/partials/head_custom.html deleted file mode 100644 index e69de29b..00000000 diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html index da523cbf..4702e378 100644 --- a/layouts/partials/site_head.html +++ b/layouts/partials/site_head.html @@ -181,7 +181,8 @@ {{ end }} {{ partial "cookie_consent" . }} - {{ partial "head_custom" . }} + + {{ partial "custom_head" . }} {{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }} diff --git a/layouts/partials/site_js.html b/layouts/partials/site_js.html index 3ffbfa48..7558f435 100644 --- a/layouts/partials/site_js.html +++ b/layouts/partials/site_js.html @@ -149,3 +149,5 @@ {{ $js_bundle := $js_bundle | resources.Concat "js/academic-bundle-pre.js" | minify }} {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/academic.min.js" | fingerprint "md5" }} + + {{ partial "custom_js" . }} From f4d4c48016fa633e868d2b069e3cf04c9a03343d Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:39:23 -0400 Subject: [PATCH 03/12] refactor(baseof): moved citation model block to its own partial --- layouts/partials/citation.html | 25 +++++++++++++++++++++++++ layouts/partials/footer_container.html | 26 +------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 layouts/partials/citation.html diff --git a/layouts/partials/citation.html b/layouts/partials/citation.html new file mode 100644 index 00000000..01620ae7 --- /dev/null +++ b/layouts/partials/citation.html @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/layouts/partials/footer_container.html b/layouts/partials/footer_container.html index 0af7d800..334a87aa 100644 --- a/layouts/partials/footer_container.html +++ b/layouts/partials/footer_container.html @@ -2,28 +2,4 @@ {{ partial "footer_section.html" . }} - - +{{ partial "citation.html" . }} From d263439e740f0e95d31e3b8f25e2884b2ff01b63 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:41:13 -0400 Subject: [PATCH 04/12] refactor(baseof): moved footer_section into the footer_container partial --- layouts/partials/footer_container.html | 26 +++++++++++++++++++++++++- layouts/partials/footer_section.html | 25 ------------------------- 2 files changed, 25 insertions(+), 26 deletions(-) delete mode 100644 layouts/partials/footer_section.html diff --git a/layouts/partials/footer_container.html b/layouts/partials/footer_container.html index 334a87aa..6ad0572d 100644 --- a/layouts/partials/footer_container.html +++ b/layouts/partials/footer_container.html @@ -1,5 +1,29 @@
- {{ partial "footer_section.html" . }} +
+ {{ with site.GetPage "privacy.md" }} +

+ {{ printf "%s" .RelPermalink .Title | safeHTML }} +

+ {{ end }} + +

+ {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} + + Powered by the + Academic theme for + Hugo. + + {{ if ne .Type "docs" }} + + {{ end }} +

+
{{ partial "citation.html" . }} diff --git a/layouts/partials/footer_section.html b/layouts/partials/footer_section.html deleted file mode 100644 index b4758a42..00000000 --- a/layouts/partials/footer_section.html +++ /dev/null @@ -1,25 +0,0 @@ -
- {{ with site.GetPage "privacy.md" }} -

- {{ printf "%s" .RelPermalink .Title | safeHTML }} -

- {{ end }} - -

- {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} - - Powered by the - Academic theme for - Hugo. - - {{ if ne .Type "docs" }} - - {{ end }} -

-
From ddba3fee2b45ee0f51a40f8548293231b2121e64 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:47:19 -0400 Subject: [PATCH 05/12] refactor(baseof): added site_footer partial to replace multiple footer partials --- layouts/partials/site_footer.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 layouts/partials/site_footer.html diff --git a/layouts/partials/site_footer.html b/layouts/partials/site_footer.html new file mode 100644 index 00000000..6ad0572d --- /dev/null +++ b/layouts/partials/site_footer.html @@ -0,0 +1,29 @@ +
+
+ {{ with site.GetPage "privacy.md" }} +

+ {{ printf "%s" .RelPermalink .Title | safeHTML }} +

+ {{ end }} + +

+ {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} + + Powered by the + Academic theme for + Hugo. + + {{ if ne .Type "docs" }} + + {{ end }} +

+
+
+ +{{ partial "citation.html" . }} From 1c2178bc44c1fc57335530839bc65bc70cd64fb4 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:47:46 -0400 Subject: [PATCH 06/12] refactor(baseof): added baseof template to replace template boilerplate --- layouts/_default/baseof.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 layouts/_default/baseof.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 00000000..7d285d37 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,21 @@ + + + +{{ partial "site_head.html" . }} + + + + {{ partial "search" . }} + + {{ partial "navbar.html" . }} + + {{ block "main" . }}{{ end }} + + {{ partial "site_js.html" . }} + + {{ partial "site_footer.html" . }} + + + + + \ No newline at end of file From 044957aca10df94dc254ae9b9e567a8adaf23325 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:56:51 -0400 Subject: [PATCH 07/12] refactor(baseof): minor adjustments to site_footer to help accomodate the docs layout --- layouts/_default/baseof.html | 5 ++- layouts/partials/site_footer.html | 51 +++++++++++++++---------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 7d285d37..aae20ddc 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -13,8 +13,11 @@ {{ partial "site_js.html" . }} - {{ partial "site_footer.html" . }} +
+ {{ partial "site_footer.html" . }} +
+ {{ partial "citation.html" . }} diff --git a/layouts/partials/site_footer.html b/layouts/partials/site_footer.html index 6ad0572d..8290a0bc 100644 --- a/layouts/partials/site_footer.html +++ b/layouts/partials/site_footer.html @@ -1,29 +1,26 @@ -
-
- {{ with site.GetPage "privacy.md" }} -

- {{ printf "%s" .RelPermalink .Title | safeHTML }} -

+
+ {{ with site.GetPage "privacy.md" }} +

+ {{ printf "%s" .RelPermalink .Title | safeHTML }} +

+ {{ end }} + +

+ {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} + + Powered by the + Academic theme for + Hugo. + + {{ if ne .Type "docs" }} + {{ end }} +

+
-

- {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} - - Powered by the - Academic theme for - Hugo. - - {{ if ne .Type "docs" }} - - {{ end }} -

-
-
- -{{ partial "citation.html" . }} From d0043daa72c3693536cb0f436590ec8327b40a2f Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:57:58 -0400 Subject: [PATCH 08/12] refactor(baseof): moved all templates to use a main block --- layouts/404.html | 8 ++++---- layouts/_default/list.html | 7 +++---- layouts/_default/single.html | 6 ++---- layouts/authors/list.html | 6 ++---- layouts/authors/terms.html | 7 +++---- layouts/partials/docs_layout.html | 8 ++++---- layouts/partials/widget_page.html | 6 ++---- layouts/project/single.html | 6 ++---- layouts/publication/single.html | 7 +++---- layouts/section/docs.html | 6 ++---- layouts/section/post.html | 7 +++---- layouts/section/publication.html | 7 +++---- layouts/section/talk.html | 7 +++---- layouts/talk/single.html | 7 +++---- 14 files changed, 39 insertions(+), 56 deletions(-) diff --git a/layouts/404.html b/layouts/404.html index bcd910f7..404df1b9 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,5 +1,5 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} +

{{ i18n "page_not_found" }}

@@ -27,5 +27,5 @@ {{ end }}
-{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index a24bdb29..4a86e6a0 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -26,5 +25,5 @@ {{ partial "pagination" . }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 720f15ca..db72d11e 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}}
@@ -40,5 +39,4 @@
-{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/authors/list.html b/layouts/authors/list.html index 20343fbf..2176e094 100644 --- a/layouts/authors/list.html +++ b/layouts/authors/list.html @@ -1,7 +1,6 @@ {{/* Author profile page. */}} -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{/* If an account has not been created for this user, just display their name as the title. */}} {{ if not .File }} @@ -38,5 +37,4 @@ {{ end }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/authors/terms.html b/layouts/authors/terms.html index 42dc07b1..f896944b 100644 --- a/layouts/authors/terms.html +++ b/layouts/authors/terms.html @@ -1,7 +1,6 @@ {{/* List of all authors. */}} -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -20,5 +19,5 @@ {{ partial "pagination" . }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/partials/docs_layout.html b/layouts/partials/docs_layout.html index 721c2484..e2ebb32f 100644 --- a/layouts/partials/docs_layout.html +++ b/layouts/partials/docs_layout.html @@ -1,5 +1,5 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} + {{ $current_page := . }}
@@ -46,10 +46,10 @@ - {{ partial "footer_section.html" . }} + {{ partial "site_footer.html" . }}
-{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/partials/widget_page.html b/layouts/partials/widget_page.html index dc19bc4e..00be9ef3 100644 --- a/layouts/partials/widget_page.html +++ b/layouts/partials/widget_page.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{/* Notify JS that this is a widget page */}} @@ -76,5 +75,4 @@ {{ end }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/project/single.html b/layouts/project/single.html index 48ba6f28..c74e9e9a 100644 --- a/layouts/project/single.html +++ b/layouts/project/single.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}}
@@ -73,5 +72,4 @@ {{ end }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/publication/single.html b/layouts/publication/single.html index ea77e0f9..b1550516 100644 --- a/layouts/publication/single.html +++ b/layouts/publication/single.html @@ -1,5 +1,5 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} +
{{ partial "page_header.html" . }} @@ -62,5 +62,4 @@
{{ end }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/section/docs.html b/layouts/section/docs.html index 15a730dc..bd65fc2e 100644 --- a/layouts/section/docs.html +++ b/layouts/section/docs.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -16,5 +15,4 @@ -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} diff --git a/layouts/section/post.html b/layouts/section/post.html index da41003e..2f7df9f3 100644 --- a/layouts/section/post.html +++ b/layouts/section/post.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -23,5 +22,5 @@ {{ partial "pagination" . }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/section/publication.html b/layouts/section/publication.html index a1f3c97a..d6b3fb75 100644 --- a/layouts/section/publication.html +++ b/layouts/section/publication.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -75,5 +74,5 @@ -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/section/talk.html b/layouts/section/talk.html index 2983a806..ca2951ce 100644 --- a/layouts/section/talk.html +++ b/layouts/section/talk.html @@ -1,5 +1,4 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} {{ partial "page_header.html" . }} @@ -36,5 +35,5 @@ -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} + +{{- end -}} diff --git a/layouts/talk/single.html b/layouts/talk/single.html index 412014b9..a4262b13 100644 --- a/layouts/talk/single.html +++ b/layouts/talk/single.html @@ -1,5 +1,5 @@ -{{ partial "header.html" . }} -{{ partial "navbar.html" . }} +{{- define "main" -}} +
{{ partial "page_header.html" . }} @@ -84,5 +84,4 @@
{{ end }} -{{ partial "footer_container.html" . }} -{{ partial "footer.html" . }} +{{- end -}} From d3ea424f726cee91ba756640f436bd852dd14e69 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 21:58:32 -0400 Subject: [PATCH 09/12] refactor(baseof): removed unnecessary partials --- layouts/partials/footer.html | 5 ----- layouts/partials/footer_container.html | 29 -------------------------- layouts/partials/header.html | 7 ------- 3 files changed, 41 deletions(-) delete mode 100644 layouts/partials/footer.html delete mode 100644 layouts/partials/footer_container.html delete mode 100644 layouts/partials/header.html diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index ead0993c..00000000 --- a/layouts/partials/footer.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ partial "site_js.html" . }} - - - - diff --git a/layouts/partials/footer_container.html b/layouts/partials/footer_container.html deleted file mode 100644 index 6ad0572d..00000000 --- a/layouts/partials/footer_container.html +++ /dev/null @@ -1,29 +0,0 @@ -
-
- {{ with site.GetPage "privacy.md" }} -

- {{ printf "%s" .RelPermalink .Title | safeHTML }} -

- {{ end }} - -

- {{ with site.Copyright }}{{ replace . "{year}" now.Year | markdownify}} · {{ end }} - - Powered by the - Academic theme for - Hugo. - - {{ if ne .Type "docs" }} - - {{ end }} -

-
-
- -{{ partial "citation.html" . }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html deleted file mode 100644 index 1b64903b..00000000 --- a/layouts/partials/header.html +++ /dev/null @@ -1,7 +0,0 @@ - - - -{{ partial "site_head.html" . }} - - - {{ partial "search" . }} From bd31268e1954aacf0fa7c4b8452b306ededd6efa Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 22:06:59 -0400 Subject: [PATCH 10/12] refactor(baseof): docs cannot use baseof or else footer is displayed twice --- layouts/docs/list.html | 20 +++++++++++++++++++- layouts/docs/single.html | 20 +++++++++++++++++++- layouts/partials/docs_layout.html | 4 ---- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 6b6a6307..4236ab46 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -1 +1,19 @@ -{{ partial "docs_layout.html" . }} + + + +{{ partial "site_head.html" . }} + + + + {{ partial "search" . }} + + {{ partial "navbar.html" . }} + + {{ partial "docs_layout.html" . }} + + {{ partial "site_js.html" . }} + + + + + diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 6b6a6307..4236ab46 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1 +1,19 @@ -{{ partial "docs_layout.html" . }} + + + +{{ partial "site_head.html" . }} + + + + {{ partial "search" . }} + + {{ partial "navbar.html" . }} + + {{ partial "docs_layout.html" . }} + + {{ partial "site_js.html" . }} + + + + + diff --git a/layouts/partials/docs_layout.html b/layouts/partials/docs_layout.html index e2ebb32f..c8e04ea9 100644 --- a/layouts/partials/docs_layout.html +++ b/layouts/partials/docs_layout.html @@ -1,5 +1,3 @@ -{{- define "main" -}} - {{ $current_page := . }}
@@ -51,5 +49,3 @@
- -{{- end -}} From 57c72011cb6c7c54bf2ca9e97901d4ddbfba2cca Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 22:14:27 -0400 Subject: [PATCH 11/12] refactor(baseof): added main blocks to two stray templates --- layouts/index.html | 5 +++++ layouts/widget_page/single.html | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/layouts/index.html b/layouts/index.html index 61d90826..d79d8ced 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,4 +1,9 @@ +{{- define "main" -}} + {{ if not (isset site.Params "color_theme") }} {{ errorf "Please complete the installation of Academic by following the steps at https://sourcethemes.com/academic/docs/install/" }} {{ end }} + {{ partial "widget_page.html" . }} + +{{- end -}} diff --git a/layouts/widget_page/single.html b/layouts/widget_page/single.html index e1d285b7..413b2926 100644 --- a/layouts/widget_page/single.html +++ b/layouts/widget_page/single.html @@ -1 +1,5 @@ +{{- define "main" -}} + {{ partial "widget_page.html" . }} + +{{- end -}} From 19c83715ef9a6f38844660ace3e7cc1f29614d16 Mon Sep 17 00:00:00 2001 From: "Russell J. Hewett" Date: Thu, 30 May 2019 22:14:55 -0400 Subject: [PATCH 12/12] refactor(baseof): partial should not be a full page template --- layouts/partials/widget_page.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/layouts/partials/widget_page.html b/layouts/partials/widget_page.html index 00be9ef3..809967fe 100644 --- a/layouts/partials/widget_page.html +++ b/layouts/partials/widget_page.html @@ -1,5 +1,3 @@ -{{- define "main" -}} - {{/* Notify JS that this is a widget page */}} @@ -74,5 +72,3 @@ {{if $use_container}}{{end}} {{ end }} - -{{- end -}}