Sha256: ce784c7f5856970c777d6167cfea7efca5a52fe1c771792512d267358a6a9b4e
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
%w{ rss/maker uri murlsh }.each { |m| require m } module Murlsh # Regenerate RSS feed after a new url has been added. class AddPost50UpdateRss < Plugin @hook = 'add_post' # content types to add an enclosure for EnclosureContentTypes = %w{ application/pdf audio/mpeg image/gif image/jpeg image/png } def self.run(url, config) output_file = 'rss.rss' feed = RSS::Maker.make('2.0') do |f| f.channel.title = f.channel.description = config.fetch('page_title', '') f.channel.link = URI.join(config.fetch('root_url'), output_file) f.items.do_sort = true Murlsh::Url.all(:order => 'id DESC', :limit => config.fetch('num_posts_feed', 25)).each do |mu| i = f.items.new_item i.title = mu.title_stripped i.link = mu.url i.date = mu.time if EnclosureContentTypes.include?(mu.content_type) i.enclosure.url = mu.url i.enclosure.type = mu.content_type i.enclosure.length = mu.content_length end end end Murlsh::openlock(output_file, 'w') { |f| f.write(feed) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
murlsh-1.0.0 | plugins/add_post_50_update_rss.rb |