Compare commits

..

6 commits

16 changed files with 31 additions and 261 deletions

View file

@ -47,7 +47,6 @@ jobs:
- name: Build with Hugo - name: Build with Hugo
run: | run: |
HUGO_REMOTE_FONT_PATH=${{ secrets.REMOTE_FONT_PATH }} \ HUGO_REMOTE_FONT_PATH=${{ secrets.REMOTE_FONT_PATH }} \
HUGO_DARKVISITORS=${{ secrets.DARKVISITORS_TOKEN }} \
hugo --minify hugo --minify
- name: Insert 404 page - name: Insert 404 page
run: | run: |

View file

@ -1,25 +0,0 @@
// manipulates the post upvote "kudos" button behavior
window.onload = function() {
// get the button and text elements
const kudosButton = document.querySelector('.kudos-button');
const kudosText = document.querySelector('.kudos-text');
const emojiSpan = kudosButton.querySelector('.emoji');
kudosButton.addEventListener('click', function(event) {
// send the event to Cabin
cabin.event('kudos')
// disable the button
kudosButton.disabled = true;
kudosButton.classList.add('clicked');
// change the displayed text
kudosText.textContent = 'Thanks!';
kudosText.classList.add('thanks');
// spin the emoji
emojiSpan.style.transform = 'rotate(360deg)';
// change the emoji to celebrate
setTimeout(function() {
emojiSpan.textContent = '🎉';
}, 150); // half of the css transition time for a smooth mid-rotation change
});
}

View file

@ -1,20 +0,0 @@
// retreives the latest link from a musicthread thread and displays it on the page
const themeSongScript = document.currentScript
const urlParams = new URLSearchParams(themeSongScript.src.split('.js')[1])
const params = Object.fromEntries(urlParams.entries())
if (params.id)
{
const musicthread = `https://musicthread.app/api/v0/thread/${params.id}`
fetch(musicthread)
.then((response) => response.json())
.then((thread) => {
let themeSong = thread.links[0]
console.log(themeSong)
themeSongContainer = document.createElement('div')
themeSongContainer.className = 'theme-song'
themeSongContainer.style
themeSongContainer.innerHTML = `<a href="${themeSong.page_url}"><img src="${themeSong.thumbnail_url}"></a><br><a href="${themeSong.page_url}">${themeSong.title}</a><br><i>${themeSong.artist}</i>`
themeSongScript.parentNode.insertBefore(themeSongContainer, themeSongScript)
})
}

View file

