This commit is contained in:
Florian Maury 2024-10-26 10:19:41 +02:00
parent 18df5aeab5
commit 63246546b3
24 changed files with 207 additions and 97 deletions

View file

View file

@ -40,22 +40,12 @@ params:
# title: "" # title: ""
# episode_type: "" # podcast field: itunes:episodeType ; one of "Full", "Trailer" or "Bonus" # episode_type: "" # podcast field: itunes:episodeType ; one of "Full", "Trailer" or "Bonus"
# transcript: # podcast field: podcast:transcript # transcript: # podcast field: podcast:transcript
# - formats # - content: "" # YAML file containing the transcript
# srt: # external_content: # url of the remote content to use as is in different format
# external_url: "" # URL to the transcript file # srt: ""
# resource_file: "" # URL to the transcript file # webvtt: ""
# webvtt: # html: ""
# external_url: "" # URL to the transcript file # json: ""
# 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
# language: fr # optional; if omitted, language is the same as the podcast language attribute # 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 # rel: "captions" # ; optional ; only valid value is "captions"; indicates that this transcript contains time codes
# funding: # podcast field: podcast:funding # funding: # podcast field: podcast:funding

View file

View file

@ -1 +1 @@
<hr/> {{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "html") -}}

View file

@ -1 +1 @@
{"json": true} {{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "json") -}}

View file

@ -1 +1 @@
{"pod": "love"} {{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "podlove") -}}

View file

@ -1 +1 @@
bla {{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "srt") -}}

View file

@ -1 +1 @@
WEBVTT {{- partial "transcript_content/dispatcher.tmpl" (dict "episode" . "format" "webvtt") -}}

View 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 -}}

View file

@ -1,13 +1,12 @@
{{- $resource := collections.Index . "resource" -}} {{- $url := collections.Index . "resource" -}}
{{- $type := collections.Index . "type" -}} {{- $type := collections.Index . "type" -}}
{{- $lang := collections.Index . "lang" -}} {{- $lang := collections.Index . "lang" -}}
{{- $rel := collections.Index . "rel" -}} {{- $rel := collections.Index . "rel" -}}
{{- $episode_page := collections.Index . "episode_page" -}} {{- $episode_page := collections.Index . "episode_page" -}}
{{- $indent := collections.Index . "indent" -}} {{- $indent := collections.Index . "indent" -}}
{{- $url := partial "external_or_local.rss.xml" (dict "context" $resource "ref_page" $episode_page) -}}
{{- strings.Repeat $indent " " -}} {{- strings.Repeat $indent " " -}}
<podcast:transcript url="{{- $url | transform.XMLEscape -}}" type="{{- . | transform.XMLEscape -}}" <podcast:transcript url="{{- $url | transform.XMLEscape -}}" type="{{- $type | transform.XMLEscape -}}"
{{- with $lang -}} {{- with $lang -}}
{{- " " | safe.HTMLAttr -}} {{- " " | safe.HTMLAttr -}}

View 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 -}}

View 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 -}}

View 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" " ") -}}

View 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" " ") -}}

View 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 -}}

View 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 -}}

View file

@ -1,4 +1,5 @@
<h1>{{ printf (T "welcome") .Title }}</h1> <header><h1>{{ printf (T "welcome") .Title }}</h1></header>
<nav>
{{- $season_cnt := 0 -}} {{- $season_cnt := 0 -}}
{{- $season_lst := slice -}} {{- $season_lst := slice -}}
{{- range .Sections -}} {{- range .Sections -}}
@ -8,18 +9,31 @@
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- if gt $season_cnt 0 -}} {{- 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" -}} {{- $season_lst = collections.Sort $season_lst "number" "asc" -}}
{{- end -}} {{- end -}}
{{- range $season_lst -}} {{- 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 -}} {{- 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 }} {{ range .RegularPagesRecursive }}
<p><a href="{{- .RelPermalink -}}"> <article>
{{- if .Params.season -}} <p><a href="{{- .RelPermalink -}}">
{{- printf "%s %d%s " (T "season" | strings.FirstUpper) (collections.Index .Params.season "number") (T "colon") -}} {{- if .Params.season -}}
{{- end -}} {{- printf "%s %d%s " (T "season" | strings.FirstUpper) (collections.Index .Params.season "number") (T "colon") -}}
{{- .Title -}} {{- end -}}
</a></p> {{- .Title -}}
</a></p>
</article>
{{ end }} {{ end }}
</section>
</nav>

View file

@ -15,7 +15,7 @@
{{- errorf "empty image parameter on the podcast %q definition" .Title -}} {{- errorf "empty image parameter on the podcast %q definition" .Title -}}
{{- end -}} {{- end -}}
{{- $indent := 2 -}} {{- $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> <channel>
<title> <title>
{{- .Title | transform.XMLEscape -}} {{- .Title | transform.XMLEscape -}}
@ -33,6 +33,7 @@
<itunes:image> <itunes:image>
{{- $image -}} {{- $image -}}
</itunes:image> </itunes:image>
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
<itunes:explicit>{{ .Params.explicit | transform.XMLEscape }}</itunes:explicit> <itunes:explicit>{{ .Params.explicit | transform.XMLEscape }}</itunes:explicit>
<podcast:guid>{{ .Params.guid | transform.XMLEscape }}</podcast:guid> <podcast:guid>{{ .Params.guid | transform.XMLEscape }}</podcast:guid>
{{- "\n" -}} {{- "\n" -}}
@ -263,9 +264,7 @@
{{- strings.Repeat $indent " " -}} {{- strings.Repeat $indent " " -}}
<description> <description>
{{- "<![CDATA[" | safe.HTML -}} {{- .Description | transform.XMLEscape -}}
{{- .Description | safe.HTML -}}
{{- "]]>" | safe.HTML -}}
</description> </description>
{{- "\n" -}} {{- "\n" -}}
@ -408,17 +407,41 @@
{{- range . -}} {{- range . -}}
{{- $rel := collections.Index . "rel" -}} {{- $rel := collections.Index . "rel" -}}
{{- $lang := collections.Index . "language" -}} {{- $lang := collections.Index . "language" -}}
{{- $formats := collections.Index . "formats" -}} {{- $srt_url := "" -}}
{{- with collections.Index $formats "srt" -}} {{- $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) -}} {{- partial "transcript.rss.xml" (dict "resource" . "type" "application/x-subrip" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
{{- end -}} {{- 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) -}} {{- partial "transcript.rss.xml" (dict "resource" . "type" "text/webvtt" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
{{- end -}} {{- 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) -}} {{- partial "transcript.rss.xml" (dict "resource" . "type" "text/html" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
{{- end -}} {{- 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) -}} {{- partial "transcript.rss.xml" (dict "resource" . "type" "application/json" "lang" $lang "rel" $rel "episode_page" $episode_page "indent" $indent) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -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>

View file

@ -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>

View file

@ -1 +0,0 @@
<script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>Test

View file

@ -1 +0,0 @@
<script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>Test

View file

@ -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>

View file

@ -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>