Module: CommonwealthVlrEngine::PagesHelperBehavior

Included in:
PagesHelper
Defined in:
app/helpers/commonwealth_vlr_engine/pages_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#render_about_site_pathObject



33
34
35
# File 'app/helpers/commonwealth_vlr_engine/pages_helper_behavior.rb', line 33

def render_about_site_path
  about_site_path
end

#render_blog_feed(source = t('blacklight.home.context.news.rss_link')) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/commonwealth_vlr_engine/pages_helper_behavior.rb', line 6

def render_blog_feed(source = t('blacklight.home.context.news.rss_link'))
  if source.present?
    feed = Rails.cache.fetch('dc_rss_feed', :expires_in => 60.minutes) do
      RSS::Parser.parse(open(source).read, false).items[0..3]
    end
  end
  if source.present? && feed.length > 0
    content = []
    feed.each do |item|
      content << (:li,
                             link_to(item.title,
                                     item.link,
                                     :class => 'feed_item_link',
                                     :target => '_blank'),
                             :class => 'feed_item')
    end
    (:ul, content.join().html_safe, :class => 'feed_items')
  else
    (:p,
                'Visit ' + link_to(t('blacklight.home.context.news.blog_title'),
                                   t('blacklight.home.context.news.blog_url'),
                                   :target => '_blank') + ' for the latest updates.')
  end
rescue
  (:p, 'No news at the moment, please check back later...')
end