-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_rss.rb
27 lines (24 loc) · 898 Bytes
/
gen_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
require 'rss'
require 'sqlite3'
require 'date'
class GenRss
def initialize
db = SQLite3::Database.open 'posts.db'
posts = db.query "SELECT * FROM tbl1 WHERE tags NOT LIKE 'site' ORDER BY date DESC"
rss = RSS::Maker.make("atom") do |maker|
maker.channel.author = "hepatica"
maker.channel.updated = Time.now.to_s
maker.channel.about = "https://krissy.club"
maker.channel.title = "Hepatiki"
posts.each_hash { |post|
maker.items.new_item do |item|
item.link = "https://krissy.club/?date=#{post['date']}"
item.title = post["date"]
item.updated = Time.at(post["date"]).to_s
item.description = post["content"]
end
}
end
File.open("rss.xml", 'w') { |file| file.write(rss) }
end
end