Class: ZRSS
- Inherits:
-
Zarchitect
- Object
- Zarchitect
- ZRSS
- Defined in:
- lib/zarchitect/rss.rb
Constant Summary
Constants inherited from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize ⇒ ZRSS
constructor
A new instance of ZRSS.
- #try_item(page) ⇒ Object
Methods inherited from Zarchitect
Constructor Details
#initialize ⇒ ZRSS
Returns a new instance of ZRSS.
3 4 5 |
# File 'lib/zarchitect/rss.rb', line 3 def initialize @items = Array.new end |
Instance Method Details
#build ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/zarchitect/rss.rb', line 21 def build rss = RSS::Maker.make("atom") do |maker| maker.channel.title = Zarchitect.conf.site_name maker.channel. = Zarchitect.conf.admin maker.channel.updated = Time.now.to_s maker.channel.about = Zarchitect.conf.site_description maker.channel.link = Zarchitect.conf.url @items.each do |item| maker.items.new_item do |rss_item| rss_item.title = item.title rss_item.pubDate = item.dates rss_item.description = item.description rss_item.link = item.link #rss_item.guid = item.guid end end end #write rss File.open("_html/feed.rss", "w") { |f| f.write(rss) } end |
#try_item(page) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/zarchitect/rss.rb', line 7 def try_item(page) return if page.draft return unless page.rss? if @items.count < Zarchitect.conf.rss_size # simply add page to rss items @items.push RSSItem.new(page) else # check if it's more recent than the oldest item in the feed if page.date > @items.last.date @items.pop @items.push RSSItem.new(page) end end @items.sort_by! { |i| i.date }.reverse! end |