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.
34 35 36 37 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 34 def initialize(sitemap, exhibit) @sitemap = sitemap @exhibit = exhibit end |
Instance Attribute Details
#exhibit ⇒ Object (readonly)
Returns the value of attribute exhibit.
6 7 8 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 6 def exhibit @exhibit end |
#sitemap ⇒ Object (readonly)
Returns the value of attribute sitemap.
6 7 8 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 6 def sitemap @sitemap end |
Class Method Details
.add_all_exhibits(sitemap) ⇒ Object
Add all (published) spotlight exhibits to the given sitemap
12 13 14 15 16 17 18 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 12 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
70 71 72 73 74 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 70 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
52 53 54 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 52 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
58 59 60 61 62 63 64 65 66 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 58 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
78 79 80 81 82 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 78 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
41 42 43 44 45 46 47 48 |
# File 'app/models/concerns/spotlight/sitemap.rb', line 41 def add_resources! return unless exhibit.published? add_exhibit_root add_pages add_resources add_browse_categories end |