Class: Jekyll::PodigeePlayerTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll/podigee_player_tag.rb

Instance Method Summary collapse

Instance Method Details

#playerconfig(context) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jekyll/podigee_player_tag.rb', line 3

def playerconfig(context)
  config = context.registers[:site].config
  page = context.registers[:page]

  audio = {}
  page["audio"].each { |key, value| audio[key] = config["url"] + "/episodes/" + value}

  { options: { theme: "default",
               startPanel: "ChapterMarks" },
    extensions: { ChapterMarks: {},
                  EpisodeInfo:  {},
                  Playlist:     {} },
    title: options['title'],
    episode: { media: audio,
               coverUrl: config['url'] + (page["episode_cover"] || '/img/logo-360x360.png'),
               title: page["title"],
               subtitle: page["subtitle"],
               url: config['url'] + page["url"],
               description: page["description"],
               chaptermarks: page["chapters"].map {|chapter| { start: chapter[0..12], title: chapter[13..255] }}
             }
  }.to_json
end

#render(context) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll/podigee_player_tag.rb', line 27

def render(context)
  config = context.registers[:site].config
  page = context.registers[:page]
  return unless page["audio"]
  return <<~HTML
    <script>
      window.playerConfiguration = #{playerconfig(context)}
    </script>
    <script class="podigee-podcast-player" data-configuration="playerConfiguration"
            src="#{config["url"].split(":").first}://cdn.podigee.com/podcast-player/javascripts/podigee-podcast-player.js">
    </script>
HTML
end