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
35 def child_pages
36   []
37 end
is_humpyard_dynamic_page?() click to toggle source
   # File app/models/humpyard/pages/news_page.rb
11 def is_humpyard_dynamic_page?
12   true
13 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
64 def last_modified_with_news_items
65   timestamps = [last_modified_without_news_items] + news_items.collect{|i| i.updated_at}
66   timestamps.sort.last
67 end
parent_page() click to toggle source
Calls superclass method
   # File app/models/humpyard/pages/news_page.rb
39 def parent_page
40   super
41 end
parse_path(path) click to toggle source
   # File app/models/humpyard/pages/news_page.rb
15 def parse_path(path)
16   return nil if path.size != 4
17   begin
18     item_created_on = Time.local(path[0], path[1], path[2]).to_date
19   rescue
20     # Rescue if no valid date was given in first 3 path parts
21     return nil
22   end
23   
24   item = news_items.find_by_title_for_url(path[3])
25   return nil if item.nil?
26   
27   return nil if item.created_at.to_date != item_created_on
28   
29   return {
30     :partial => 'detail',
31     :locals => {:item => item}
32     }
33 end
site_map(locale) click to toggle source
   # File app/models/humpyard/pages/news_page.rb
43 def site_map(locale)
44   if page.in_sitemap        
45     {
46       :url => page.human_url(:locale => locale),
47       :lastmod => page.last_modified,
48       :hidden => !page.in_sitemap,
49       :children => news_items.map do |i|
50         { 
51           :url => i.human_url(:locale => locale),
52           :lastmod => i.updated_at,
53           :hidden => !page.in_sitemap,
54           :children => []
55         }
56       end
57     }  
58   else
59     nil
60   end
61 end