mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
🐛 Fix: hidden collection navigation, list and related content from encrypted content
This commit is contained in:
@@ -65,3 +65,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.encrypted-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
+4
-5
@@ -914,7 +914,6 @@ class FixIt {
|
||||
}
|
||||
|
||||
initFixItDecryptor() {
|
||||
const $tocNodes = document.querySelectorAll('#toc-auto>.d-none, #toc-static.d-none');
|
||||
this.decryptor = new FixItDecryptor({
|
||||
decrypted: () => {
|
||||
this.initTwemoji();
|
||||
@@ -927,16 +926,16 @@ class FixIt {
|
||||
this.initEcharts();
|
||||
this.initTypeit();
|
||||
this.initMapbox();
|
||||
this.util.forEach($tocNodes, ($element) => {
|
||||
$element.classList.remove('d-none');
|
||||
this.util.forEach(document.querySelectorAll('.encrypted-hidden'), ($element) => {
|
||||
$element.classList.replace('encrypted-hidden', 'decrypted-shown');
|
||||
});
|
||||
this.initToc();
|
||||
this.initTocListener();
|
||||
this.initPangu();
|
||||
},
|
||||
reset: () => {
|
||||
this.util.forEach($tocNodes, ($element) => {
|
||||
$element.classList.add('d-none');
|
||||
this.util.forEach(document.querySelectorAll('.decrypted-shown'), ($element) => {
|
||||
$element.classList.replace('decrypted-shown', 'encrypted-hidden');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{- /* Collection List */ -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- if .Params.collections | and $params.collectionList -}}
|
||||
{{- if .Params.collections | and $params.collectionList | and (not $params.password) -}}
|
||||
{{- $collectionTerms := .GetTerms "collections" -}}
|
||||
{{- range $collectionTerms -}}
|
||||
{{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{- /* Collection Navigation */ -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- if .Params.collections | and $params.collectionNavigation -}}
|
||||
{{- if .Params.collections | and $params.collectionNavigation | and (not $params.password) -}}
|
||||
{{- $collectionTerms := .GetTerms "collections" -}}
|
||||
{{- range $collectionTerms -}}
|
||||
{{- $termLink := printf `<a href="%v">%v <span>%v・%v</span></span></a>`
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{{- $msg := (.Scratch.Get "params").message | default (T "single.encryptedMessage") -}}
|
||||
{{- $loading := resources.Get "images/loading.svg" | minify -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
<div class="fixit-decryptor-container">
|
||||
<img class="fixit-decryptor-loading" src="{{ $loading.RelPermalink }}" alt="decryptor loading" />
|
||||
<label for="fixit-decryptor-input" title='{{ T "single.password" }}'>
|
||||
<input type="password" id="fixit-decryptor-input" class="d-none" placeholder="🔑 {{ $msg }}" />
|
||||
</label>
|
||||
<button class="fixit-encryptor-btn d-none">
|
||||
{{- dict "Class" "fa-solid fa-lock" | partial "plugin/icon.html" }} {{ T "single.encryptyAgain" -}}
|
||||
</button>
|
||||
</div>
|
||||
{{- if $params.password -}}
|
||||
{{- $msg := (.Scratch.Get "params").message | default (T "single.encryptedMessage") -}}
|
||||
{{- $loading := resources.Get "images/loading.svg" | minify -}}
|
||||
<div class="fixit-decryptor-container">
|
||||
<img class="fixit-decryptor-loading" src="{{ $loading.RelPermalink }}" alt="decryptor loading" />
|
||||
<label for="fixit-decryptor-input" title='{{ T "single.password" }}'>
|
||||
<input type="password" id="fixit-decryptor-input" class="d-none" placeholder="🔑 {{ $msg }}" />
|
||||
</label>
|
||||
<button class="fixit-encryptor-btn d-none">
|
||||
{{- dict "Class" "fa-solid fa-lock" | partial "plugin/icon.html" }} {{ T "single.encryptyAgain" -}}
|
||||
</button>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
@@ -33,49 +33,53 @@
|
||||
{{- end -}}
|
||||
</span>
|
||||
</div>
|
||||
{{- with $params.license | string -}}
|
||||
<div class="post-info-license{{ with $params.password }} d-none{{ end }}">
|
||||
<span>{{- . | safeHTML -}} </span>
|
||||
</div>
|
||||
{{- if not $params.password -}}
|
||||
{{- with $params.license | string -}}
|
||||
<div class="post-info-license">
|
||||
<span>{{ . | safeHTML }}</span>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
<div class="post-info-line{{ with $params.password }} d-none{{ end }}">
|
||||
<div class="post-info-md">
|
||||
{{- $linkOptions := slice -}}
|
||||
{{- if $params.LinkToMarkdown -}}
|
||||
{{- with .OutputFormats.Get "markdown" -}}
|
||||
{{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "single.readMarkdown") "Content" (T "single.readMarkdown") "externalIcon" false -}}
|
||||
{{- if not $params.password -}}
|
||||
<div class="post-info-line">
|
||||
<div class="post-info-md">
|
||||
{{- $linkOptions := slice -}}
|
||||
{{- if $params.LinkToMarkdown -}}
|
||||
{{- with .OutputFormats.Get "markdown" -}}
|
||||
{{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "single.readMarkdown") "Content" (T "single.readMarkdown") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToSource | and $gitRepo -}}
|
||||
{{- $link := replace $blobURL "{path}" $.File.Path -}}
|
||||
{{- $sourceURL = add $link "?plain=1" -}}
|
||||
{{- $options := dict "Class" "link-to-source" "Destination" $sourceURL "Title" (T "single.viewSource") "Content" (T "single.viewSource") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToSource | and $gitRepo -}}
|
||||
{{- $link := replace $blobURL "{path}" $.File.Path -}}
|
||||
{{- $sourceURL = add $link "?plain=1" -}}
|
||||
{{- $options := dict "Class" "link-to-source" "Destination" $sourceURL "Title" (T "single.viewSource") "Content" (T "single.viewSource") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToEdit | and $gitRepo -}}
|
||||
{{- $link := replace $editURL "{path}" $.File.Path -}}
|
||||
{{- $options := dict "Class" "link-to-edit" "Destination" $link "Title" (T "single.editThisPage") "Content" (T "single.editThisPage") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToReport | and $gitRepo -}}
|
||||
{{- $link := replace $reportURL "{title}" ($.Title | urlquery) -}}
|
||||
{{- $link = replace $link "{URL}" $.Permalink -}}
|
||||
{{- $link = replace $link "{sourceURL}" $sourceURL -}}
|
||||
{{- $options := dict "Class" "link-to-report" "Destination" $link "Title" (T "single.reportIssue") "Content" (T "single.reportIssue") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- range $linkOptions -}}
|
||||
<span>{{ partial "plugin/link.html" . }}</span>
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToEdit | and $gitRepo -}}
|
||||
{{- $link := replace $editURL "{path}" $.File.Path -}}
|
||||
{{- $options := dict "Class" "link-to-edit" "Destination" $link "Title" (T "single.editThisPage") "Content" (T "single.editThisPage") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- if $params.LinkToReport | and $gitRepo -}}
|
||||
{{- $link := replace $reportURL "{title}" ($.Title | urlquery) -}}
|
||||
{{- $link = replace $link "{URL}" $.Permalink -}}
|
||||
{{- $link = replace $link "{sourceURL}" $sourceURL -}}
|
||||
{{- $options := dict "Class" "link-to-report" "Destination" $link "Title" (T "single.reportIssue") "Content" (T "single.reportIssue") "externalIcon" false -}}
|
||||
{{- $linkOptions = $linkOptions | append $options -}}
|
||||
{{- end -}}
|
||||
{{- range $linkOptions -}}
|
||||
<span>{{ partial "plugin/link.html" . }}</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
<div class="post-info-share">
|
||||
<span>
|
||||
{{- partial "plugin/share.html" . -}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-info-share">
|
||||
<span>
|
||||
{{- partial "plugin/share.html" . -}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
<div class="post-info-more">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{- /* https://gohugo.io/content-management/related/ */ -}}
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- if $params.related.enable -}}
|
||||
{{- if $params.related.enable | and (not $params.password) -}}
|
||||
{{- $posts := where .Site.RegularPages "Type" "posts" -}}
|
||||
{{- if .Site.Params.page.hiddenFromRelated -}}
|
||||
{{- $posts = where $posts "Params.hiddenfromrelated" false -}}
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
||||
<div class="details toc{{ with $params.password }} d-none{{ end }}" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
|
||||
<div class="details toc{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
|
||||
<div class="details-summary toc-title">
|
||||
<span>{{ T "single.contents" }}</span>
|
||||
<span>{{ dict "Class" "details-icon fa-solid fa-angle-right" | partial "plugin/icon.html" }}</span>
|
||||
@@ -180,8 +180,6 @@
|
||||
{{- /* Expiration Reminder */ -}}
|
||||
{{- partial "single/expiration-reminder.html" . -}}
|
||||
{{- $content -}}
|
||||
{{- else -}}
|
||||
{{- partial "single/fixit-decryptor.html" . -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
@@ -197,6 +195,9 @@
|
||||
{{- /* Collection Navigation */ -}}
|
||||
{{- partial "single/collection-nav.html" . -}}
|
||||
|
||||
{{- /* FixIt Decryptor */ -}}
|
||||
{{- partial "single/fixit-decryptor.html" . -}}
|
||||
|
||||
{{- /* Footer */ -}}
|
||||
{{- partial "single/footer.html" . -}}
|
||||
|
||||
@@ -212,11 +213,11 @@
|
||||
<aside class="toc" id="toc-auto" aria-label="{{ T "single.contents" }}">
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
||||
<h2 class="toc-title{{ with $params.password }} d-none{{ end }}">
|
||||
<h2 class="toc-title{{ with $params.password }} encrypted-hidden{{ end }}">
|
||||
{{- T "single.contents" -}}
|
||||
{{- dict "Class" "toc-icon fa-solid fa-angle-down fa-fw" | partial "plugin/icon.html" -}}
|
||||
</h2>
|
||||
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}{{ with $params.password }} d-none{{ end }}" id="toc-content-auto"></div>
|
||||
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-content-auto"></div>
|
||||
{{- end -}}
|
||||
</aside>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user