jekyll-octopod 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bab9d22951437197ea9b85735a898f4c6fe4582ee18eb942f63864cbe842c5b9
4
- data.tar.gz: 9dee8614f7de17e484323d2ca79d84be23e798dc953a98abe9c2dfae592be4fb
3
+ metadata.gz: '08b3d44f4b48f6f493121d5d6bcd4708d4d82f54a386be9a79e8f4cf9df5aceb'
4
+ data.tar.gz: 518582535ee414dcc81f41ad540bf3242bd2fe339067d292733c7c3abe995ca9
5
5
  SHA512:
6
- metadata.gz: 90483ebdbb7ba04b2dd8c0a5a196f75356224fb482488de2b030ae02ab975f513012ca718bbb52ee6c9404286b019c80a2fc3c509bc5ff7f37f042624be5d77b
7
- data.tar.gz: 0fcaa3555178d41f5a30acf9c8fe1254bb59efc19213190e79a59c0b3a6921a61cfee5f29cc82a06287845dd448e0f276bd8aa2714a758e01c0de5a2c33ebb54
6
+ metadata.gz: df52f5ac952f8ce2f4ae7089696183f519f93d0f43133e02011e1f66114c8b9b2e57b32d6da857b69439330af566b53693495f5c7ab733eee8a8e1e7e0d2c256
7
+ data.tar.gz: 61da23c9b801a3f33e011e97723c0dcb2a4d5de86cd15b0e3bdeb8f4cb3f5527eb93c1fc600aaabb6b7e24181b96a223b277c05cc06bc48422a07dc4551b4c47
@@ -39,10 +39,78 @@ module Jekyll
39
39
  publicationDate: page["date"].respond_to?(:xmlschema) ? page["date"].xmlschema : page["date"].to_s,
40
40
  duration: page["duration"],
41
41
  audio: audio,
42
- chapters: page["chapters"] ? page["chapters"].map { |chapter| split_chapter(chapter) }.compact : nil
42
+ chapters: page["chapters"] ? page["chapters"].map { |chapter| split_chapter(chapter) }.compact : nil,
43
+ transcripts: transcripts_for(page)
43
44
  }.to_json
44
45
  end
45
46
 
47
+ # Finds a WebVTT transcript for this episode and parses it into the cue list Podlove Web
48
+ # Player's "transcripts" config field expects (see the same docs link above the config
49
+ # method: a plain list of { start, start_ms, end, end_ms, speaker, voice, text } cues - the
50
+ # player has no native understanding of WebVTT itself, so this is doing that conversion, not
51
+ # just passing the file through). Looks for an explicit page["transcript"] filename first,
52
+ # then falls back to the audio file's own basename with a .vtt extension (i.e.
53
+ # "episode1.mp3" -> "episode1.vtt"), resolved on disk the same way file_size() locates audio
54
+ # files: relative to the site root if the filename already contains a "/", otherwise under
55
+ # episodes/. Returns nil if there's no matching, parseable file, so the config field is
56
+ # simply omitted rather than sent empty.
57
+ def transcripts_for(page)
58
+ filename = page["transcript"] || vtt_sibling_of(page["audio"])
59
+ return nil unless filename
60
+
61
+ path = filename =~ /\// ? filename : File.join('episodes', filename)
62
+ return nil unless File.exist?(path)
63
+
64
+ cues = parse_vtt(File.read(path, encoding: 'UTF-8'))
65
+ cues.empty? ? nil : cues
66
+ end
67
+
68
+ def vtt_sibling_of(audio_hash)
69
+ return nil unless audio_hash
70
+ primary = audio(audio_hash)
71
+ return nil unless primary
72
+
73
+ primary.sub(/\.[^.\/]+\z/, '.vtt')
74
+ end
75
+
76
+ # Parses WebVTT cues, including Auphonic's "<v Speaker>text</v>" voice-tag convention. Not a
77
+ # full WebVTT implementation (no styling, regions, or nested tags) - just enough to turn
78
+ # timed, optionally speaker-tagged captions into Podlove's transcript-cue shape.
79
+ def parse_vtt(content)
80
+ content = content.sub(/\A\xEF\xBB\xBF/, '').gsub("\r\n", "\n")
81
+
82
+ content.split(/\n\n+/).filter_map do |block|
83
+ lines = block.strip.split("\n")
84
+ next nil if lines.empty?
85
+
86
+ # Discard the "WEBVTT" header, NOTE/STYLE/REGION blocks, and any cue identifier line -
87
+ # everything up to the "start --> end" timing line, which is left in place once found.
88
+ lines.shift while lines.first && !lines.first.include?('-->')
89
+ timing = lines.shift
90
+ next nil unless timing
91
+
92
+ match = timing.match(/((?:\d{2}:)?\d{2}:\d{2}\.\d{3})\s*-->\s*((?:\d{2}:)?\d{2}:\d{2}\.\d{3})/)
93
+ next nil unless match
94
+
95
+ text = lines.join(' ').strip
96
+ voice = text[/\A<v\s+([^>]+)>/, 1]
97
+ text = text.sub(/\A<v\s+[^>]+>/, '').sub(%r{</v>\z}, '').strip
98
+
99
+ { start: match[1], start_ms: ms_from_vtt_timestamp(match[1]),
100
+ end: match[2], end_ms: ms_from_vtt_timestamp(match[2]),
101
+ speaker: nil, voice: voice, text: text }
102
+ end
103
+ end
104
+
105
+ def ms_from_vtt_timestamp(timestamp)
106
+ parts = timestamp.split(':')
107
+ seconds, millis = parts.pop.split('.')
108
+ minutes = parts.pop.to_i
109
+ hours = parts.empty? ? 0 : parts.pop.to_i
110
+
111
+ (((hours * 60) + minutes) * 60 + seconds.to_i) * 1000 + millis.to_i
112
+ end
113
+
46
114
  def playerbaseconfig(context)