@ -1,167 +0,0 @@
/*
Typo, a more natural web typing thing
https://neatnik.net/typo
https://github.com/neatnik/typo
Copyright (c) 2021 Neatnik LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
function num_between(min, max) {
return Math.floor(Math.random() * (max- min + 1) + min);
}
function chance(val) {
if(num_between(0, 100) < val) return true;
else return false;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var typos = {
q:['w','a'],
w:['q','r','s'],
e:['w','d','r'],
r:['e','f','t'],
t:['r','g','y'],
y:['t','h','u'],
u:['y','j','i'],
i:['u','k','o'],
o:['i','l','p'],
p:['o',';','['],
a:['q','s','z'],
s:['w','a','x','d'],
d:['e','s','c','f'],
f:['r','d','v','g'],
g:['t','f','b','h'],
h:['y','g','n','j'],
j:['u','h','m','k'],
k:['i','j',',','l'],
l:['o','k','.',';'],
z:['a','x'],
x:['z','s','c'],
c:['x','d','v'],
v:['c','f','b'],
b:['v','g','n'],
n:['b','h','m'],
m:['n','j',','],
}
async function typo(element, text) {
var buffer = '';
var typo_active = false;
var typing_typos = (element.dataset.typoChance) ? element.dataset.typoChance : 10;
var typing_speed = (element.dataset.typingDelay) ? element.dataset.typingDelay : 50;
var typing_jitter = (element.dataset.typingJitter) ? element.dataset.typingJitter : 15;
for (var i = 0; i < text.length; i++) {
// Get the letter that we're supposed to type
letter = text.charAt(i);
// Trigger a typo
if(chance(typing_typos) && typo_active === false && i > 1 && i < text.length - 3) {
if(typeof typos[letter] !== 'undefined') {
// Swap the letter with a random typo
typo = typos[letter][Math.floor(Math.random() * typos[letter].length)];
// Append the letter to the buffer
buffer = buffer + typo;
// Write the buffer
element.innerHTML = buffer;
typo_active = true;
var seed = num_between(2,5); // Reduced max seed to ensure correction
realization_delay = seed;
realization_delay_counter = seed;
}
}
// Append the letter to the buffer
buffer = buffer + letter;
// Write the buffer
element.innerHTML = buffer;
// Typical typing speed
var speed_lower = parseFloat(typing_speed) - parseInt(typing_jitter);
var speed_upper = parseFloat(typing_speed) + parseInt(typing_jitter);
delay = num_between(speed_lower,speed_upper);
// Chance of longer delay though
if(chance(5)) delay = num_between(100, 200);
await sleep(delay);
if(typo_active) {
realization_delay_counter--;
if(realization_delay_counter == 0) {
for (var k = 0; k < seed+1; k++) {
// Pause at realization of typo
await sleep(typing_jitter);
// Rewind the buffer!
buffer = buffer.substring(0, buffer.length - 1);
// Write rewound buffer
element.innerHTML = buffer;
// Brief pause before continuing
await sleep(30);
}
typo_active = false;
// Add the letters back
i = i - seed;
await sleep(100);
}
}
}
// Ensure any remaining typo is corrected
if(typo_active) {
await sleep(typing_jitter * 2);
for (var k = 0; k < seed+1; k++) {
buffer = buffer.substring(0, buffer.length - 1);
element.innerHTML = buffer;
await sleep(30);
}
for (var k = 0; k < seed; k++) {
buffer += text.charAt(text.length - seed + k);
element.innerHTML = buffer;
await sleep(typing_speed);
}
}
return new Promise(resolve => setTimeout(resolve, 1));
}
document.addEventListener('DOMContentLoaded', function() {
var element = document.getElementById('tagline');
var text = element.innerHTML;
typo(element, text);
});

View file

@ -8,12 +8,6 @@ numberOfRelatedPosts = 5
indexTitle = ".-. ..- -. - .. -- . - . .-. .-. --- .-." indexTitle = ".-. ..- -. - .. -- . - . .-. .-. --- .-."
darkVisitors = [
"AI Assistant",
"AI Data Scraper",
"AI Search Crawler"
]
omgUser = "jbowdre" omgUser = "jbowdre"
musicThreadId = "2aVjZUocjk96LELFbV5JvJjm14v" musicThreadId = "2aVjZUocjk96LELFbV5JvJjm14v"

View file

@ -1,14 +1,17 @@
--- ---
title: "/changelog" title: "/changelog"
date: "2024-05-26T21:19:08Z" date: "2024-05-26T21:19:08Z"
lastmod: "2024-08-02T21:16:14Z" lastmod: "2024-08-04T22:30:43Z"
description: "Maybe I should keep a log of all my site-related tinkering?" description: "Maybe I should keep a log of all my site-related tinkering?"
featured: false featured: false
toc: false toc: false
timeless: true timeless: true
categories: slashes categories: slashes
--- ---
*High-level list of config/layout changes to the site. The full changelog is of course [on GitHub](https://github.com/jbowdre/runtimeterror/commits/main/).* *Running list of config/layout changes to the site. The full changelog is of course [on GitHub](https://github.com/jbowdre/runtimeterror/commits/main/).*
**2024-08-04:**
- Dynamically build `robots.txt` based on [ai.robots.txt](https://github.com/ai-robots-txt/ai.robots.txt)
**2024-08-02:** **2024-08-02:**
- Display "pinned" recent track in sidebar using [MusicThread](https://musicthread.app) instead of latest scrobble - Display "pinned" recent track in sidebar using [MusicThread](https://musicthread.app) instead of latest scrobble

View file

@ -15,7 +15,7 @@ categories: slashes
- uses the font face [Berkeley Mono](https://berkeleygraphics.com/typefaces/berkeley-mono/) ([details](/using-custom-font-hugo/)), and icons from [Font Awesome](https://fontawesome.com/) and [Fork Awesome](https://forkaweso.me/). - uses the font face [Berkeley Mono](https://berkeleygraphics.com/typefaces/berkeley-mono/) ([details](/using-custom-font-hugo/)), and icons from [Font Awesome](https://fontawesome.com/) and [Fork Awesome](https://forkaweso.me/).
- performs syntax highlighting with [Torchlight](https://torchlight.dev) ([details](/spotlight-on-torchlight/)). - performs syntax highlighting with [Torchlight](https://torchlight.dev) ([details](/spotlight-on-torchlight/)).
- provides site search with [lunr](https://lunrjs.com/) based on an implementation detailed by [Victoria Drake](https://victoria.dev/blog/add-search-to-hugo-static-sites-with-lunr/). - provides site search with [lunr](https://lunrjs.com/) based on an implementation detailed by [Victoria Drake](https://victoria.dev/blog/add-search-to-hugo-static-sites-with-lunr/).
- uses [Dark Visitors](https://darkvisitors.com/docs/robots-txt)'s API to dynamically generate a [robots.txt](/robots.txt) discouraging AI scrapers with some Hugo code from [Luke Harris](https://github.com/lkhrs/hugo-dark-visitors). - fetches [ai.robots.txt](https://github.com/ai-robots-txt/ai.robots.txt) to dynamically generate a [robots.txt](/robots.txt) discouraging AI scrapers with Hugo's [`resources.GetRemote` capability](https://gohugo.io/functions/resources/getremote/).
- leverages [Cabin](https://withcabin.com) for [privacy-friendly](https://withcabin.com/privacy/runtimeterror.dev) analytics. - leverages [Cabin](https://withcabin.com) for [privacy-friendly](https://withcabin.com/privacy/runtimeterror.dev) analytics.
- fetches recently-played music from [MusicThread](https://musicthread.app/). - fetches recently-played music from [MusicThread](https://musicthread.app/).
- displays my latest status from [omg.lol](https://home.omg.lol/referred-by/jbowdre). - displays my latest status from [omg.lol](https://home.omg.lol/referred-by/jbowdre).

View file

@ -47,8 +47,7 @@
</button> </button>
<span class="kudos-text">Enjoyed this?</span> <span class="kudos-text">Enjoyed this?</span>
</div> </div>
{{ $kudos := resources.Get "js/kudos.js" | minify }} <script src="https://res.runtimeterror.dev/js/kudos.js" async></script>
<script src="{{ $kudos.RelPermalink }}"></script>
<span class="post_email_reply"><a href="mailto:wheel.east.brief@clkdmail.com?Subject=Re: {{ .Title }}">📧 Reply by email</a></span> <span class="post_email_reply"><a href="mailto:wheel.east.brief@clkdmail.com?Subject=Re: {{ .Title }}">📧 Reply by email</a></span>
{{- end }} {{- end }}
<footer class="content__footer"></footer> <footer class="content__footer"></footer>

View file

@ -54,12 +54,11 @@
{{ with .Site.Params.omgUser }} {{ with .Site.Params.omgUser }}
<hr> <hr>
<h3>status.lol</h3> <h3>status.lol</h3>
<script src="https://status.lol/{{ . }}.js?time&link&fluent&pretty"></script> <script src="https://status.lol/{{ . }}.js?time&link&fluent&pretty" defer></script>
{{ end }} {{ end }}
{{ with .Site.Params.musicThreadId }} {{ with .Site.Params.musicThreadId }}
<hr> <hr>
<h3>current theme song</h3> <h3>current theme song</h3>
{{ $jsThemeSong := resources.Get "js/theme-song.js" | minify }} <script src="https://res.runtimeterror.dev/js/theme-song.js?id={{ . }}" defer></script>
<script src="{{ $jsThemeSong.RelPermalink }}?id={{ . }}"></script>
{{ end }} {{ end }}

View file

@ -0,0 +1,15 @@
{{- $url := "https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/main/robots.json" -}}
{{- with resources.GetRemote $url -}}
{{- with .Err -}}
{{- errorf "%s" . -}}
{{- else -}}
{{- $robots := unmarshal .Content -}}
{{- range $botname, $props := $robots }}
{{- printf "User-agent: %s\n" $botname }}
{{- end }}
{{- printf "Disallow: /\n" }}
{{- printf "\n# (bad bots bundled by https://github.com/ai-robots-txt/ai.robots.txt)" }}
{{- end -}}
{{- else -}}
{{- errorf "Unable to get remote resource %q" $url -}}
{{- end -}}

View file

@ -1,27 +0,0 @@
{{/* borrowed from Luke Harris @ https://github.com/lkhrs/hugo-dark-visitors */}}
{{- $url := "https://api.darkvisitors.com/robots-txts" -}}
{{- $api_key := getenv "HUGO_DARKVISITORS" -}}
{{- $bearer := printf "Bearer %v" $api_key -}}
{{- $agent_types := slice -}}
{{- if .Site.Params.darkVisitors -}}
{{- range .Site.Params.darkVisitors -}}
{{- $agent_types = $agent_types | append . -}}
{{- end -}}
{{- else -}}
{{- $agent_types = slice "AI Data Scraper" -}}
{{- end -}}
{{- $agent_types := $agent_types | jsonify -}}
{{- $opts := dict
"method" "post"
"headers" (dict "Authorization" (slice $bearer) "Content-Type" "application/json")
"body" (printf `{"agent_types": %s,"disallow": "/"}` $agent_types)
-}}
{{- with resources.GetRemote $url $opts -}}
{{- with .Err -}}
{{- errorf "%s" . -}}
{{- else -}}
{{- .Content -}}
{{- end -}}
{{- else -}}
{{- errorf "Unable to get remote resource %q" $url -}}
{{- end -}}

