Sha256: 1ed9d397916963f07e34fd257c9f8118ca7c3857e5dac5b2ffd7be18cdc64576
Contents?: true
Size: 867 Bytes
Versions: 3
Compression:
Stored size: 867 Bytes
Contents
require 'uri' require 'rack' require 'murlsh' module Murlsh # Serve RSS feed. class RssServer def initialize(config); @config = config; end # Respond to a GET request for RSS feed. def get(req) conditions = Murlsh::SearchConditions.new(req['q']).conditions page = 1 per_page = config.fetch('num_posts_feed', 25) result_set = Murlsh::UrlResultSet.new(conditions, page, per_page) urls = result_set.results feed_url = URI.join(config.fetch('root_url'), 'rss.rss') body = Murlsh::RssBody.new(config, req, feed_url, urls) resp = Rack::Response.new(body, 200, 'Cache-Control' => 'must-revalidate, max-age=0', 'Content-Type' => 'application/rss+xml') if u = body.updated resp['Last-Modified'] = u.httpdate end resp end attr_reader :config end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
murlsh-1.6.1 | lib/murlsh/rss_server.rb |
murlsh-1.6.0 | lib/murlsh/rss_server.rb |
murlsh-1.5.0 | lib/murlsh/rss_server.rb |