Class: ODDB::View::Rss::Package

Inherits:
HtmlGrid::Component show all
Includes:
Latin1
Defined in:
src/view/rss/package.rb

Direct Known Subclasses

PriceCut, PriceRise, SlIntroduction

Instance Method Summary (collapse)

Methods included from Latin1

#sanitize

Methods inherited from HtmlGrid::Component

#additional_javascripts, #dynamic_html

Instance Method Details

- (Object) to_html(context)



28
29
30
31
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
# File 'src/view/rss/package.rb', line 28

def to_html(context)
  RSS::Maker.make('2.0') { |feed|
    feed.channel.title = @lookandfeel.lookup(@title)
    feed.channel.link = @lookandfeel._event_url(:home)
    feed.channel.description = @lookandfeel.lookup(@description)
    feed.channel.language = @session.language
    feed.image.url = @lookandfeel.resource(:logo_rss)
    feed.image.title = @lookandfeel.lookup(:logo)
    feed.encoding = 'UTF-8'
    feed.xml_stylesheets.new_xml_stylesheet.href = @lookandfeel.resource(:css)
    language = @session.language
    @model.each { |package|
      item = feed.items.new_item
      item.author = "ODDB.org"
      pcurrent = package.price_public
      plast = package.price_public(1)
      args = pcurrent.valid_from.strftime(@lookandfeel.lookup(:date_format)),
        package.name, package.size, package.price_public
      fmt = "%s: %s, %s, %s"
      if plast != nil && plast.to_f > 1e-10
        args.push((pcurrent - plast) / plast * 100.0)
        fmt = "%s: %s, %s, %s, %+.1f%%"
      end
      item.title = sanitize sprintf(fmt, *args)
      
      url = @lookandfeel._event_url(:show, :pointer => package.pointer)
      item.guid.content = item.link = url
      item.guid.isPermaLink = true
      item.date = pcurrent.valid_from

      comp = PackageTemplate.new(package, @session, self)
      item.description = sanitize(comp.to_html(context))
    }
  }.to_s
end