Module: Card::Set::All::Rss::RssFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod008-card-mod-format/all/rss.rb,
card/tmpsets/set/mod007-card-mod-format/all/rss.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xmlObject

Returns the value of attribute xml.



9
10
11
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 9

def xml
  @xml
end

Instance Method Details

#initialize(card, args) ⇒ Object



11
12
13
14
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 11

def initialize card, args
  super
  @xml = @parent ? @parent.xml : ::Builder::XmlMarkup.new
end

#pub_dateObject



65
66
67
68
69
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 65

def pub_date
  (card.updated_at || Time.zone.now).to_s(:rfc822)
  # updated_at fails on virtual
  # cards, because not all to_s's take args (just actual dates)
end

#raw_feed_itemsObject



40
41
42
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 40

def raw_feed_items
  [card]
end

#show(view, args) ⇒ Object



16
17
18
19
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 16

def show view, args
  view ||= :feed
  render! view, args
end

#view: closedObject



82
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 82

view :closed,       :link,   mod: All::Base::Format

#view: comment_boxObject



76
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 76

view(:comment_box) { "" }

#view: contentObject



80
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 80

view :content,      :core,   mod: All::Base::Format

#view: feedObject

FIXME: integrate this with common XML features when it is added



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 22

view :feed, cache: :never do
  return "RSS feeds disabled" unless Cardio.config.rss_enabled
  begin
    @xml.instruct! :xml, version: "1.0", standalone: "yes"
    @xml.rss version: "2.0",
             "xmlns:content" => "http://purl.org/rss/1.0/modules/content/" do
      @xml.channel do
        @xml.title       render_feed_title
        @xml.description render_feed_description
        @xml.link        render_url
        render_feed_body
      end
    end
  rescue => e
    @xml.error "\n\nERROR rendering RSS: #{e.inspect}\n\n #{e.backtrace}"
  end
end

#view: feed_bodyObject



44
45
46
47
48
49
50
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 44

view :feed_body, cache: :never do
  raw_feed_items.each do |item|
    @xml.item do
      subformat(item).render! :feed_item
    end
  end
end

#view: feed_descriptionObject



75
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 75

view(:feed_description) { "" }

#view: feed_itemObject



56
57
58
59
60
61
62
63
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 56

view :feed_item do
  @xml.title card.name
  add_name_context
  @xml.description render_feed_item_description
  @xml.pubDate pub_date
  @xml.link render_url
  @xml.guid render_url
end

#view: feed_item_descriptionObject



71
72
73
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 71

view :feed_item_description do
  render_open_content
end

#view: feed_titleObject



52
53
54
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 52

view :feed_title do
  Card::Rule.global_setting(:title) + " : " + card.name.gsub(/^\*/, "")
end


77
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 77

view(:menu) { "" }

#view: openObject



79
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 79

view :open,         :titled, mod: All::Base::Format

#view: open_contentObject



81
# File 'card/tmpsets/set/mod008-card-mod-format/all/rss.rb', line 81

view :open_content, :core,   mod: All::Base::Format