From 1b7d35a7b8feaa373e58a727199e032d2d91da40 Mon Sep 17 00:00:00 2001 From: Joerg Reichert Date: Wed, 24 Feb 2016 20:30:14 +0100 Subject: [PATCH 1/2] first version of RSS builder --- app/views/search/index.rss.builder | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/views/search/index.rss.builder diff --git a/app/views/search/index.rss.builder b/app/views/search/index.rss.builder new file mode 100644 index 0000000..11bb90d --- /dev/null +++ b/app/views/search/index.rss.builder @@ -0,0 +1,18 @@ +xml.instruct! :xml, :version => "1.0" +xml.rss :version => "2.0" do + xml.channel do + xml.title "Search results" + xml.description "Papers matching search criteria" + xml.link root_url + + @papers.each do |doc| + xml.item do + xml.title doc.name + xml.description article.content[0, doc.content.length < 30 ? doc.content.length : 30] + xml.pubDate doc.published_at.to_date.to_s(:rfc822) + xml.link doc.url + xml.guid doc.url + end + end + end +end \ No newline at end of file From 46f795fb88a676f8db5b7a8139c3e39192e76859 Mon Sep 17 00:00:00 2001 From: Joerg Reichert Date: Wed, 2 Mar 2016 22:48:59 +0100 Subject: [PATCH 2/2] fixed rss content and added header information to rss link --- app/views/layouts/application.html.slim | 1 + app/views/search/index.rss.builder | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 9de75b8..6526e49 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -5,6 +5,7 @@ html = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'vendor/modernizr' = csrf_meta_tags + = auto_discovery_link_tag(:rss, params.merge(format: :rss)) body .row diff --git a/app/views/search/index.rss.builder b/app/views/search/index.rss.builder index 11bb90d..6c488b6 100644 --- a/app/views/search/index.rss.builder +++ b/app/views/search/index.rss.builder @@ -8,7 +8,7 @@ xml.rss :version => "2.0" do @papers.each do |doc| xml.item do xml.title doc.name - xml.description article.content[0, doc.content.length < 30 ? doc.content.length : 30] + xml.description truncate(doc.content, length: 768) xml.pubDate doc.published_at.to_date.to_s(:rfc822) xml.link doc.url xml.guid doc.url