initial
This commit is contained in:
parent
18df5aeab5
commit
63246546b3
24 changed files with 207 additions and 97 deletions
|
@ -40,22 +40,12 @@ params:
|
|||
# title: ""
|
||||
# episode_type: "" # podcast field: itunes:episodeType ; one of "Full", "Trailer" or "Bonus"
|
||||
# transcript: # podcast field: podcast:transcript
|
||||
# - formats
|
||||
# srt:
|
||||
# external_url: "" # URL to the transcript file
|
||||
# resource_file: "" # URL to the transcript file
|
||||
# webvtt:
|
||||
# external_url: "" # URL to the transcript file
|
||||
# resource_file: "" # URL to the transcript file
|
||||
# json:
|
||||
# external_url: "" # URL to the transcript file
|
||||
# resource_file: "" # URL to the transcript file
|
||||
# html:
|
||||
# external_url: "" # URL to the transcript file
|
||||
# resource_file: "" # URL to the transcript file
|
||||
# podlove:
|
||||
# external_url: "" # URL to the transcript file
|
||||
# resource_file: "" # URL to the transcript file
|
||||
# - content: "" # YAML file containing the transcript
|
||||
# external_content: # url of the remote content to use as is in different format
|
||||
# srt: ""
|
||||
# webvtt: ""
|
||||
# html: ""
|
||||
# json: ""
|
||||
# language: fr # optional; if omitted, language is the same as the podcast language attribute
|
||||
# rel: "captions" # ; optional ; only valid value is "captions"; indicates that this transcript contains time codes
|
||||
# funding: # podcast field: podcast:funding
|
||||
|
|
|
@ -1 +1 @@
|
|||
<hr/>
|
||||
{{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "html") -}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"json": true}
|
||||
{{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "json") -}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"pod": "love"}
|
||||
{{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "podlove") -}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
bla
|
||||
{{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "srt") -}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
WEBVTT
|
||||
{{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "webvtt") -}}
|
||||
|
|
13
layouts/partials/timecode_to_ms.tmpl
Normal file
13
layouts/partials/timecode_to_ms.tmpl
Normal file
|
@ -0,0 +1,13 @@
|
|||
{{- $retvalue := 0 -}}
|
||||
{{- $parts := strings.Split . ":" -}}
|
||||
{{- if ne (len $parts) 3 -}}
|
||||
{{- errorf "invalid timestamp %q" . -}}
|
||||
{{- else -}}
|
||||
{{- $hours := collections.Index $parts 0 | cast.ToInt -}}
|
||||
{{- $minutes := collections.Index $parts 1 | cast.ToInt -}}
|
||||
{{- $parts2 := strings.Split (collections.Index $parts 2) "," -}}
|
||||
{{- $seconds := collections.Index $parts2 0 | cast.ToInt -}}
|
||||
{{- $milliseconds := collections.Index $parts2 1 | cast.ToInt -}}
|
||||
{{- $retvalue = math.Add $retvalue (math.Mul $hours 3600 1000) (math.Mul $minutes 60 1000) (math.Mul $seconds 1000) $milliseconds -}}
|
||||
{{- end -}}
|
||||
{{- return $retvalue -}}
|
|
@ -1,13 +1,12 @@
|
|||
{{- $resource := collections.Index . "resource" -}}
|
||||
{{- $url := collections.Index . "resource" -}}
|
||||
{{- $type := collections.Index . "type" -}}
|
||||
{{- $lang := collections.Index . "lang" -}}
|
||||
{{- $rel := collections.Index . "rel" -}}
|
||||
{{- $episode_page := collections.Index . "episode_page" -}}
|
||||
{{- $indent := collections.Index . "indent" -}}
|
||||
|
||||
{{- $url := partial "external_or_local.rss.xml" (dict "context" $resource "ref_page" $episode_page) -}}
|
||||
{{- strings.Repeat $indent " " -}}
|
||||
<podcast:transcript url="{{- $url | transform.XMLEscape -}}" type="{{- . | transform.XMLEscape -}}"
|
||||
<podcast:transcript url="{{- $url | transform.XMLEscape -}}" type="{{- $type | transform.XMLEscape -}}"
|
||||
|
||||
{{- with $lang -}}
|
||||
{{- " " | safe.HTMLAttr -}}
|
||||
|
|
18
layouts/partials/transcript_content/dispatcher.tmpl
Normal file
18
layouts/partials/transcript_content/dispatcher.tmpl
Normal file
|
@ -0,0 +1,18 @@
|
|||
{{- $ctx := . -}}
|
||||
{{- if reflect.IsMap $ctx -}}
|
||||
{{- with $ctx.episode.Params.transcript -}}
|
||||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- if eq .language $ctx.episode.Lang -}}
|
||||
{{- $resource_name := .content -}}
|
||||
{{- with $ctx.episode.Resources.Get $resource_name -}}
|
||||
{{- $transcript := . | transform.Unmarshal -}}
|
||||
{{- partial (printf "transcript_content/%s.tmpl" $ctx.format) $transcript -}}
|
||||
{{- else -}}
|
||||
{{- errorf "failed to get resource %q for episode %q" $resource_name $ctx.episode.Title -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
20
layouts/partials/transcript_content/html.tmpl
Normal file
20
layouts/partials/transcript_content/html.tmpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- with .speaker -}}
|
||||
<cite>{{- . | transform.HTMLEscape -}}</cite>
|
||||
{{- "\n" -}}
|
||||
{{- end -}}
|
||||
{{- with .start -}}
|
||||
<time>{{- strings.Replace . "," "." | transform.HTMLEscape -}}</time>
|
||||
{{- "\n" -}}
|
||||
{{- end -}}
|
||||
<p>
|
||||
{{- .line | transform.HTMLEscape -}}
|
||||
{{- with .line2 -}}
|
||||
{{- " " | transform.HTMLEscape -}}
|
||||
{{- . | transform.HTMLEscape -}}
|
||||
{{- end -}}
|
||||
</p>
|
||||
{{- "\n" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
25
layouts/partials/transcript_content/json.tmpl
Normal file
25
layouts/partials/transcript_content/json.tmpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{- $segments := slice -}}
|
||||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- $start_ms := partial "timecode_to_ms.tmpl" .start -}}
|
||||
{{- $end_ms := partial "timecode_to_ms.tmpl" .end -}}
|
||||
{{- $start_secs := math.Div $start_ms 1000.0 -}}
|
||||
{{- $end_secs := math.Div $end_ms 1000.0 -}}
|
||||
{{- $concat := true -}}
|
||||
{{- if and .speaker2 (ne .speaker .speaker2) -}}
|
||||
{{- $entry := dict "startTime" $start_secs "endTime" $end_secs "speaker" .speaker "body" .line -}}
|
||||
{{- $entry2 := dict "startTime" $start_secs "endTime" $end_secs "speaker" .speaker2 "body" .line2 -}}
|
||||
{{- $segments = collections.Append $entry $entry2 $segments -}}
|
||||
{{- $concat = false -}}
|
||||
{{- end -}}
|
||||
{{- if $concat -}}
|
||||
{{- $body := .line -}}
|
||||
{{- if .line2 -}}
|
||||
{{- $body = printf "%s %s" $body .line2 -}}
|
||||
{{- end -}}
|
||||
{{- $entry := dict "startTime" $start_secs "endTime" $end_secs "speaker" .speaker "body" $body -}}
|
||||
{{- $segments = collections.Append $entry $segments -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- dict "version" "1.0.0" "segments" $segments | encoding.Jsonify (dict "indent" " ") -}}
|
25
layouts/partials/transcript_content/podlove.tmpl
Normal file
25
layouts/partials/transcript_content/podlove.tmpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{- $segments := slice -}}
|
||||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- $start_dot := strings.Replace .start "," "." -}}
|
||||
{{- $end_dot := strings.Replace .end "," "." -}}
|
||||
{{- $start_ms := partial "timecode_to_ms.tmpl" .start -}}
|
||||
{{- $end_ms := partial "timecode_to_ms.tmpl" .end -}}
|
||||
{{- $concat := true -}}
|
||||
{{- if and .speaker2 (ne .speaker .speaker2) -}}
|
||||
{{- $entry := dict "start" $start_dot "start_ms" $start_ms "end" $end_dot "end_ms" $end_ms "speaker" "" "voice" .speaker "text" .line -}}
|
||||
{{- $entry2 := dict "start" $start_dot "start_ms" $start_ms "end" $end_dot "end_ms" $end_ms "speaker" "" "voice" .speaker2 "text" .line2 -}}
|
||||
{{- $segments = collections.Append $entry $entry2 $segments -}}
|
||||
{{- $concat = false -}}
|
||||
{{- end -}}
|
||||
{{- if $concat -}}
|
||||
{{- $text := .line -}}
|
||||
{{- if .line2 -}}
|
||||
{{- $text = printf "%s %s" $text .line2 -}}
|
||||
{{- end -}}
|
||||
{{- $entry := dict "start" $start_dot "start_ms" $start_ms "end" $end_dot "end_ms" $end_ms "speaker" "" "voice" .speaker "text" $text -}}
|
||||
{{- $segments = collections.Append $entry $segments -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $segments | encoding.Jsonify (dict "indent" " ") -}}
|
13
layouts/partials/transcript_content/srt.tmpl
Normal file
13
layouts/partials/transcript_content/srt.tmpl
Normal file
|
@ -0,0 +1,13 @@
|
|||
{{- $counter := 1 -}}
|
||||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- printf "%d\n" $counter -}}
|
||||
{{- printf "%s --> %s\n" .start .end | safe.HTML -}}
|
||||
{{- printf "%s\n" .line | safe.HTML -}}
|
||||
{{- with .line2 -}}
|
||||
{{- printf "%s\n" . | safe.HTML -}}
|
||||
{{- end -}}
|
||||
{{- "\n" -}}
|
||||
{{- end -}}
|
||||
{{- $counter = add $counter 1 -}}
|
||||
{{- end -}}
|
24
layouts/partials/transcript_content/webvtt.tmpl
Normal file
24
layouts/partials/transcript_content/webvtt.tmpl
Normal file
|
@ -0,0 +1,24 @@
|
|||
WEBVTT
|
||||
{{- "\n\n" -}}
|
||||
{{- range . -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- printf "%s --> %s\n" .start .end | safe.HTML -}}
|
||||
{{- with .speaker -}}
|
||||
{{- printf "<v %s>" (. | transform.HTMLEscape) | safe.HTML -}}
|
||||
{{- end -}}
|
||||
{{- printf "%s" .line | safe.HTML -}}
|
||||
{{- if .line2 -}}
|
||||
{{- $to_print := true -}}
|
||||
{{- if .speaker2 -}}
|
||||
{{- if ne .speaker .speaker2 -}}
|
||||
{{- printf "</v><v %s>%s</v>" (.speaker2 | transform.HTMLEscape) .line | safe.HTML -}}
|
||||
{{- $to_print = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $to_print -}}
|
||||
{{- printf " %s" .line2 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- "\n\n" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -1,4 +1,5 @@
|
|||
<h1>{{ printf (T "welcome") .Title }}</h1>
|
||||
<header><h1>{{ printf (T "welcome") .Title }}</h1></header>
|
||||
<nav>
|
||||
{{- $season_cnt := 0 -}}
|
||||
{{- $season_lst := slice -}}
|
||||
{{- range .Sections -}}
|
||||
|
@ -8,18 +9,31 @@
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if gt $season_cnt 0 -}}
|
||||
<h2>{{- T "seasons" | strings.FirstUpper -}}</h2>
|
||||
<section>
|
||||
<h2>
|
||||
{{- printf "%s%s" (T "seasons" | strings.FirstUpper) (T "colon") -}}
|
||||
</h2>
|
||||
{{- $season_lst = collections.Sort $season_lst "number" "asc" -}}
|
||||
{{- end -}}
|
||||
{{- range $season_lst -}}
|
||||
<p><a href="{{- (collections.Index . "object").RelPermalink -}}">{{- printf "%s %d%s %s" (T "season" | strings.FirstUpper) (collections.Index . "number") (T "colon") (collections.Index . "title") -}}</a></p>
|
||||
<article>
|
||||
<p><a href="{{- (collections.Index . "object").RelPermalink -}}">{{- printf "%s %d%s %s" (T "season" | strings.FirstUpper) (collections.Index . "number") (T "colon") (collections.Index . "title") -}}</a></p>
|
||||
</article>
|
||||
{{- end -}}
|
||||
{{- printf "%s%s" (T "episodes" | strings.FirstUpper ) (T "colon") -}}
|
||||
</section>
|
||||
<section>
|
||||
<h2>
|
||||
{{- printf "%s%s" (T "episodes" | strings.FirstUpper ) (T "colon") -}}
|
||||
</h2>
|
||||
{{ range .RegularPagesRecursive }}
|
||||
<p><a href="{{- .RelPermalink -}}">
|
||||
{{- if .Params.season -}}
|
||||
{{- printf "%s %d%s " (T "season" | strings.FirstUpper) (collections.Index .Params.season "number") (T "colon") -}}
|
||||
{{- end -}}
|
||||
{{- .Title -}}
|
||||
</a></p>
|
||||
<article>
|
||||
<p><a href="{{- .RelPermalink -}}">
|
||||
{{- if .Params.season -}}
|
||||
{{- printf "%s %d%s " (T "season" | strings.FirstUpper) (collections.Index .Params.season "number") (T "colon") -}}
|
||||
{{- end -}}
|
||||
{{- .Title -}}
|
||||
</a></p>
|
||||
</article>
|
||||
{{ end }}
|
||||
</section>
|
||||
</nav>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{{- errorf "empty image parameter on the podcast %q definition" .Title -}}
|
||||
{{- end -}}
|
||||
{{- $indent := 2 -}}
|
||||
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0" version="2.0">
|
||||
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title>
|
||||
{{- .Title | transform.XMLEscape -}}
|
||||
|
@ -33,6 +33,7 @@
|
|||
<itunes:image>
|
||||
{{- $image -}}
|
||||
</itunes:image>
|
||||
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
|
||||
<itunes:explicit>{{ .Params.explicit | transform.XMLEscape }}</itunes:explicit>
|
||||
<podcast:guid>{{ .Params.guid | transform.XMLEscape }}</podcast:guid>
|
||||
{{- "\n" -}}
|
||||
|
@ -263,9 +264,7 @@
|
|||
|
||||
{{- strings.Repeat $indent " " -}}
|
||||
<description>
|
||||
{{- "<![CDATA[" | safe.HTML -}}
|
||||
{{- .Description | safe.HTML -}}
|
||||
{{- "]]>" | safe.HTML -}}
|
||||
{{- .Description | transform.XMLEscape -}}
|
||||
</description>
|
||||
{{- "\n" -}}
|
||||
|
||||
|
@ -408,17 +407,41 @@
|
|||
{{- range . -}}
|
||||
{{- $rel := collections.Index . "rel" -}}
|
||||
{{- $lang := collections.Index . "language" -}}
|
||||
{{- $formats := collections.Index . "formats" -}}
|
||||
{{- with collections.Index $formats "srt" -}}
|
||||
{{- $srt_url := "" -}}
|
||||
{{- $webvtt_url := "" -}}
|
||||
{{- $html_url := "" -}}
|
||||
{{- $json_url := "" -}}
|
||||
{{- with collections.Index . "content" -}}
|
||||
{{- /* if content is defined, it means we are generating the transcripts ourselves */ -}}
|
||||
{{- with $episode_page.OutputFormats.Get "transcriptsrt" -}}
|
||||
{{- $srt_url = .Permalink -}}
|
||||
{{- end -}}
|
||||
{{- with $episode_page.OutputFormats.Get "transcriptwebvtt" -}}
|
||||
{{- $webvtt_url = .Permalink -}}
|
||||
{{- end -}}
|
||||
{{- with $episode_page.OutputFormats.Get "transcripthtml" -}}
|
||||
{{- $html_url = .Permalink -}}
|
||||
{{- end -}}
|
||||
{{- with $episode_page.OutputFormats.Get "transcriptjson" -}}
|
||||
{{- $json_url = .Permalink -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $external_content := collections.Index . "external_content" -}}
|
||||
{{- $srt_url = collections.Index $external_content "srt" -}}
|
||||
{{- $webvtt_url = collections.Index $external_content "webvtt" -}}
|
||||
{{- $html_url = collections.Index $external_content "html" -}}
|
||||
{{- $json_url = collections.Index $external_content "json" -}}
|
||||
{{- end -}}
|
||||
{{- with $srt_url -}}
|
||||
{{- partial "transcript.rss.xml" (dict "resource" . "type" "application/x-subrip" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
|
||||
{{- end -}}
|
||||
{{- with collections.Index $formats "webvtt" -}}
|
||||
{{- with $webvtt_url -}}
|
||||
{{- partial "transcript.rss.xml" (dict "resource" . "type" "text/webvtt" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
|
||||
{{- end -}}
|
||||
{{- with collections.Index $formats "html" -}}
|
||||
{{- with $html_url -}}
|
||||
{{- partial "transcript.rss.xml" (dict "resource" . "type" "text/html" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
|
||||
{{- end -}}
|
||||
{{- with collections.Index $formats "json" -}}
|
||||
{{- with $json_url -}}
|
||||
{{- partial "transcript.rss.xml" (dict "resource" . "type" "application/json" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>Categories on My New Hugo Site</title>
|
||||
<link>http://localhost:1313/categories/</link>
|
||||
<description>Recent content in Categories on My New Hugo Site</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>en-us</language>
|
||||
<atom:link href="http://localhost:1313/categories/index.xml" rel="self" type="application/rss+xml" />
|
||||
</channel>
|
||||
</rss>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>My New Hugo Site</title>
|
||||
<link>http://localhost:1313/</link>
|
||||
<description>Recent content on My New Hugo Site</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>en-us</language>
|
||||
<lastBuildDate></lastBuildDate>
|
||||
<atom:link href="http://localhost:1313/index.xml" rel="self" type="application/rss+xml" />
|
||||
</channel>
|
||||
</rss>
|
|
@ -1 +0,0 @@
|
|||
<script src="/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer></script>Test
|
|
@ -1 +0,0 @@
|
|||
<script src="/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer></script>Test
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||
<url>
|
||||
<loc>http://localhost:1313/</loc>
|
||||
<lastmod>2024-10-11T00:00:00+00:00</lastmod>
|
||||
</url><url>
|
||||
<loc>http://localhost:1313/podcasts/</loc>
|
||||
<lastmod>2024-10-11T00:00:00+00:00</lastmod>
|
||||
</url><url>
|
||||
<loc>http://localhost:1313/podcasts/yakafokon/season_1/</loc>
|
||||
<lastmod>2024-10-11T00:00:00+00:00</lastmod>
|
||||
</url><url>
|
||||
<loc>http://localhost:1313/categories/</loc>
|
||||
</url><url>
|
||||
<loc>http://localhost:1313/tags/</loc>
|
||||
</url>
|
||||
</urlset>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>Tags on My New Hugo Site</title>
|
||||
<link>http://localhost:1313/tags/</link>
|
||||
<description>Recent content in Tags on My New Hugo Site</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>en-us</language>
|
||||
<atom:link href="http://localhost:1313/tags/index.xml" rel="self" type="application/rss+xml" />
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in a new issue