Class: Jekyll::PodigeePlayerTag

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

Constant Summary collapse

PLAYER_THEMES =
["default", "default-dark", "legacy", "minimal", "republica"]

Instance Method Summary collapse

Instance Method Details

#playerconfig(context) ⇒ Object



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

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

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

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

#render(context) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jekyll/podigee_player_tag.rb', line 31

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"]}/podigee-player/javascripts/podigee-podcast-player.js">
    </script>
HTML
end