View file

@ -13,5 +13,5 @@
<!-- Code Copy button via https://digitaldrummerj.me/hugo-add-copy-code-snippet-button/ --> <!-- Code Copy button via https://digitaldrummerj.me/hugo-add-copy-code-snippet-button/ -->
{{ if (findRE "<pre" .Content 1) }} {{ if (findRE "<pre" .Content 1) }}
{{ $jsCopy := resources.Get "js/code-copy-button.js" | minify }} {{ $jsCopy := resources.Get "js/code-copy-button.js" | minify }}
<script src="{{ $jsCopy.RelPermalink }}"></script> <script src="{{ $jsCopy.RelPermalink }}" async></script>
{{ end }} {{ end }}

View file

@ -37,7 +37,7 @@
{{ if eq .Site.Params.analytics true }} {{ if eq .Site.Params.analytics true }}
<!-- cabin analytics --> <!-- cabin analytics -->
<script async defer src="https://cabin.runtimeterror.dev/hello.js"></script> <script async src="https://cabin.runtimeterror.dev/hello.js"></script>
{{ end }} {{ end }}
<!-- syntax highlighting --> <!-- syntax highlighting -->
@ -49,5 +49,4 @@
{{ end }} {{ end }}
<!-- typo text animation --> <!-- typo text animation -->
{{ $jsTypo := resources.Get "js/typo.js" | minify }} <script src="https://res.runtimeterror.dev/js/typo.js" defer></script>
<script src="{{ $jsTypo.RelPermalink }}"></script>

View file

@ -12,6 +12,6 @@
} }
</script> </script>
{{ $jsLunr := resources.Get "js/lunr.js" | minify }} {{ $jsLunr := resources.Get "js/lunr.js" | minify }}
<script src="{{ $jsLunr.RelPermalink }}"></script> <script src="{{ $jsLunr.RelPermalink }}" async></script>
{{ $jsSearch := resources.Get "js/search.js" | minify }} {{ $jsSearch := resources.Get "js/search.js" | minify }}
<script src="{{ $jsSearch.RelPermalink }}"></script> <script src="{{ $jsSearch.RelPermalink }}" async></script>

View file

@ -8,4 +8,4 @@ Disallow:
# except for these bots which are not friends: # except for these bots which are not friends:
{{ partial "dark-visitors.html" . }} {{ partial "bad-robots.html" . }}

View file

@ -444,6 +444,7 @@ p:has(+ ul) {
.kudos-button:disabled { .kudos-button:disabled {
cursor: default; cursor: default;
color: var(--fg);
} }
.kudos-button .emoji { .kudos-button .emoji {