Class: Nwiki::Frontend::Feed
- Inherits:
-
Object
- Object
- Nwiki::Frontend::Feed
- Defined in:
- lib/nwiki/frontend/app.rb
Instance Attribute Summary collapse
-
#articles_path ⇒ Object
readonly
Returns the value of attribute articles_path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(git_repo_path, opts = {}) ⇒ Feed
constructor
A new instance of Feed.
Constructor Details
Instance Attribute Details
#articles_path ⇒ Object (readonly)
Returns the value of attribute articles_path.
24 25 26 |
# File 'lib/nwiki/frontend/app.rb', line 24 def articles_path @articles_path end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/nwiki/frontend/app.rb', line 32 def call env [ 200, { 'Content-Type' => "application/atom+xml; charset=#{Nwiki::Core::Wiki.repo_filename_encoding}" }, [ RSS::Maker.make('atom') { |maker| maker.channel.title = @wiki.title maker.channel.description = @wiki.subtitle maker.channel.link = Rack::Request.new(env).url maker.channel. = @wiki. maker.channel.date = Time.parse('2014-02-06') maker.channel.id = Rack::Request.new(env).url maker.items.do_sort = true maker.items.max_size = 50 log = @wiki.access.repo.log log.each do |commit| date = commit.date commit.show.each do |diff| next unless diff.new_file path = Nwiki::Core::Wiki.canonicalize_path(diff.b_path) path.gsub!(/\.org$/, '') maker.items.new_item do |item| item.link = Rack::Request.new(env).url.gsub(Regexp.new(Rack::Request.new(env).fullpath), "#{articles_path}/#{path}") item.title = File.basename(path) item.date = date end end end }.to_s ] ] end |