0
1
Fork 0
textfiles/layouts/_default/textfile.html

151 lines
6.4 KiB
HTML

{{/*
Copyright (C) 2019 Josh Habdas <jhabdas@protonmail.com>
This file is part of After Dark.
After Dark is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
After Dark is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/}}
{{ define "header" }}
{{ partial "masthead.html" . }}
<div class="textfile-layout">
<header>
<h1>{{- .Title }}</h1>
{{ partial "breadcrumb.html" . }}
</header>
</div>
{{ end }}
{{ define "main" }}
<div class="textfile-layout">
<center>
{{ partialCached "banner.html" . }}
</center>
<nav>
{{ with .NextInSection }}
<span id="prevlabel">prev</span>
<a aria-labelledby="prevlabel" tabindex="2" href="{{ .RelPermalink }}">
<svg class="i-chevron-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3">
<path d="M20 30 L8 16 20 2" />
</svg>
</a>
{{ end }}
<a aria-label="up" tabindex="3" href="{{ (path.Split .RelPermalink).Dir }}">
<svg class="i-chevron-top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3">
<path d="M30 20 L16 8 2 20" />
</svg>
</a>
{{ with .PrevInSection }}
<a aria-labelledby="nextlabel" tabindex="1" href="{{ .RelPermalink }}">
<svg class="i-chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3">
<path d="M12 30 L24 16 12 2" />
</svg>
</a>
<span id="nextpage">next</span>
{{ end }}
</nav>
{{ if and (isset .Params.ansilove "render") .Params.ansilove.render }}
{{ $ansilove := resources.Get "/js/vendor/ansilove/ansilove.js" }}
<script>
((window, document, undefined) => {
window.fetchInject([
{{ printf "%s" $ansilove.RelPermalink }}
]).then(() => {
const retina = window.devicePixelRatio > 1;
const defaultOpts = {
"bits": "9",
"2x": (retina ? 1 : 0)
};
let options = defaultOpts;
{{ if isset .Params.ansilove "options" }}
options = {
...options,
...{{ .Params.ansilove.options | jsonify | safeJS }}
};
{{ end }}
{{ if isset .Params.ansilove "split" }}
AnsiLove.splitRender('{{ .LinkTitle }}', (canvases, sauce) => {
const viewport = document.getElementById('viewport');
const textfile = document.getElementById('textfile');
textfile.style.display = 'none';
canvases.forEach(canvas => {
canvas.style.verticalAlign = 'bottom';
viewport.appendChild(canvas);
});
}, 27, options);
{{ else if isset .Params.ansilove "animate" }}
const controller = AnsiLove.animate('{{ .LinkTitle }}', (canvas, sauce) => {
const viewport = document.getElementById('viewport');
const textfile = document.getElementById('textfile');
textfile.style.display = 'none';
viewport.appendChild(canvas);
controller.play(9600, () => {/* finished */});
}, options);
{{ else }}
AnsiLove.render('{{ .LinkTitle }}', (canvas, sauce) => {
const viewport = document.getElementById('viewport');
const textfile = document.getElementById('textfile');
textfile.style.display = 'none';
viewport.appendChild(canvas);
}, options);
{{ end }}
});
})(window, document);
</script>
{{ end }}
<div id="viewport">
<pre id="textfile">
{{- $filepath := printf "/content/%s%s" .Page.File.Dir .Page.LinkTitle -}}
{{- if fileExists $filepath -}}
{{- readFile $filepath -}}
{{- end -}}
</pre>
</div>
<center>
{{ $path := printf "/content/%s%s" .File.Dir .Page.LinkTitle }}
{{ if fileExists $path }}
{{ $fileInfo := os.Stat $path }}
{{/* Sanitization for piracy/NFO/b%d and the like */}}
{{/* XXX: The % encoding needs to come first */}}
{{ $sanitized_filename := replace $fileInfo.Name "%" "%25" }}
{{/* Sanitization for bbs/DELAM/CAPTURES/mit#s and the like */}}
{{ $sanitized_filename = replace $sanitized_filename "#" "%23" }}
{{/* Sanitization for piracy/NFO/_PENTIUM.NFO.html and the like */}}
{{ $sanitized_filename = replace $sanitized_filename "&" "%26" }}
{{/* See list.html for companion sanitization logic */}}
<dl style="display:inline-block">
<dt>DOWNLOAD FILE</dt>
<dd>
<a download="{{ $fileInfo.Name }}" href="./{{ $sanitized_filename }}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
<path d="M9 22 C0 23 1 12 9 13 6 2 23 2 22 10 32 7 32 23 23 22 M11 26 L16 30 21 26 M16 16 L16 30" />
</svg>
</a>
</dd>
<dt>MD5</dt><dd>{{ md5 (readFile $path) }}</dt>
</dl>
{{ end }}
{{ partialCached "banner.html" . }}
<p><small>
AAAAH! MY EYES! <a href="javascript:document.querySelector('.theme-toggle').click()">Click here</a> if you prefer a black and white color scheme.
</small></p>
{{ partialCached "theme-toggle.html" . }}
</center>
</div>
{{ end }}
{{ define "footer" }}
{{ with .Params.pagefooter }}
<p>{{ . | safeHTML }}</p>
{{ end }}
{{ end }}