Skip to content

Commit 31fee8d

Browse files
author
Bastian Bartmann
committed
added podloveaudio view helper
1 parent 715912d commit 31fee8d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/podlove-web-player-rails.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
require "podlove-web-player-rails/version"
2+
require "podlove-web-player-rails/view_helpers"
23

34
module Podlove
45
module Web
56
module Player
67
module Rails
78
class Engine < ::Rails::Engine
9+
initializer "podlove-web-player-rails.view_helpers" do |app|
10+
ActionView::Base.send :include, ViewHelpers
11+
end
812
end
913
end
1014
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module Podlove
2+
module Web
3+
module Player
4+
module Rails
5+
module ViewHelpers
6+
def podloveaudio(options = {})
7+
html = "<audio id='player'>"
8+
html << "<source src='#{options[:src]}' type='#{options[:type]}'></source>"
9+
html << "</audio>"
10+
11+
options.delete(:src)
12+
options.delete(:type)
13+
14+
script = "$('#player').podlovewebplayer(#{options.to_json});"
15+
16+
return raw html + "\n" + javascript_tag(script)
17+
end
18+
end
19+
end
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)