-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
31 lines (26 loc) · 856 Bytes
/
app.rb
File metadata and controls
31 lines (26 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'byebug' rescue puts 'no byebug'
require 'rss'
require 'open-uri'
get '/' do
content_type 'application/rss+xml'
url = params['url'] || 'https://www.penseo.de/post/rss.xml'
open(url) do |rss|
feed = RSS::Parser.parse(rss)
rss = RSS::Maker.make("atom") do |maker|
maker.channel.id = url
maker.channel.author = url
maker.channel.pubDate = Time.now
maker.channel.title = feed.channel.title
items = feed.items.sort_by(&:pubDate).reverse.to_enum.with_index { |item, index| item.pubDate = Time.now - index * 60 * 60 * 24 }
items.each do |item|
maker.items.new_item do |i|
i.link = item.link
i.title = item.title
i.updated = item.pubDate
i.description = item.description
end
end
end
rss.to_s
end
end