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

Fix rss images and email images #2784

Merged
merged 6 commits into from
Jun 7, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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