various fixes for Amfora and hugo-embedded stuff in Gemini

This commit is contained in:
Wouter Groeneveld 2021-04-03 20:39:27 +02:00
parent d978a39b8d
commit 6d931a19eb
3 changed files with 20 additions and 6 deletions

View File

@ -11,7 +11,7 @@ categories:
- webdesign
---
As you may have read, I'm quite the [Hugo.io fan](/post/hugo-extended) and I build all my websites using this static website generator. As cool and tech-savvy it is, projects like [forestry.io](https://forestry.io/) exist to leverage Hugo's powers into the world of teams an non-technical bloggers. However, it still requires things like _committing_ and does not come with a lot of custom design options.
As you may have read, I'm quite the [Hugo.io fan](/post/2020/05/hugo-extended/) and I build all my websites using this static website generator. As cool and tech-savvy it is, projects like [forestry.io](https://forestry.io/) exist to leverage Hugo's powers into the world of teams an non-technical bloggers. However, it still requires things like _committing_ and does not come with a lot of custom design options.
My wife has been blogging on and off for more than five years now, and she's been using things like Blogspot, Webnode, Wix and Wordpress. Not content with any of those, about a month ago she started creating yet another blog, calling in my help with the code portions. She's never content with the design options the free templates offer, and would like to design things herself, without having a lot of knowledge of CSS/HTML.
@ -140,7 +140,7 @@ Yup:
Brizy duplicates images from global bocks for each page, and for each page, Brizy duplicates images for each (mobile) device used in `srcset` attributes of `img` tags. `26` images for one page ID.
There goes my [nginx caching strategy](/post/vps). What a mess. Should I write a bash script to create symlinks? That does not change anything for the clientside webbrowser. What a mess.
There goes my [nginx caching strategy](/post/2020/04/vps/). What a mess. Should I write a bash script to create symlinks? That does not change anything for the clientside webbrowser. What a mess.
### So, trash Brizy and use something else?

View File

@ -47,4 +47,12 @@ I'm quite pleased with the result, although the code itself is far from pretty,
I tried to design the index and single layout files as similar as possible to their html variants, while focusing in simplicity. Related articles are also visible at the end of an article, and the index file simply contains a short bio followed by an overview of all posts, groupbed by year and month, just like in my [html /post overview](/post). After defining `[outputFormats.GEMINI]` in my Hugo `config.toml`, all that was left is to use `rsync` to copy over the gemini subfolder to an appropriate location that gets picked up by Agate. Job done!
Now, the the most important question, "why publish on Gemini" could be answered with "because it's easy!". I'm not yet sure if that answer is very satisfactory, but at least Brain Baking got launched in Space today! All that is left is to submit it to the GUS Gemini Universal Search engine...
Well, not entirely. My Markdown files are littered with surprisingly Hugo-specific junk:
- Shortcodes, such as YouTube, embedded video or audio.
- Four hashes - `h4` - which isn't supported by the Gemini protocol.
- `<span/>` tags in my quotes that help with HTML markup.
Also, after trying out a second Gemini client, the terminal-friendly [Amfora](https://github.com/makeworld-the-better-one/amfora), I noticed the reference numbers do not align with Amfora's shortcut keys that allow you to quickly navigate to a link. Reference 1 would match to key 2. Why? Because an image is also converted to a link (`=> url`), wich is placed in-between text, while the actual references are at the bottom. Hence, pressing number one would let us download the image - except Amfora can't handle that (yet). I solved this by starting at a specific index, based on the number of times the arrow notation is present in the `.gmi` file, before processing inline links. These are all things to take into account when writing future posts.
Now, the the most important question, _"why publish on Gemini"_ could be answered with "because it's easy!". I'm not yet sure if that answer is very satisfactory, but at least Brain Baking got launched in Space today! All that is left is to submit it to the GUS Gemini Universal Search engine...

View File

@ -1,12 +1,18 @@
# {{ .Title }}{{ $scratch := newScratch }}{{ $scratch.Set "ref" 1 }}
# {{ .Title }}{{ $scratch := newScratch }}
{{ $content := .RawContent -}}
{{ $content := $content | replaceRE "`(.+?)`" "$1" -}}{{ $content := $content | replaceRE "`" "```" -}}
{{ $content := $content | replaceRE `\*\*(.+?)\*\*` "$1" -}}
{{ $content := $content | replaceRE `_(.+?)_` "$1" -}}
{{ $content := $content | replaceRE `#### ` "### " -}}
{{ $content := $content | replaceRE `<span>(.+?)</span>` "-- $1" -}}
{{ $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}}
{{ $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}}
{{ $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}}
{{ $content := $content | replaceRE `!\[\]\((.+?) \"(.+?)\"\)` "=> $1 Image: $2" -}}
{{ $content := $content | replaceRE `{{< audio "(.+?)" >}}` "=> https://brainbaking.com/$1 Embedded Audio link - $1" -}}
{{ $content := $content | replaceRE `{{< video "(.+?)" >}}` "=> https://brainbaking.com/$1 Embedded Video link - $1" -}}
{{ $content := $content | replaceRE `{{< youtube (.+?) >}}` "=> https://www.youtube.com/watch?v=$1 YouTube link to $1" -}}
{{ $content := $content | replaceRE `!\[.*\]\((.+?) \"(.+?)\"\)` "=> $1 Image: $2" -}}
{{ $links := findRE `\n=> ` $content }}{{ $scratch.Set "ref" (add (len $links) 1) }}
{{ $refs := findRE `\[.+?\]\(.+?\)` $content }}
{{ $scratch.Set "content" $content }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $contentInLoop := $scratch.Get "content" }}{{ $url := (printf "%s #%d" . $ref) }}{{ $contentInLoop := replace $contentInLoop . $url -}}{{ $scratch.Set "content" $contentInLoop }}{{ $scratch.Set "ref" (add $ref 1) }}{{ end }}{{ $content := $scratch.Get "content" | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$1 [$3]" -}}
{{ $content }}
@ -15,7 +21,7 @@
Written by Wouter Groeneveld on {{ .Lastmod.Format (.Site.Params.dateFormat | default "2 January 2006") }}.
## References
{{ $scratch.Set "ref" 1 }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $url := (printf "%s #%d" . $ref) }}
{{ $scratch.Set "ref" (add (len $links) 1) }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $url := (printf "%s #%d" . $ref) }}
=> {{ $url | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$2 [$3] $1 ($2)" -}}
{{ $scratch.Set "ref" (add $ref 1) }}{{ end}}
{{ $related := first 3 (where (where .Site.RegularPages.ByDate.Reverse ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}