2020-03-09 12:13:27 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-10 09:09:48 +02:00
|
|
|
require 'date'
|
|
|
|
|
2020-03-09 12:13:27 +01:00
|
|
|
xml.instruct! :xml, version: '1.0'
|
|
|
|
xml.rss :version => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/' do
|
2016-02-24 20:30:14 +01:00
|
|
|
xml.channel do
|
2020-03-09 12:13:27 +01:00
|
|
|
xml.title 'Search results'
|
|
|
|
xml.description 'Papers matching search criteria'
|
2016-02-24 20:30:14 +01:00
|
|
|
|
|
|
|
@papers.each do |doc|
|
|
|
|
xml.item do
|
|
|
|
xml.title doc.name
|
2020-03-09 12:13:27 +01:00
|
|
|
unless doc.content.blank?
|
|
|
|
xml.description do
|
|
|
|
xml.cdata! truncate(doc.content.sub('------------------------------- ', ''), length: 768)
|
|
|
|
end
|
2016-04-10 09:09:48 +02:00
|
|
|
end
|
2020-03-09 12:13:27 +01:00
|
|
|
unless doc.published_at.blank?
|
|
|
|
xml.pubDate DateTime.parse(doc.published_at).utc.strftime('%a, %d %b %Y %H:%M:%S %z')
|
|
|
|
end
|
|
|
|
doc.originator.each do |originator|
|
|
|
|
xml.dc :creator do
|
|
|
|
xml.cdata! originator
|
|
|
|
end
|
2016-04-10 09:09:48 +02:00
|
|
|
end
|
2020-03-09 12:13:27 +01:00
|
|
|
unless doc.paper_type.blank?
|
|
|
|
xml.category do
|
|
|
|
xml.cdata! doc.paper_type
|
|
|
|
end
|
2016-04-10 09:09:48 +02:00
|
|
|
end
|
2016-02-24 20:30:14 +01:00
|
|
|
xml.link doc.url
|
|
|
|
xml.guid doc.url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-03-09 12:13:27 +01:00
|
|
|
end
|