pidgin/nest

Dealing with depreciation

2019-06-11, Jason
bcd002f09cc6
Parents cd4aa1bfb28c
Children baee1c8450b1
Dealing with depreciation

* `.URL` => `.RelPermalink`
* `.Hugo` => `hugo`
* `.File.Path` zero object protection

+ Simplify some templateing
--- a/hugo/themes/learn/layouts/partials/footer.html Tue Jun 11 03:44:34 2019 +0100
+++ b/hugo/themes/learn/layouts/partials/footer.html Tue Jun 11 03:59:19 2019 +0100
@@ -2,7 +2,7 @@
{{ if .Params.chapter }}
</div> <!-- end chapter-->
{{ end }}
- </div>
+ </div>
{{ partial "custom-comments.html" . }}
</div>
@@ -15,7 +15,7 @@
{{ define "menu-nextprev" }}
{{ $currentNode := .currentnode }}
{{ if ne .menu.Params.hidden true }}
- {{ if hasPrefix $currentNode.URL .menu.URL }}
+ {{ if hasPrefix $currentNode.RelPermalink .menu.RelPermalink }}
{{ $currentNode.Scratch.Set "NextPageOK" "OK" }}
{{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }}
{{ else }}
@@ -44,16 +44,16 @@
{{ $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{ if $showPrevNext }}
{{ with ($.Scratch.Get "prevPage") }}
- <a class="nav nav-prev" href="{{ .URL }}" title="{{ .Title }}"> <i class="fa fa-chevron-left"></i></a>
+ <a class="nav nav-prev" href="{{ .RelPermalink }}" title="{{ .Title }}"> <i class="fa fa-chevron-left"></i></a>
{{ end }}
{{ with ($.Scratch.Get "nextPage") }}
- <a class="nav nav-next" href="{{ .URL }}" title="{{ .Title }}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
+ <a class="nav nav-next" href="{{ .RelPermalink }}" title="{{ .Title }}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
{{ end }}
{{ end }}
</div>
</section>
-
+
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
--- a/hugo/themes/learn/layouts/partials/header.html Tue Jun 11 03:44:34 2019 +0100
+++ b/hugo/themes/learn/layouts/partials/header.html Tue Jun 11 03:59:19 2019 +0100
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- {{ .Hugo.Generator }}
+ {{ hugo.Generator }}
{{ partial "meta.html" . }}
{{ partial "favicon.html" . }}
<title>{{ .Title }} :: {{ .Site.Title }}</title>
@@ -50,13 +50,21 @@
{{ if and (or .IsPage .IsSection) .Site.Params.editURL }}
{{ $File := .File }}
{{ $Site := .Site }}
- {{ with $File.Path }}
- <div id="top-github-link">
- <a class="github-link" title='{{ T "Edit-this-page" }}' href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="blank">
- <i class="fas fa-code-branch"></i>
- <span id="top-github-link-text">{{ T "Edit-this-page" }}</span>
- </a>
- </div>
+
+ {{ if .File }}
+ {{ if .File.Path }}
+ <div id="top-github-link">
+ <a
+ class="github-link"
+ title='{{ T "Edit-this-page" }}'
+ href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}"
+ target="blank"
+ >
+ <i class="fas fa-code-branch"></i>
+ <span id="top-github-link-text">{{ T "Edit-this-page" }}</span>
+ </a>
+ </div>
+ {{ end }}
{{ end }}
{{ end }}
@@ -75,7 +83,7 @@
{{ if $showBreadcrumb }}
{{ template "breadcrumb" dict "page" . "value" .Title }}
{{ else }}
- {{ .Title }}
+ {{ .Title }}
{{ end }}
</span>
</div>
@@ -109,9 +117,9 @@
{{ define "breadcrumb" }}
{{ $parent := .page.Parent }}
{{ if $parent }}
- {{ $value := (printf "<a href='%s'>%s</a> > %s" $parent.URL $parent.Title .value) }}
- {{ template "breadcrumb" dict "page" $parent "value" $value }}
+ {{ $value := (printf "<a href='%s'>%s</a> > %s" $parent.RelPermalink $parent.Title .value) }}
+ {{ template "breadcrumb" dict "page" $parent "value" $value }}
{{ else }}
- {{ .value|safeHTML }}
+ {{ .value | safeHTML }}
{{ end }}
{{ end }}
--- a/hugo/themes/learn/layouts/partials/menu.html Tue Jun 11 03:44:34 2019 +0100
+++ b/hugo/themes/learn/layouts/partials/menu.html Tue Jun 11 03:59:19 2019 +0100
@@ -13,16 +13,12 @@
<div class="highlightable">
<ul class="topics">
+ {{ $orderByTitle := (eq .Site.Params.ordersectionsby "title") }}
+ {{ $sections := cond $orderByTitle .Site.Home.Sections.ByTitle .Site.Home.Sections.ByWeight }}
- {{ 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 }}
+ {{ range $sections }}
+ {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }}
+ {{ end }}
</ul>
{{ $disableShortcutsTitle := .Site.Params.DisableShortcutsTitle }}
@@ -31,7 +27,7 @@
<h3>{{ if not $disableShortcutsTitle }}{{ T "Shortcuts-Title" }}{{ end }}</h3>
<ul>
{{ range sort . "Weight" }}
- <li>
+ <li>
{{ .Pre }}<a class="padding" href="{{ .URL | absLangURL }}">{{ safeHTML .Name }}</a>{{ .Post }}
</li>
{{ end }}
@@ -56,11 +52,11 @@
{{ range $siteLanguages }}
{{ if eq $translation.Lang .Lang }}
{{ $selected := false }}
- {{ if eq $pageLang .Lang }}
- <option id="{{ $translation.Language }}" value="{{ $translation.URL }}" selected>{{ .LanguageName }}</option>
- {{ else }}
- <option id="{{ $translation.Language }}" value="{{ $translation.URL }}">{{ .LanguageName }}</option>
- {{ end }}
+ <option
+ id="{{ $translation.Language }}"
+ value="{{ $translation.RelPermalink }}"
+ {{ if eq $pageLang .Lang }}selected{{ end }}
+ >{{ .LanguageName }}</option>
{{ end }}
{{ end }}
{{ end }}
@@ -90,16 +86,16 @@
</div>
</nav>
-<!-- templates -->
+{{/*-- templates --*/}}
{{ define "section-tree-nav" }}
{{ $showvisitedlinks := .showvisitedlinks }}
{{ $currentNode := .currentnode }}
{{ with .sect }}
{{ if .IsSection }}
{{ safeHTML .Params.head }}
- <li data-nav-id="{{ .URL }}" title="{{ .Title }}" class="dd-item
+ <li data-nav-id="{{ .RelPermalink }}" title="{{ .Title }}" class="dd-item
{{- if .IsAncestor $currentNode }} parent{{ end -}}
- {{- if eq .UniqueID $currentNode.UniqueID }} active{{ end -}}
+ {{- if and (eq .File.UniqueID $currentNode.File.UniqueID) }} active{{ end -}}
{{- if .Params.alwaysopen }} parent{{ end }}">
<a href="{{ .RelPermalink }}">
{{ safeHTML .Params.Pre }}{{ or .Params.menuTitle .LinkTitle .Title }}{{ safeHTML .Params.Post }}
@@ -136,9 +132,15 @@
</li>
{{ else }}
{{ if not .Params.Hidden }}
- <li data-nav-id="{{ .URL }}" title="{{ .Title }}" class="dd-item {{ if eq .UniqueID $currentNode.UniqueID }}active{{ end }}">
+ <li
+ data-nav-id="{{ .RelPermalink }}"
+ title="{{ .Title }}"
+ class="dd-item {{ if eq .File.UniqueID $currentNode.File.UniqueID }}active{{ end }}"
+ >
<a href="{{ .RelPermalink }}">
- {{ safeHTML .Params.Pre }}{{ or .Params.menuTitle .LinkTitle .Title }}{{ safeHTML .Params.Post }}
+ {{ safeHTML .Params.Pre }}
+ {{ or .Params.menuTitle .LinkTitle .Title }}
+ {{ safeHTML .Params.Post }}
{{ if $showvisitedlinks }}
<i class="fas fa-check read-icon"></i>
{{ end }}
@@ -148,4 +150,3 @@
{{ end }}
{{ end }}
{{ end }}
-