Compare commits

...

4 Commits

Author SHA1 Message Date
hedy d365e1ca4c
Use UTC everywhere 2024-04-11 19:36:01 +08:00
hedy 60141b41d2
Better place to show tags in gemini 2024-04-11 18:53:53 +08:00
hedy e211f5d41f
Show tags in gemini post listing 2024-04-11 18:30:17 +08:00
hedy 858544b7d6
Use prettier, more resilient tag listing for WWW
And document requirements in the readme
2024-04-11 18:25:50 +08:00
22 changed files with 78 additions and 41 deletions

View File

@ -2,6 +2,8 @@ HUGO=hugo
HUGO_CACHEDIR=~/hugo_cache
HUGO_FLAGS=--cleanDestinationDir
PRETTIER=prettier
RSYNC=rsync
RSYNC_FLAGS=-a
@ -55,6 +57,7 @@ html:
$(RSYNC) $(RSYNC_FLAGS) public/ --exclude '*.gmi' --exclude gemini $(HTML_DEST)
@# Manually include gemini tag (because it was excluded above)
$(RSYNC) $(RSYNC_FLAGS) public/tags/gemini $(HTML_DEST)/tags/
$(PRETTIER) --write $(HTML_DEST)"/**/*.html"
finish-clean:
rm -rf $(GEMINI_DEST)-back $(HTML_DEST)-back

View File

