Skip to content

Commit

Permalink
Merge pull request huginn#2114 from HyShai/itunes-image
Browse files Browse the repository at this point in the history
add itunes podcast icon
  • Loading branch information
knu authored Sep 7, 2017
2 parents 8613add + 5e1e5a1 commit 48afe27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 48afe27

Please sign in to comment.