66 lines
1.7 KiB
HTML
66 lines
1.7 KiB
HTML
{{/* Source: https://gitlab.com/Roneo/hugo-shortcode-roneo-collection */}}
|
|
|
|
{{- $src := .Get 0 -}}
|
|
|
|
{{/* Convert URL from archive.org/details/foo to archive.org/metadata/foo */}}
|
|
{{ $archiveMetadata := replace $src "/details/" "/metadata/" }}
|
|
|
|
{{/* Get JSON */}}
|
|
{{ $dataJ := getJSON $archiveMetadata }}
|
|
|
|
{{- $identifier := $dataJ.metadata.identifier -}}
|
|
{{- $root := "https://archive.org/download" -}}
|
|
|
|
{{ "<!-- Shortcode 'audio-archive.html' -->" | safeHTML }}
|
|
|
|
<style>
|
|
|
|
.audio-treeview {
|
|
list-style: none;
|
|
padding-bottom: 2em;
|
|
}
|
|
|
|
.audio-treeview li {
|
|
padding-top: 2em;
|
|
}
|
|
|
|
.audio-treeview li figure {
|
|
padding-top: 1em;
|
|
}
|
|
|
|
</style>
|
|
|
|
<ul class="audio-treeview">
|
|
{{ range $dataJ.files }}
|
|
|
|
{{/* Show Audio files only */}}
|
|
{{ if or (eq .format "VBR MP3") (eq .format "MPEG-4 Audio") }}
|
|
{{/* Only MP3: */}}
|
|
{{/* {{ if eq .format "VBR MP3" }} */}}
|
|
<li>
|
|
{{$path := print $root "/" $identifier "/" .name}}
|
|
{{/* <a href="{{ $path }}" target="_blank" aria-label="Download {{ index .name }}" download>{{ index .name }}</a> */}}
|
|
{{/* "index .name:" {{ index .name }} <br> */}}
|
|
|
|
{{/* Remove folder from path */}}
|
|
{{ $fileHeading := replaceRE ".*/" "" .name }}
|
|
{{/* Remove file extension and display */}}
|
|
{{ strings.TrimSuffix (path.Ext $fileHeading) $fileHeading }}
|
|
|
|
{{/* Embed HTML player */}}
|
|
<figure>
|
|
<audio controls class="player">
|
|
<source src="{{- $path -}}" type="audio/mpeg">
|
|
</audio>
|
|
</figure>
|
|
|
|
{{/* Add a label depending on metadata */}}
|
|
{{/* {{ if in .source "original" }}
|
|
<b>ORIGINAL</b>
|
|
{{ end }} */}}
|
|
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
</ul>
|