Browse Source

Support posting songs

So far only audio files are supported, but we could also add support for
embeds from SoundCloud, and possibly other services.
Lucas Stadler 9 years ago
parent
commit
1b85e11f27
2 changed files with 24 additions and 0 deletions
  1. 21 0
      go/blog/blog.go
  2. 3 0
      go/blog/blog.yaml

+ 21 - 0
go/blog/blog.go

@ -121,6 +121,8 @@ func main() {
121 121
			err = linkTmpl.Execute(os.Stdout, post)
122 122
		case "image":
123 123
			err = imageTmpl.Execute(os.Stdout, post)
124
		case "song":
125
			err = songTmpl.Execute(os.Stdout, post)
124 126
		default:
125 127
			fmt.Fprintf(os.Stderr, "Error: no output for type '%s'\n", post.Type)
126 128
			os.Exit(1)
@ -195,6 +197,25 @@ var imageTmpl = template.Must(template.New("image").
195 197
</article>
196 198
`))
197 199
200
var songTmpl = template.Must(template.New("song").
201
	Funcs(funcs).Parse(`
202
<article id="{{ .Id }}" class="song">
203
	{{- if .Title }}
204
	<header>
205
		<h1>{{ .Title }}</h1>
206
		{{- if .Date }}<time>{{ .Date }}</time>{{ end -}}
207
	</header>
208
	{{- end }}
209
	<audio src="{{ safe_url .URL }}" controls>
210
		Your browser can't play {{ .URL }}.
211
	</audio>
212
	{{- if .Content }}
213
214
	{{ markdown .Content }}
215
	{{- end -}}
216
</article>
217
`))
218
198 219
func exit(err error) {
199 220
	fmt.Fprintf(os.Stderr, "Error: %s\n", err)
200 221
	os.Exit(1)

+ 3 - 0
go/blog/blog.yaml

@ -14,3 +14,6 @@
14 14
- url: file:///home/lu/m/pictures/inspiration/empartridge-anything.jpg
15 15
  content: By [@empartridge](http://empartridge.tumblr.com).
16 16
  type: image
17
- url: file:///home/lu/m/musique/DRALMS/Shook/05 - Shook.mp3
18
  content: Shook, by DRALMS.
19
  type: song