blob: 4c9df0d33de4f85c99d2cdf4d7e05ac404a1e94c (
plain)
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
|
module Gentoo
class PlanetGenerator < Jekyll::Generator
PLANET_XML = '_data/planet.xml'
def generate(site)
planetinfo = Nokogiri::XML(File.open(PLANET_XML))
# author is the only thing taken from the dublin core, we don't need namespaces for that
planetinfo.remove_namespaces!
site.data['planet'] ||= { 'posts' => [] }
planetinfo.xpath('/rss/channel/item').each do |item|
item_data = {}
item.children.each do |tag|
case tag.name
when 'title'
item_data['title'] = tag.text.partition(':')[2].strip
when 'link'
item_data['uri'] = tag.text
when 'creator'
if tag.text =~ /^(.*) \(([^)]+)\)$/
item_data['author'] = $1
item_data['nick'] = $2
end
end
end
site.data['planet']['posts'] << item_data
end
end
end
end
|