@ -20,8 +20,35 @@ design. It has a few custom colors, a sans-serif font stack, and some styling in
the footer and nav. Everything else is partially based on top of [simple
css](https://simplecss.org) and sometimes [seirdy's site](https://seirdy.one).
## requirements
### build
- **hugo** - generate files
- **rsync** - separate HTML & gemini files into dedicated destinations
perhaps I'll just switch to plain copying in the future. This was a relic of
the old deployment system where I kept some extra files (such as CGI scripts)
in the destination which should not be deleted.
what this means is that I'll have to do `rm -rf DEST/*` periodically to clean
up old files
- **python3** - postprocessing on the gemini files
- **prettier** - format HTML files
this requires my template HTMl files not rely on newline for spacing.
to test, simply remove the prettier command from Makefile, run `make gen &&
mkdir public2 && cp -r public public2` and run prettier on `public2`, make
sure everything in `public2` looks the same as `public`.
### deploy
- **hut** - publishes HTML/gemini files to srht.site
## hardcoded values
### resources
In WWW, posts' resources are stored under the same directory as the post:
- `/posts/my-slug/index.html` (the post itself)
- `/posts/my-slug/resource-1.png`
@ -40,28 +67,26 @@ These files might need to be changed to customize this:
- [x] let gemini version also have a post page at /posts/index.gmi
- [ ] minify images and use WebP
- [ ] lint
- [ ] better a11y
- [x] provide atom feed for www
- [x] show post description in list
- [ ] proper reply via email link
## writing
## Workflows
### posts
```sh
bin/post
```
## deploy
resources should be put in the same directory as the post. Link to them within
markdown ad gemini files using the `get-resource-link.{gmi|html}` shortcode
which returns the relative permalink of the file. (see [resources](#resources).)
Also see [gemcgi](https://git.sr.ht/~hedy/gemcgi)
### deploy
```sh
make all deploy
```
### twtxt
Hardcodes destination host and gemini directory.
```sh
bin/twt
```

View File

@ -1,6 +1,6 @@
+++
title = '{{ replace .Name '-' ' ' | title }}'
date = {{ .Date.Format "2006-01-02" }}
date = {{ .Date.UTC.Format "2006-01-02" }}
draft = true
outputs = ['html', 'gemtext']
slug = {{ .Name }}

View File

@ -2,10 +2,11 @@
{{ $title := slicestr (replace .Name "-" " ") 11 -}}
title = {{ $title | title }}
description = {{ strings.FirstUpper $title }}
tags = []
highlight = false
draft = true
date = {{ .Date.Format "2006-01-02T15:04:05Z" }}
date = {{ .Date.UTC.Format "2006-01-02T15:04:05Z" }}
draft = true
outputs = ['html', 'gemtext']
# Filename after the date

View File

@ -1,6 +1,7 @@
baseURL = "https://home.hedy.dev/"
languageCode = "en-us"
title = "~hedy's home"
languageCode = "en-us"
timeZone = "UTC"
# Yes. Because I like the /folder -> /folder/ redirects
uglyurls = false

View File

@ -3,7 +3,7 @@ date = '2021-02-05T01:44:15Z'
description = "I'm alive!"
draft = false
outputs = ['html', 'gemtext']
tags = ['test']
tags = []
title = 'Hello world'
slug = 'hello'
+++

View File

@ -3,6 +3,7 @@ date = '2021-02-23'
description = 'A walkthrough of my workflows for the site and a gentle introduction to tilde.cafe and the Tildeverse.'
draft = false
outputs = ['html', 'gemtext']
tags = ['meta']
slug = 'site-meta'
title = 'How this site works'
+++

View File

@ -5,7 +5,7 @@ draft = false
highlight = true
outputs = ['html', 'gemtext']
slug = 'multiple-emails-git'
tags = ['git', 'howto']
tags = ['howto', 'git']
title = 'Managing multiple emails for git across different computers'
+++

View File

@ -5,7 +5,7 @@ draft = false
highlight = true
outputs = ['html', 'gemtext']
slug = 'hugo-syntax-highlighting'
tags = ['howto']
tags = ['howto', 'hugo']
title = 'Setting up syntax highlighting for Hugo'
+++

View File

@ -5,7 +5,7 @@ draft = false
footnotes_heading = 'Footnotes'
outputs = ['html', 'gemtext']
slug = 'vim-column-editing'
tags = ['howto']
tags = ['howto', 'terminal']
title = 'Vim visual block mode for column editing'
EOF = false
+++

View File

@ -22,7 +22,7 @@
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<lastBuildDate>{{ .Date.UTC.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .RelPermalink .MediaType | safeHTML }}
{{- end }}
@ -31,7 +31,7 @@
<item>
<title>{{ .Title }}</title>
<link>{{ .RelPermalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<pubDate>{{ .Date.UTC.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .RelPermalink }}</guid>
<description>{{ .Content | html }}</description>

View File

@ -10,7 +10,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>hedy's blog</title>
<link href="{{ .RelPermalink }}"/>
<updated>{{ time.Now | time.Format "2006-01-02" | safeHTML }}T12:00:00Z</updated>
<updated>{{ time.Now.UTC | time.Format "2006-01-02T15:04:05Z" | safeHTML }}</updated>
<id>{{ .RelPermalink }}</id>
<author>
<name>{{ $.Site.Author.name }}</name>
@ -22,7 +22,7 @@
<title>{{ .Title }}</title>
{{ printf `<link rel="alternate" href="%s" />` .RelPermalink | safeHTML }}
<id>{{ .RelPermalink }}</id>
<updated>{{ .Date.Format "2006-01-02" }}T12:00:00Z</updated>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z" }}</updated>
<author>
<name>{{ $.Site.Author.name }}</name>
<email>{{ $.Site.Author.email }}</email>

View File

@ -10,7 +10,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>hedy's gemlog</title>
<link href="{{ .Site.Params.geminiRoot }}"/>
<updated>{{ time.Now | time.Format "2006-01-02" | safeHTML }}T12:00:00Z</updated>
<updated>{{ time.Now.UTC | time.Format "2006-01-02T15:04:05Z" | safeHTML }}</updated>
<id>{{ .Site.Params.geminiRoot }}</id>
<author>
<name>{{ $.Site.Author.name }}</name>
@ -24,7 +24,7 @@
<title>{{ $p.Title }}</title>
{{ printf `<link rel="alternate" href="%s" />` $perm | safeHTML }}
<id>{{ $perm }}</id>
<updated>{{ $p.Date.Format "2006-01-02" }}T12:00:00Z</updated>
<updated>{{ $p.Date.Format "2006-01-02T15:04:05Z" }}</updated>
<author>
<name>{{ $.Site.Author.name }}</name>
<email>{{ $.Site.Author.email }}</email>

View File

@ -4,7 +4,7 @@
{{ $lastmod := .Lastmod -}}
{{ if lt .Date $lastmod -}}
Last updated {{ .Lastmod.Format "2006-01-02" }}{{ end }}
Last updated {{ .Lastmod.UTC.Format "2006-01-02" }}{{ end }}
--
{{ trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML }}

View File

@ -4,10 +4,10 @@
<meta name="author" content="{{ .Site.Author.name }}">
<meta property="article:author" content="{{ .Site.Author.name }}">
{{ if gt .Date 0 -}}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
<meta property="article:published_time" content="{{ .Date.UTC.Format "2006-01-02T15:04:05Z" | safeHTML }}">
{{ end -}}
{{ if lt .Date .Lastmod -}}
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
<meta property="article:modified_time" content="{{ .Lastmod.UTC.Format "2006-01-02T15:04:05Z" | safeHTML }}">
{{- end -}}
<!--Have concerns? Drop me an email with your constructive criticism.-->
<script data-goatcounter="https://ultimategopher.goatcounter.com/count"

View File

@ -1,4 +1,4 @@
{{ if lt .Page.Date .Page.Lastmod -}}
{{ .Prefix | safeHTML }}Last updated on
<time itemprop="dateModified" class="dt-updated">{{ .Page.Lastmod.Format "Jan 2, 2006" }}</time>
<time itemprop="dateModified" class="dt-updated">{{ .Page.Lastmod.UTC.Format "Jan 2, 2006" }}</time>
{{- end -}}

View File

@ -11,5 +11,5 @@
{{ range (where .Site.RegularPages "Section" "posts") }}
{{- if .OutputFormats.Get "gemtext" }}
=> {{replace (replace .RelPermalink "/gemini" "" 1) "/index.gmi" ".gmi" 1}} {{ .Date.Format "2006-01-02" }} · {{.Title | safeHTML}}{{ end }}
{{ .Description }}
{{ .Description }}{{ partial "tags.gmi" (dict "Page" . "Prefix" " (tagged " "Postfix" ")") -}}
{{ end -}}

View File

@ -31,8 +31,8 @@
{{ end -}}
<p class="post-meta">
<time datetime="{{ .Date.Format "2006-01-02 15:04:05Z07:00" }}">{{ .Date.Format "Jan 02, 2006" }}</time>
&nbsp;·&nbsp; {{ partial "tags.html" . }}
</p>
{{- partial "tags.html" (dict "Page" . "Prefix" "&nbsp; · &nbsp;") -}}
</p>
<p class="desc">{{ .Description }}</p>
</li>
{{- end }}

View File

@ -1,4 +1,4 @@
{{- $taxonomy := "tags" }}
{{- with .Param $taxonomy }}
Tagged{{ range $index, $tag := . -}}{{- with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}{{ if (not $index) }}{{ printf " " }}{{ end }}{{ $tag | urlize }}{{ end }}{{ end }}{{- end }}
{{ $taxonomy := "tags" -}}
{{ with .Page.Param $taxonomy -}}{{ with $.Prefix }}{{ . | safeHTML }}{{ end }}
{{- range $index, $tag := . -}}{{- with $.Page.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}#{{ $tag | urlize }}{{ end }}{{ end }}{{ with $.Postfix }}{{ . | safeHTML }}{{ end }}{{ end }}

View File

@ -1,5 +1,11 @@
{{ $taxonomy := "tags" -}}
{{ with .Param $taxonomy -}}<span class="tags">
{{ range $index, $tag := . -}}{{- with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}<a href="{{ .RelPermalink }}">{{ $tag | urlize }}</a>{{- end -}}{{- end }}
</span>{{- end -}}
{{ $tags := .Page.Param $taxonomy -}}
{{ if (len $tags) -}}
{{ with $.Prefix }}{{ . | safeHTML -}}{{ end -}}
<span class="tags">
{{- range $index, $tag := $tags -}}
{{- $taglink := $.Page.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}<a href="{{ $taglink.RelPermalink }}">{{ $tag | urlize }}</a>
{{- end }}
</span>
{{- end }}

View File

@ -1,7 +1,7 @@
{{ define "content" -}}
# {{ $.Title }}
{{ .Date.Format "Jan 02, 2006" }} · {{ .WordCount }} words
{{ .Date.UTC.Format "Jan 02, 2006" }} · {{ .WordCount }} words
{{ partial "lastmod.gmi" (dict "Page" . "Postfix" ".") }}
--
{{ partial "processed-content.gmi" . }}

View File

@ -6,7 +6,7 @@
<div class="post-meta">
<p>
<time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "Jan 02, 2006" }}</time>
{{ partial "lastmod.html" (dict "Page" . "Prefix" "&nbsp;·&nbsp;" ) }}
{{- partial "lastmod.html" (dict "Page" . "Prefix" "&nbsp; · &nbsp;" ) }}
&nbsp;·&nbsp; {{ .WordCount }} words
</p>
<hr>