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

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xmlObject

Returns the value of attribute xml.



11
12
13
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 11

def xml
  @xml
end

Instance Method Details

#initialize(card, args) ⇒ Object



13
14
15
16
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 13

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

#pub_dateObject



68
69
70
71
72
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 68

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



43
44
45
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 43

def raw_feed_items
  [card]
end

#show(view, args) ⇒ Object



18
19
20
21
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 18

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

#view: closedObject



85
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 85

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

#view: comment_boxObject



79
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 79

view(:comment_box) { "" }

#view: contentObject



83
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 83

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

#view: feedObject

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 24

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 StandardError => e
    @xml.error "\n\nERROR rendering RSS: #{e.inspect}\n\n #{e.backtrace}"
  end
end

#view: feed_bodyObject



47
48
49
50
51
52
53
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 47

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



78
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 78

view(:feed_description) { "" }

#view: feed_itemObject



59
60
61
62
63
64
65
66
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 59

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



74
75
76
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 74

view :feed_item_description do
  render_open_content
end

#view: feed_titleObject



55
56
57
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 55

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


80
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 80

view(:menu) { "" }

#view: openObject



82
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 82

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

#view: open_contentObject



84
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/rss.rb', line 84

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