47
115
  config = context.registers[:site].config
48
116
  { version: 5, base: "#{config["url"]}/assets/podlove-player/" }.to_json
@@ -2,8 +2,8 @@ module Jekyll
2
2
  class Octopod
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
- MINOR = 20
6
- TINY = 1
5
+ MINOR = 21
6
+ TINY = 0
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-octopod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Eilermann
@@ -105,7 +105,6 @@ extra_rdoc_files: []
105
105
  files:
106
106
  - README.md
107
107
  - Rakefile
108
- - assets/_config.yml
109
108
  - assets/_config.yml.sample
110
109
  - assets/_posts/2016-03-22-episode0.md
111
110
  - assets/_sass/_overrides.scss
data/assets/_config.yml DELETED
@@ -1,47 +0,0 @@
1
- # You have to configure this ###################################################
2
- title: Octopod
3
- # You should configure this ####################################################
4
- url: http://localhost:4000
5
- subtitle: Static Site Podcast Publishing for Geeks
6
- description: My super duper cool podcast.
7
- author: Uncle Octopod
8
- email: octopod@example.com
9
- keywords: [octopod, podcast, magic]
10
- itunes_categories: [Technology]
11
- # additional_feeds:
12
- # itunes: http://itunes.apple.com/de/podcast/podcast_name/id42424242
13
- # torrent_m4a: http://bitlove.org/example_user/example_podcast_m4a/feed
14
- # torrent_mp3: http://bitlove.org/example_user/example_podcast_mp3/feed
15
- episodes_per_feed_page: 100
16
- ## Rsync Deploy config #########################################################
17
- ### Be sure your public key is listed in your server's ~/.ssh/authorized_keys
18
- ### file.
19
- ssh_host: user@host.org
20
- ssh_port: 22
21
- document_root: /path/to/your/htdocs/
22
- rsync_delete: true
23
- # You can configure this #######################################################
24
- twitter_nick: my_twitter_handle
25
- language: en
26
- explicit: 'no' # 'yes'/'no'/clean
27
- license: CC BY 4.0
28
- license_url: https://creativecommons.org/licenses/by/4.0/
29
- license_image_url: https://i.creativecommons.org/l/by/4.0/88x31.png
30
- ## Flattr ######################################################################
31
- flattr_uid: # Flattr will not be used unless this is set
32
- flattr_button: compact # compact | default
33
- flattr_mode: auto # auto | manual(default)
34
- flattr_popout: 1 # 1 | 0 (show popout when hovering mouse over button)
35
- flattr_language: en_GB # available languages - https://api.flattr.com/rest/v2/languages.txt
36
- flattr_category: audio # available categories - https://api.flattr.com/rest/v2/categories.txt
37
- ## Disqus comments #############################################################
38
- disqus_shortname: # Disqus will not be used unless this is set
39
- disqus_developer: 0 # 1 / 0
40
- ## Feed links ###########################################################
41
- itunes_url: https://itunes.apple.com/at/podcast/myname/id#myid#
42
- bitlove_url: https://bitlove.org/myaccount
43
- fyyd_url: https://fyyd.de/podcast/myaccount/myid
44
- gpodder_url: https://gpodder.net/podcast/mypodcast
45
-
46
- gems: [jekyll-octopod]
47
- theme: jekyll-bootflat