class Humpyard::Pages::NewsPage

Humpyard::Pages::NewsPage is a page containing news articles

Public Instance Methods

child_pages() click to toggle source
# File app/models/humpyard/pages/news_page.rb, line 35
def child_pages
  []
end
is_humpyard_dynamic_page?() click to toggle source
# File app/models/humpyard/pages/news_page.rb, line 11
def is_humpyard_dynamic_page?
  true
end
last_modified_with_news_items() click to toggle source

Return the logical modification time for the page, suitable for http caching, generational cache keys, etc.

# File app/models/humpyard/pages/news_page.rb, line 64
def last_modified_with_news_items
  timestamps = [last_modified_without_news_items] + news_items.collect{|i| i.updated_at}
  timestamps.sort.last
end
parent_page() click to toggle source
Calls superclass method
# File app/models/humpyard/pages/news_page.rb, line 39
def parent_page
  super
end
parse_path(path) click to toggle source
# File app/models/humpyard/pages/news_page.rb, line 15
def parse_path(path)
  return nil if path.size != 4
  begin
    item_created_on = Time.local(path[0], path[1], path[2]).to_date
  rescue
    # Rescue if no valid date was given in first 3 path parts
    return nil
  end
  
  item = news_items.find_by_title_for_url(path[3])
  return nil if item.nil?
  
  return nil if item.created_at.to_date != item_created_on
  
  return {
    :partial => 'detail',
    :locals => {:item => item}
    }
end
site_map(locale) click to toggle source
# File app/models/humpyard/pages/news_page.rb, line 43
def site_map(locale)
  if page.in_sitemap        
    {
      :url => page.human_url(:locale => locale),
      :lastmod => page.last_modified,
      :hidden => !page.in_sitemap,
      :children => news_items.map do |i|
        { 
          :url => i.human_url(:locale => locale),
          :lastmod => i.updated_at,
          :hidden => !page.in_sitemap,
          :children => []
        }
      end
    }  
  else
    nil
  end
end