Class: ODDB::View::Rss::Fachinfo

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

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)



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
69
70
71
72
73
74
75
76
77
# File 'src/view/rss/fachinfo.rb', line 35

def to_html(context)
  RSS::Maker.make('2.0') { |feed|
    feed.channel.title = @lookandfeel.lookup(:fachinfo_feed_title)
    feed.channel.link = @lookandfeel._event_url(:home)
    feed.channel.description = @lookandfeel.lookup(:fachinfo_feed_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 { |fachinfo|

      document = fachinfo.send(language)
      next unless(document.is_a?(FachinfoDocument))

      item = feed.items.new_item
      item.author = "ODDB.org"

      name = item.title = sanitize(fachinfo.localized_name(language))
      item.guid.content = item.link = @lookandfeel._event_url(:resolve, 
                                        :pointer => fachinfo.pointer)
      item.guid.isPermaLink = true
      item.date = fachinfo.revision

      comp = FachinfoTemplate.new(fachinfo, @session, self)

      ptrn = /#{Regexp.escape(name)}(®|\(TM\))?/u
      link = HtmlGrid::Link.new(:name, fachinfo, @session, self)
      link.href = @lookandfeel._event_url(:search, 
                                          :search_type => 'st_sequence', 
                                          :search_query => name.gsub('/', '%2F'))
      html = comp.to_html(context)
      html.gsub!(%r{<pre\b.*?</pre>}imu) { |match|
        match.gsub(%r{\n}u, '<BR>')
      }
      item.description = sanitize(html).gsub(ptrn) { |match|
        link.value = match
        link.to_html(context)
      }
    }
  }.to_s
end