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/partials | |
initial commit; forked from https://github.com/Yukuro/hugo-theme-shell
Diffstat (limited to 'layouts/partials')
| -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 |
8 files changed, 205 insertions, 0 deletions
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 -}} |
