Class: Spotlight::Sitemap
- Inherits:
-
Object
- Object
- Spotlight::Sitemap
- Defined in:
- app/models/concerns/spotlight/sitemap.rb
Overview
Generate a sitemap for the Spotlight exhibit content
Instance Attribute Summary collapse
-
#exhibit ⇒ Object
readonly
Returns the value of attribute exhibit.
-
#sitemap ⇒ Object
readonly
Returns the value of attribute sitemap.
Class Method Summary collapse
-
.add_all_exhibits(sitemap) ⇒ Object
Add all (published) spotlight exhibits to the given sitemap.
-
.add_exhibit(sitemap, exhibit) ⇒ Object
Add a single exhibit to the given sitemap.
Instance Method Summary collapse
-
#add_browse_categories ⇒ Object
Add published browse categories to the sitemap.
-
#add_exhibit_root ⇒ Object
Add the exhibit home page to the sitemap.
-
#add_pages ⇒ Object
Add all published feature and about pages to the sitemap.
-
#add_resources ⇒ Object
Add all catalog resources to the sitemap.
-
#add_resources! ⇒ Object
Add all exhibit resources to the sitemap.
-
#initialize(sitemap, exhibit) ⇒ Sitemap
constructor
A new instance of Sitemap.
Constructor Details
#initialize(sitemap, exhibit) ⇒ Sitemap
Returns a new instance of Sitemap.
32 33 34 35 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 32 def initialize(sitemap, exhibit) @sitemap = sitemap @exhibit = exhibit end |
Instance Attribute Details
#exhibit ⇒ Object (readonly)
Returns the value of attribute exhibit.
4 5 6 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 4 def exhibit @exhibit end |
#sitemap ⇒ Object (readonly)
Returns the value of attribute sitemap.
4 5 6 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 4 def sitemap @sitemap end |
Class Method Details
.add_all_exhibits(sitemap) ⇒ Object
Add all (published) spotlight exhibits to the given sitemap
10 11 12 13 14 15 16 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 10 def self.add_all_exhibits(sitemap) SitemapGenerator::Interpreter.send :include, Spotlight::Engine.routes.url_helpers Spotlight::Exhibit.published.find_each do |e| add_exhibit(sitemap, e) end end |
Instance Method Details
#add_browse_categories ⇒ Object
Add published browse categories to the sitemap
68 69 70 71 72 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 68 def add_browse_categories exhibit.searches.published.find_each do |s| sitemap.add sitemap.exhibit_browse_path(exhibit, s), priority: 0.5, lastmod: s.updated_at end end |
#add_exhibit_root ⇒ Object
Add the exhibit home page to the sitemap
50 51 52 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 50 def add_exhibit_root sitemap.add sitemap.exhibit_root_path(exhibit) end |
#add_pages ⇒ Object
Add all published feature and about pages to the sitemap
56 57 58 59 60 61 62 63 64 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 56 def add_pages exhibit.feature_pages.published.find_each do |p| sitemap.add sitemap.exhibit_feature_page_path(exhibit, p), priority: 0.8, lastmod: p.updated_at end exhibit.about_pages.published.find_each do |p| sitemap.add sitemap.exhibit_about_page_path(exhibit, p), priority: 0.5, lastmod: p.updated_at end end |
#add_resources ⇒ Object
Add all catalog resources to the sitemap
76 77 78 79 80 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 76 def add_resources exhibit.solr_documents.each do |d| sitemap.add sitemap.exhibit_solr_document_path(exhibit, d), priority: 0.25, lastmod: document_last_modified(d) end end |
#add_resources! ⇒ Object
Add all exhibit resources to the sitemap
39 40 41 42 43 44 45 46 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 39 def add_resources! return unless exhibit.published? add_exhibit_root add_pages add_resources add_browse_categories end |