Skip to content

Commit

Permalink
Image added (#2162)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarpreet-chadha authored and jywarren committed Feb 2, 2018
1 parent a554039 commit d3391d5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/views/notes/rss.rss.builder
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
xml.instruct!
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.channel do
xml.title "Recent research notes on PublicLab.org"
xml.description "Open source environmental science research at Public Lab"
xml.link "https://#{ request.host }/feed.rss"
xml.tag! 'atom:link', :rel => 'self', :type => 'application/rss+xml', :href => request.host.to_s
xml.tag! 'atom:link', :rel => 'self', :type => 'application/rss+xml', :href => "https://#{ request.host }/feed.rss"

@notes.each do |node|

body = node.latest.render_body
body = "<p><![CDATA[ <img src='#{node.main_image.path(:default)}' alt='#{node.main_image.title}' > ]]></p>#{node.body}" if node.main_image
uname = node.author.username
email = node.author.email
if node.author.user.has_power_tag('twitter')
uname = node.author.user.get_value_of_power_tag('twitter')
end
author_format = "@#{uname} (#{email})"

xml.item do
xml.title node.title
xml.author node.author.user.has_power_tag('twitter') ? "@" + node.author.user.get_value_of_power_tag('twitter') : node.author.username
xml.title "@#{uname} shared : #{node.title}"
xml.author author_format
xml.pubDate node.created_at.to_s(:rfc822)
#xml.link url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
xml.link "https://" + request.host.to_s + node.path
xml.enclosure url: node.main_image.path(:default) if node.main_image
xml.description auto_link(body, :sanitize => false)
if node.main_image
xml.description { xml.cdata!("<img src='#{node.main_image.path(:default)}' alt='#{node.main_image.title}'>") }
else
xml.description { xml.cdata!("<img src='https://i.publiclab.org/system/images/photos/000/000/354/medium/Boots-ground-02.png' alt='PublicLab'>") }
end
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
end
end
Expand Down

0 comments on commit d3391d5

Please sign in to comment.