Skip to main content

This is a new website theme. Help me improve it and give your feedback (opens in a new tab).

Shortcodes for my Weekly Reports

Published:

Tags:

Hugo Debian Tor Foss
This blog post is more than two years old. It is preserved here in the hope that it is useful to someone, but please be aware that links may be broken and that opinions expressed here may not reflect my current views. If this is a technical article, it may no longer reflect current best practice.

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: