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

RSS for Tag show with image correction #2213

Merged
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
7 changes: 4 additions & 3 deletions app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,10 @@ def rss
end

def rss_for_tagged_with_author
@user = User.find_by(name: params[:author])
@notes = Tag.tagged_nodes_by_author([params[:tagname]], @user)
.limit(20)
@user = User.find_by(name: params[:authorname])
@notes = Tag.tagged_nodes_by_author(params[:tagname], @user)
.where(status: 1)
.limit(20)
respond_to do |format|
format.rss do
response.headers['Content-Type'] = 'application/xml; charset=utf-8'
Expand Down
27 changes: 15 additions & 12 deletions app/views/tag/rss.rss.builder
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.channel do
xml.title "Research tagged '#{params[:tagname]}'"
xml.description "Open source environmental science research at Public Lab"
xml.link "https://#{request.host}/feed/tag/"+params[:tagname]+".rss"

@notes.each do |node|

body = node.body
body = "<img src='"+node.main_image.path(:default)+"'/><br /> "+node.body if node.main_image

xml.item do
xml.title node.title
xml.author node.author.name
if node.power_tag('date') != ''
author = node.author.username
if node.author.user.has_power_tag('twitter')
author = "@#{node.author.user.get_value_of_power_tag('twitter')}"
end
xml.item do
xml.title node.title
xml.author author
if node.power_tag('date') != ''
begin
xml.pubDate DateTime.strptime(node.power_tag('date'), "%m-%d-%Y").rfc822
rescue
Expand All @@ -22,10 +23,12 @@ xml.rss :version => "2.0" do
else
xml.pubDate node.created_at.to_s(:rfc822)
end
#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 "//#{ request.host }/"+node.main_image.path(:default) if node.main_image
xml.description auto_link(node.latest.render_body, :sanitize => false)
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>") }
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>") }
end
xml.guid url_for :only_path => false, :controller => 'notes', :action => 'show', :id => node.nid
end
end
Expand Down
26 changes: 12 additions & 14 deletions app/views/tag/rss_for_tagged_with_author.rss.builder
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.channel do
xml.title "Research tagged '#{params[:tagname]}' by #{params[:authorname]}"
xml.title "Research tagged '#{params[:tagname]}' by '#{params[:authorname]}'"
xml.description "Open source environmental science research at Public Lab"
xml.link "https://#{request.host}/feed/tag/"+params[:tagname]+"/author/"+"params[:authorname]"+".rss"
xml.link "https://#{request.host}/feed/tag/"+params[:tagname]+"/author/"+params[:authorname]+".rss"

@notes.each do |node|

body = node.body
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 author_format
body = node.body
author = node.author.username
if node.author.user.has_power_tag('twitter')
author = "@#{node.author.user.get_value_of_power_tag('twitter')}"
end
xml.item do
xml.title node.title
xml.author author
if node.power_tag('date') != ''
begin
xml.pubDate DateTime.strptime(node.power_tag('date'), "%m-%d-%Y").rfc822
Expand All @@ -27,9 +25,9 @@ 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}'>") }
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>") }
else
xml.description { xml.cdata!("<img src='https://i.publiclab.org/system/images/photos/000/000/354/medium/Boots-ground-02.png' alt='PublicLab'><p>#{body}</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
end
Expand Down