-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_rss.rb
executable file
·34 lines (31 loc) · 930 Bytes
/
make_rss.rb
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
32
33
34
#!/usr/bin/env ruby
STDOUT.sync = true
require 'rss'
require 'nokogiri'
rss = RSS::Maker.make('atom') do |atom|
atom.channel.author = 'SeedRamp'
atom.channel.title = 'SeedRamp'
atom.channel.id = 'seedramp.com'
atom.channel.updated = Time.now
Dir['target/log/**/*.html']
.reject { |f| f[/\.amp\.html$/] }
.sort
.reverse
.each do |file|
p file
xml = Nokogiri::XML.parse(File.read(file))
atom.items.new_item do |item|
puts xml
time = Time.parse(xml.xpath('//meta[@name="published"]/@content')[0])
url = file.gsub(/^target\//, 'http://www.seedramp.com/')
item.id = url
item.link = url
item.title = xml.xpath('//title/text()')
item.published = time
item.updated = time
item.summary = xml.xpath('//div[@id="content"]')
item.author = xml.xpath('//meta[@name="author"]/@content')
end
end
end
puts rss