Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add itunes podcast icon #2114

Merged
merged 3 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/models/agents/data_output_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ def feed_icon
interpolated['template']['icon'].presence || feed_link + '/favicon.ico'
end

def itunes_icon
if(boolify(interpolated['ns_itunes']))
"<itunes:image href=#{feed_icon.encode(xml: :attr)} />"
end
end

def feed_description
interpolated['template']['description'].presence || "A feed of Events received by the '#{name}' Huginn Agent"
end
Expand Down Expand Up @@ -295,6 +301,7 @@ def receive_web_request(params, method, format)
<channel>
<atom:link href=#{feed_url(secret: params['secret'], format: :xml).encode(xml: :attr)} rel="self" type="application/rss+xml" />
<atom:icon>#{feed_icon.encode(xml: :text)}</atom:icon>
#{itunes_icon}
#{hub_links}
<title>#{feed_title.encode(xml: :text)}</title>
<description>#{feed_description.encode(xml: :text)}</description>
Expand Down
6 changes: 4 additions & 2 deletions spec/models/agents/data_output_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,11 @@
content, status, content_type = agent.receive_web_request({ 'secret' => 'secret1' }, 'get', 'text/xml')
expect(status).to eq(200)
expect(content_type).to eq('application/rss+xml')

doc = Nokogiri(content)
namespaces = doc.collect_namespaces
expect(namespaces).not_to include("xmlns:itunes")
expect(doc.at("/rss/channel/*[local-name()='itunes:image']")).to be_nil
end
end

Expand All @@ -484,12 +485,13 @@
content, status, content_type = agent.receive_web_request({ 'secret' => 'secret1' }, 'get', 'text/xml')
expect(status).to eq(200)
expect(content_type).to eq('application/rss+xml')

doc = Nokogiri(content)
namespaces = doc.collect_namespaces
expect(namespaces).to include(
"xmlns:itunes" => 'http://www.itunes.com/dtds/podcast-1.0.dtd'
)
expect(doc.at('/rss/channel/itunes:image').attr('href')).to eq('https://yoursite.com/favicon.ico')
end
end

Expand Down