diff options
| author | Craig Jennings <craigmartinjennings@gmail.com> | 2024-03-24 14:41:32 -0500 |
|---|---|---|
| committer | Craig Jennings <craigmartinjennings@gmail.com> | 2024-03-24 14:41:32 -0500 |
| commit | 4aed6ea63ae93704b5d4cc07b528a0dd70a5d752 (patch) | |
| tree | d7610e41ff54da3f340cec1c86134c189a44db8a /layouts | |
initial commit; forked from https://github.com/Yukuro/hugo-theme-shell
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/404.html | 0 | ||||
| -rw-r--r-- | layouts/_default/baseof.html | 11 | ||||
| -rw-r--r-- | layouts/_default/list.html | 0 | ||||
| -rw-r--r-- | layouts/_default/single.html | 8 | ||||
| -rw-r--r-- | layouts/index.html | 55 | ||||
| -rw-r--r-- | layouts/partials/footer.html | 0 | ||||
| -rw-r--r-- | layouts/partials/head.html | 7 | ||||
| -rw-r--r-- | layouts/partials/header.html | 5 | ||||
| -rw-r--r-- | layouts/partials/mathjax.html | 13 | ||||
| -rw-r--r-- | layouts/partials/style.html | 43 | ||||
| -rw-r--r-- | layouts/partials/typeActivity.html | 57 | ||||
| -rw-r--r-- | layouts/partials/typeIndex.html | 66 | ||||
| -rw-r--r-- | layouts/partials/typewriter.html | 14 | ||||
| -rw-r--r-- | layouts/shortcodes/typewriter.html | 14 |
14 files changed, 293 insertions, 0 deletions
diff --git a/layouts/404.html b/layouts/404.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/404.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..2a153c4 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en{{ end }}"> + {{- partial "head.html" . -}} + <body> + {{- partial "header.html" . -}} + <div id="content"> + {{- block "main" . }}{{- end }} + </div> + {{- partial "footer.html" . -}} + </body> +</html> diff --git a/layouts/_default/list.html b/layouts/_default/list.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/_default/list.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..58c1678 --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,8 @@ +{{ define "main" }} + {{ $title := printf "<h1 id='title'>%s</h1>" .Title}} + {{ $title := printf "<span id='terminal'>%s</span>" $title}} + {{ $content := printf "<span id='terminal'>%s</span>" .Content }} + + + {{ partial "partials/typeActivity.html" (dict "context" . "title" $title "content" $content "titledelay" $.Site.Params.Terminal.titleDelay "contentdelay" $.Site.Params.Terminal.contentDelay )}} +{{ end }} diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 0000000..0a84145 --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,55 @@ +{{ define "main" }} + {{ $env := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName "" | safeHTML }} + {{ $envWithDir := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName .Site.Params.Terminal.workDir | safeHTML }} + + {{ $cd := printf "<span id='terminal'>cd %s</span>" .Site.Params.Terminal.workDir | safeHTML }} + {{ $cat := printf "<span id=terminal>cat %s</span>" .Site.Params.Terminal.profile | safeHTML }} + + {{ $description := "" }} + {{ if eq (substr .Site.Params.Terminal.description -3 3) ".md" }} + {{ $s := "" }} + {{ with .Site.GetPage .Site.Params.Terminal.description }} + <!-- replace the first p tag with a br tag --> + {{ $s = replaceRE "</?p[^>]*>" "" .Content 1 }} + {{ end }} + {{ $description = printf "<span id='terminal'>%s</span>" $s | safeHTML}} + {{ else }} + {{ $limit := sub (len (findRE "\n" .Site.Params.Terminal.description)) 1 }} + {{ $description = printf "<span id='terminal'>%s</span>" .Site.Params.Terminal.description }} + {{ $description = replaceRE "\n" "<br>" $description $limit| safeHTML }} + {{ end }} + + {{ $tree := "" }} + {{ $leaf := "" }} + {{ if .Site.Params.Tree.use }} + {{ $tree = printf "<span id='terminal'>tree ./%s/</span>" .Site.Params.Tree.folderName | safeHTML}} + {{ $leaf = printf "%s<strong><span id='dir'>./%s/</span></strong><br>" $leaf .Site.Params.Tree.folderName | safeHTML}} + {{ range $index, $val := .Site.Params.Tree.files }} + {{ $ac := index $val 0}} + {{ $link := index $val 1}} + + <!-- pass link (i.e. http, https) and mailto --> + {{ $l := $.Site.GetPage $link }} + {{ if $l }} + {{ $link = $l.Permalink}} + {{ end }} + + {{ if eq (add $index 1) (len $.Site.Params.Tree.files) }} + {{ $leaf = printf "<span id='terminal'>%s└── <a href='%s'>%s</a></span>" $leaf $link $ac | safeHTML}} + {{ else }} + {{ $leaf = printf "<span id='terminal'>%s├── <a href='%s'>%s</a></span><br>" $leaf $link $ac | safeHTML}} + {{ end }} + {{ end }} + {{ end }} + + {{ $end := $env }} + + {{ $payload := delimit (slice $cd $cat $description $tree $leaf $end) "" }} + + {{ $ps1Delay := $.Site.Params.Terminal.ps1Delay }} + {{ $stdoutDelay := $.Site.Params.Terminal.stdoutDelay }} + {{ $commandDelay := $.Site.Params.Terminal.commandDelay }} + + {{ partial "partials/typeIndex.html" (dict "context" . "env" $env "cd" $cd "envWithDir" $envWithDir "cat" $cat "description" $description "tree" $tree "leaf" $leaf "ps1delay" $ps1Delay "stdoutdelay" $stdoutDelay "commanddelay" $commandDelay ) }} + +{{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/partials/footer.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..0caae6c --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,7 @@ +<head> + <title>{{- if .IsHome }}{{ .Site.Title }}{{- else }}{{ .Title }}{{- end }}</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width,initial-scale=1"> + <meta name="description" content="{{if .IsHome}}{{ $.Site.Params.description }}{{else}}{{.Description}}{{end}}" /> + {{ partial "partials/style.html" . }} +</head>
\ No newline at end of file diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 0000000..a1a20c5 --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,5 @@ +{{ if or ( eq .Site.Params.Terminal.terminalDelay 0 ) ( eq .Site.Params.Terminal.activityDelay 0 )}} + {{ if .Page.Params.math }} + {{ partial "mathjax.html" . }} + {{ end }} +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/mathjax.html b/layouts/partials/mathjax.html new file mode 100644 index 0000000..eb6315a --- /dev/null +++ b/layouts/partials/mathjax.html @@ -0,0 +1,13 @@ +<script> + window.MathJax = { + CommonHTML: { linebreaks: { automatic: true } }, + tex: { + inlineMath: [ ['$', '$'], ['\\(','\\)'] ], + displayMath: [ ['$$','$$'], ['\\[', '\\]'] ], + processEscapes: false, + noUndefined: { attributes: { mathcolor: 'red', mathbackground: '#FFEEEE', mathsize: '90%' } } }, + messageStyle: 'none' +}; +</script> +<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> +<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/tex-mml-svg.js"></script> diff --git a/layouts/partials/style.html b/layouts/partials/style.html new file mode 100644 index 0000000..d4ceb09 --- /dev/null +++ b/layouts/partials/style.html @@ -0,0 +1,43 @@ +<style> +{{ if .IsHome }} +{{- $default_style := resources.Get "sass/default.scss" | resources.ToCSS -}} +{{- $default_style.Content | safeCSS -}} +{{ else }} +{{- $activity_style := resources.Get "sass/activity.scss" | resources.ToCSS | minify -}} +{{- $activity_style.Content | safeCSS -}} +{{ end }} + +{{ $terminal_style := resources.Get "sass/white.scss" }} +{{/* {{ with (eq .Site.Params.Terminal.scheme "monokai") }} {{- $terminal_style = resources.Get "sass/monokai.scss" | resources.ToCSS | minify -}} {{ end }} */}} +{{ with (eq .Site.Params.Terminal.scheme "shell-powershell") }} + {{- $terminal_style = resources.Get "sass/powershell.scss" | resources.ToCSS | minify -}} + {{- $terminal_style = $terminal_style.Content -}} +{{ end }} +{{/* {{ with (eq .Site.Params.Terminal.scheme "gruvbox_light") }} {{- $terminal_style = resources.Get "sass/gruvbox_light.scss" | resources.ToCSS | minify -}} {{ end }} */}} +{{/* {{ with (eq .Site.Params.Terminal.scheme "gruvbox_dark") }} {{- $terminal_style = resources.Get "sass/gruvbox_dark.scss" | resources.ToCSS | minify -}} {{ end }} */}} +{{/* {{ with (eq .Site.Params.Terminal.scheme "solarized_light") }} {{- $terminal_style = resources.Get "sass/solarized_light.scss" | resources.ToCSS | minify -}} {{ end }} */}} +{{/* {{ with (eq .Site.Params.Terminal.scheme "solarized_dark") }} {{- $terminal_style = resources.Get "sass/solarized_dark.scss" | resources.ToCSS | minify -}} {{ end }} */}} +{{ with (eq .Site.Params.Terminal.scheme "shell-ubuntu") }} + {{- $terminal_style = resources.Get "sass/ubuntu.scss" | resources.ToCSS | minify -}} + {{- $terminal_style = $terminal_style.Content -}} +{{ end }} +{{ with (eq .Site.Params.Terminal.scheme "shell-retro") }} + {{- $terminal_style = resources.Get "sass/retro.scss" | resources.ToCSS | minify -}} + {{- $terminal_style = $terminal_style.Content -}} +{{ end }} +{{/* {{ with (eq .Site.Params.Terminal.scheme "goph") }} {{- $terminal_style = resources.Get "sass/goph.scss" | resources.ToCSS | minify -}} {{ end }} */}} + +{{/* Assume that ubuntu and retro do not exist in gogh. */}} +{{ $themeData := getJSON "https://raw.githubusercontent.com/Gogh-Co/Gogh/master/data/themes.json" }} +{{ range $t := $themeData }} + {{if eq $t.name $.Site.Params.Terminal.scheme }} + {{ $terminal_style = printf "body{background:%s}body #terminal{color:%s}body #user{color:%s}body #dir{color:%s}body .Typewriter__cursor{color:%s}a{color:%s}" $t.background $t.cursor $t.color_03 $t.color_05 $t.cursor $t.cursor | safeCSS }} + {{ end }} +{{ end }} + +{{/* {{- $terminal_style.Content | safeCSS -}} */}} +{{ $terminal_style | safeCSS }} + +</style> + + diff --git a/layouts/partials/typeActivity.html b/layouts/partials/typeActivity.html new file mode 100644 index 0000000..911754f --- /dev/null +++ b/layouts/partials/typeActivity.html @@ -0,0 +1,57 @@ +<span id="activity-title"></span> <br> + <span id="activity-content"></span> <br> + +<script type="text/javascript"> + async function typewriter(text, elementId, waitAfter) { + var n = 0, + isTag = false + addText = ""; + const el = document.getElementById(elementId); + + const wait = () => new Promise(r => setTimeout(r, waitAfter)); + const nowait = () => new Promise(r => r()); + + const render = () => el.innerHTML = (text.slice(0, n + 1) + addText); + + const cursor = document.createElement('span'); + cursor.id = "blink"; + + el.style.setProperty("--cursor-visibility", "visible"); + while (n < text.length) { + if (text.charAt(n + 1) === "<") isTag = true; + if (text.charAt(n + 1) === ">") isTag = false; + + if (isTag) { + n++; + continue; + } + + requestAnimationFrame(render); + + if (waitAfter === 0) { + await nowait(); + } else { + await wait(); + } + + n++; + } + el.style.setProperty("--cursor-visibility", "collapse"); + } + + function parseDelay(d) { + const parsed = parseInt(d, 10); + if (isNaN(parsed)) return 0; + return parsed; + } + + const titleDelay = parseDelay("{{ .titledelay }}"), + contentDelay = parseDelay("{{ .contentdelay }}"); + const typeeffetct = async () => { + await typewriter("{{ .title }}", "activity-title", titleDelay); + await typewriter("{{ .content }}", "activity-content", contentDelay); + return; + } + + typeeffetct() +</script>
\ No newline at end of file diff --git a/layouts/partials/typeIndex.html b/layouts/partials/typeIndex.html new file mode 100644 index 0000000..ab2526f --- /dev/null +++ b/layouts/partials/typeIndex.html @@ -0,0 +1,66 @@ +<span id="ps1_01"></span> <span id="cd"></span> <br> +<span id="ps1_02"></span> <span id="cat"></span> <br> +<span id="std_out_01"></span> <br> +<span id="ps1_03"></span> <span id="tree"></span> <br> +<span id="std_out_02"></span> <br> +<span id="ps1_04"></span> + +<script type="text/javascript"> + async function typewriter(text, elementId, waitAfter) { + var n = 0, + isTag = false + addText = ""; + const el = document.getElementById(elementId); + + const wait = () => new Promise(r => setTimeout(r, waitAfter)); + const nowait = () => new Promise(r => r()); + + const render = () => el.innerHTML = (text.slice(0, n + 1) + addText); + + const cursor = document.createElement('span'); + cursor.id = "blink"; + + el.style.setProperty("--cursor-visibility", "visible"); + while (n < text.length) { + if (text.charAt(n + 1) === "<") isTag = true; + if (text.charAt(n + 1) === ">") isTag = false; + + if (isTag) { + n++; + continue; + } + + requestAnimationFrame(render); + + if (waitAfter === 0) { + await nowait(); + } else { + await wait(); + } + + n++; + } + el.style.setProperty("--cursor-visibility", "collapse"); + } + + function parseDelay(d) { + const parsed = parseInt(d, 10); + if (isNaN(parsed)) return 0; + return parsed; + } + + const ps1Delay = parseDelay("{{ .ps1delay }}"), + stdoutDelay = parseDelay("{{ .stdoutdelay }}"), + commandDelay = parseDelay("{{ .commanddelay }}"); + const typeeffetct = async () => { + await typewriter("{{ .env }}", "ps1_01", ps1Delay); await typewriter("{{ .cd }}", "cd", commandDelay); + await typewriter("{{ .envWithDir }}", "ps1_02", ps1Delay); await typewriter("{{ .cat }}", "cat", commandDelay); + await typewriter("{{ .description }}", "std_out_01", stdoutDelay); + await typewriter("{{ .envWithDir }}", "ps1_03", ps1Delay); await typewriter("{{ .tree }}", "tree", commandDelay); + await typewriter("{{ .leaf }}", "std_out_02", stdoutDelay); + await typewriter("{{ .envWithDir }}", "ps1_04", ps1Delay); + return; + } + + typeeffetct() +</script>
\ No newline at end of file diff --git a/layouts/partials/typewriter.html b/layouts/partials/typewriter.html new file mode 100644 index 0000000..daab6ae --- /dev/null +++ b/layouts/partials/typewriter.html @@ -0,0 +1,14 @@ +<div id=typewriter></div> + +{{- if eq .delay 0 }} + {{ .payload }} +{{ else }} + <script src="https://cdn.jsdelivr.net/gh/tameemsafi/typewriterjs/dist/core.js"></script> + <script type="text/javascript"> + const instance = new Typewriter('#typewriter', { + strings: '{{ .payload }}', + delay: '{{ .delay }}', + autoStart: true, + }); + </script> +{{ end -}} diff --git a/layouts/shortcodes/typewriter.html b/layouts/shortcodes/typewriter.html new file mode 100644 index 0000000..a16cfbb --- /dev/null +++ b/layouts/shortcodes/typewriter.html @@ -0,0 +1,14 @@ +{{ $random := delimit (seq 9 | shuffle) "" }} +{{ $tpid := md5 $random }} + +<div id = a{{ $tpid }}></div> + +<script src="https://unpkg.com/typewriter-effect@latest/dist/core.js"></script> + +<script type="text/javascript"> + const instance = new Typewriter('#a{{ $tpid }}', { + strings: '{{ .Inner | replaceRE "\n" "<br>" | safeHTML }}', + delay: 20, + autoStart: true, + }); +</script>
\ No newline at end of file |
