Shortcodes for my Weekly Reports
Published:
I’ve been writing weekly reports on my free software activities for over a month now, so I’m looking at ways of making these easier to write. Each review takes about an hour to write up, and I’m spending enough time formatting links to packages and bug reports that I’ve written some Hugo shortcodes to help.
For Debian:
{{ with ( .Get "bug" ) }}{{ range ( first 1 ( split . "," ) ) }}<a href="https://bugs.debian.org/{{ . }}">#{{ . }}</a>{{ end }}{{ if ( ( gt ( len ( split . "," ) ) 1 ) ) }}{{ range ( after 1 ( split . "," ) ) }}, <a href="https://bugs.debian.org/{{ . }}">#{{ . }}</a>{{ end }}{{ end }}{{ end }}
{{ with ( .Get "src" ) }}{{ range ( first 1 ( split . "," ) ) }}<a href="https://packages.debian.org/source/sid/{{ . }}">{{ . }}</a>{{ end }}{{ if ( ( gt ( len ( split . "," ) ) 1 ) ) }}{{ range ( after 1 ( split . "," )) }}, <a href="https://packages.debian.org/source/sid/{{ . }}">{{ . }}</a>{{ end }}{{ end }}{{ end }}
{{ with ( .Get "pkg" ) }}{{ range ( first 1 ( split . "," ) ) }}<a href="https://packages.debian.org/sid/{{ . }}">{{ . }}</a>{{ end }}{{ if ( ( gt ( len ( split . "," ) ) 1 ) ) }}{{ range ( after 1 ( split . "," )) }}, <a href="https://packages.debian.org/sid/{{ . }}">{{ . }}</a>{{ end }}{{ end }}{{ end }}
For Tor Project:
{{ with ( .Get "bug" ) }}{{ range ( first 1 ( split . "," ) ) }}<a href="https://bugs.torproject.org/{{ . }}">#{{ . }}</a>{{ end }}{{ if ( ( gt ( len ( split . "," ) ) 1 ) ) }}{{ range ( after 1 ( split . "," ) ) }}, <a href="https://bugs.torproject.org/{{ . }}">#{{ . }}</a>{{ end }}{{ end }}{{ end }}
So now I can write things like:
* {{< debian bug="759639" >}}
* {{< debian bug="739609,759639" >}}
* {{< debian pkg="direwolf" >}}
* {{< debian src="direwolf" >}}
* {{< tor bug="20869" >}}
and I’ll get: