Class: RSSView

Inherits:
Object
  • Object
show all
Includes:
Precious::Views::AppHelpers, Precious::Views::RouteHelpers
Defined in:
lib/gollum/views/rss.rb

Constant Summary

Constants included from Precious::Views::RouteHelpers

Precious::Views::RouteHelpers::ROUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Precious::Views::RouteHelpers

#clean_url, included, #page_route, parse_routes

Methods included from Precious::Views::AppHelpers

#extract_page_dir

Constructor Details

#initialize(base_url, wiki_title, url, changes) ⇒ RSSView

Returns a new instance of RSSView.



10
11
12
13
14
15
# File 'lib/gollum/views/rss.rb', line 10

def initialize(base_url, wiki_title, url, changes)
  @base_url = base_url
  @wiki_title = wiki_title
  @url = url
  @changes = changes
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



8
9
10
# File 'lib/gollum/views/rss.rb', line 8

def base_url
  @base_url
end

Instance Method Details

#renderObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gollum/views/rss.rb', line 17

def render
  latest_changes = "#{@url}#{latest_changes_path}"
  RSS::Maker.make('2.0') do |maker|
    maker.channel.author = 'Gollum Wiki'
    maker.channel.updated = @changes.first.authored_date
    maker.channel.title = "#{@wiki_title} Latest Changes"
    maker.channel.description = "Latest Changes in #{@wiki_title}"
    maker.channel.link = latest_changes
    @changes.each do |change|
      maker.items.new_item do |item|
        item.link = latest_changes
        item.title = change.message
        item.updated = change.authored_date
        id = change.id
        files = change.stats.files.map do |files|
          [files[:old_file], files[:new_file]].compact.map do |file|
            f = extract_page_dir(file)
            "<li><a href=\"#{@url}#{page_route(f)}/#{id}\">#{f}</a></li>"
          end
        end
        item.description = "Commited by: <a href=\"mailto:#{change.author.email}\">#{change.author.name}</a><br/>Commit ID: #{id[0..6]}<br/><br/>Affected files:<ul>#{files.join}</ul>"
      end
    end
  end.to_s
end