Skip to content

Commit

Permalink
Fix rss images and email images (publiclab#2784)
Browse files Browse the repository at this point in the history
* Fix rss images and email images

* Update rss.rss.builder

* Update rss_for_tagged_with_author.rss.builder

* Update rss.rss.builder

* Update rss.rss.builder

* Update notify_node_creation.html.erb
  • Loading branch information
jywarren authored and SidharthBansal committed Jun 19, 2018
1 parent f5f0442 commit 4367452
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
10 changes: 5 additions & 5 deletions app/views/notes/rss.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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 => "https://#{ request.host }/feed.rss"
xml.link "https://#{request.host}/feed.rss"
xml.tag! 'atom:link', rel: 'self', type: 'application/rss+xml', href: "https://#{request.host}/feed.rss"

@notes.each do |node|
author = node.author.username
Expand All @@ -17,13 +17,13 @@ xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.pubDate node.created_at.to_s(:rfc822)
xml.link "https://" + request.host.to_s + node.path
body = auto_link(body, sanitize: false)
body = "<p><a href='https://#{ActionMailer::Base.default_url_options[:host]}/moderate/publish/#{@node.id}'>Approve</a> or <a href='https://#{ActionMailer::Base.default_url_options[:host]}/moderate/spam/<%= node.id %>'>Spam</a></p>" + body if node.status == 4
body = "<p><a href='https://#{request.host}/moderate/publish/#{@node.id}'>Approve</a> or <a href='https://#{request.host}/moderate/spam/<%= node.id %>'>Spam</a></p>" + body if node.status == 4
if node.main_image
xml.description { xml.cdata!("<img src='#{node.main_image.path(:default)}' alt='#{node.main_image.title}'> <br />" + body) }
xml.description { xml.cdata!("<img src='https://#{request.host}#{node.main_image.path(:default)}' alt='#{node.main_image.title}'> <br />" + body) }
else
xml.description { xml.cdata!("<img src='https://publiclab.org/system/images/photos/000/023/444/original/Screenshot_20180204-101546_2.png' alt='PublicLab'> <br />" + body) }
end
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
xml.guid url_for only_path: false, controller: 'notes', action: 'show', id: node.nid
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/subscription_mailer/notify_node_creation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

<hr />

<% if @node.main_image %><a style="margin-bottom:10px;" href="<%= @node.path %>"><img src="<%= @node.main_image.path(:default) %>" /></a><% end %>
<% if @node.main_image %><a style="margin-bottom:10px;" href="<%= ActionMailer::Base.default_url_options[:host] %><%= @node.path %>"><img src="<%= ActionMailer::Base.default_url_options[:host] %><%= @node.main_image.path(:default) %>" /></a><% end %>
<%= raw auto_link(@node.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), :sanitize => false) %>
<%= raw auto_link(@node.latest.render_body_email(ActionMailer::Base.default_url_options[:host]), sanitize: false) %>

<hr />
<hr />

<div style="color:#aaa;">

Expand Down
6 changes: 3 additions & 3 deletions app/views/tag/rss.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
end
xml.link "https://" + request.host.to_s + node.path
if node.main_image
xml.description { xml.cdata!("<img src='#{node.main_image.path(:default)}' alt='#{node.main_image.title}'><p>#{auto_link(node.latest.render_body, :sanitize => false)}</p>") }
xml.description { xml.cdata!("<img src='https://#{request.host}#{node.main_image.path(:default)}' alt='#{node.main_image.title}'> <p>#{auto_link(node.latest.render_body, sanitize: false)}</p>") }
else
xml.description { xml.cdata!("<img src='https://publiclab.org/system/images/photos/000/023/444/original/Screenshot_20180204-101546_2.png' alt='PublicLab'><p>#{auto_link(node.latest.render_body, :sanitize => false)}</p>") }
xml.description { xml.cdata!("<img src='https://publiclab.org/system/images/photos/000/023/444/original/Screenshot_20180204-101546_2.png' alt='PublicLab'><p>#{auto_link(node.latest.render_body, sanitize: false)}</p>") }
end
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
xml.guid url_for only_path: false, controller: 'notes', action: 'show', id: node.nid
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/tag/rss_for_tagged_with_author.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
end
xml.link "https://" + request.host.to_s + node.path
if node.main_image
xml.description { xml.cdata!("<img src='#{node.main_image.path(:default)}' alt='#{node.main_image.title}'><p>#{auto_link(node.latest.render_body, :sanitize => false)}</p>") }
xml.description { xml.cdata!("<img src='https://#{request.host}#{node.main_image.path(:default)}' alt='#{node.main_image.title}'> <p>#{auto_link(node.latest.render_body, sanitize: false)}</p>") }
else
xml.description { xml.cdata!("<img src='https://publiclab.org/system/images/photos/000/023/444/original/Screenshot_20180204-101546_2.png' alt='PublicLab'><p>#{auto_link(node.latest.render_body, :sanitize => false)}</p>") }
xml.description { xml.cdata!("<img src='https://publiclab.org/system/images/photos/000/023/444/original/Screenshot_20180204-101546_2.png' alt='PublicLab'><p>#{auto_link(node.latest.render_body, sanitize: false)}</p>") }
end
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
xml.guid url_for only_path: false, controller: 'notes', action: 'show', id: node.nid
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions app/views/users/rss.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ xml.rss :version => "2.0" do
newline = '&#13;&#10;'

body = node.body
body = "<img src='"+node.main_image.path(:default)+"'/><br />"+newline+node.body if node.main_image
body = "<img src='https://#{request.host}"+node.main_image.path(:default)+"'/><br />"+newline+node.body if node.main_image

xml.item do
xml.title node.title
xml.author node.author.name
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.image "http://publiclaboratory.org/"+node.main_image.path(:default) if node.main_image
xml.description auto_link(node.latest.render_body, :sanitize => false)
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
xml.description auto_link(node.latest.render_body, sanitize: false)
xml.guid url_for only_path: false, controller: 'notes', action: 'show', id: node.nid
end
end
end
Expand Down

0 comments on commit 4367452

Please sign in to comment.