Module: SolidusSitemap::SolidusDefaults
- Includes:
- Spree::BaseHelper
- Defined in:
- lib/solidus_sitemap/solidus_defaults.rb
Instance Method Summary collapse
- #add_account(options = {}) ⇒ Object
- #add_login(options = {}) ⇒ Object
- #add_pages(options = {}) ⇒ Object
- #add_password_reset(options = {}) ⇒ Object
- #add_product(product, options = {}) ⇒ Object
- #add_products(options = {}) ⇒ Object
- #add_signup(options = {}) ⇒ Object
- #add_taxon(taxon, options = {}) ⇒ Object
- #add_taxons(options = {}) ⇒ Object
- #default_url_options ⇒ Object
- #gem_available?(name) ⇒ Boolean
- #main_app ⇒ Object
Instance Method Details
#add_account(options = {}) ⇒ Object
17 18 19 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 17 def add_account( = {}) add(account_path, ) end |
#add_login(options = {}) ⇒ Object
9 10 11 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 9 def add_login( = {}) add(login_path, ) end |
#add_pages(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 49 def add_pages( = {}) # TODO: this should be refactored to add_pages & add_page Spree::Page.active.each do |page| add(page.path, .merge(lastmod: page.updated_at)) end if gem_available? 'spree_essential_cms' Spree::Page.visible.each do |page| add(page.slug, .merge(lastmod: page.updated_at)) end if gem_available? 'spree_static_content' end |
#add_password_reset(options = {}) ⇒ Object
21 22 23 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 21 def add_password_reset( = {}) add(new_spree_user_password_path, ) end |
#add_product(product, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 34 def add_product(product, = {}) opts = .merge(lastmod: product.updated_at) if gem_available?('spree_videos') && product.videos.present? # TODO: add exclusion list configuration option # https://sites.google.com/site/webmasterhelpforum/en/faq-video-sitemaps#multiple-pages # don't include all the videos on the page to avoid duplicate title warnings primary_video = product.videos.first opts.merge!(video: [(primary_video.youtube_ref, product)]) end add(product_path(product), opts) end |
#add_products(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 25 def add_products( = {}) active_products = Spree::Product.active.uniq add(products_path, .merge(lastmod: active_products.last_updated)) active_products.each do |product| add_product(product, ) end end |
#add_signup(options = {}) ⇒ Object
13 14 15 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 13 def add_signup( = {}) add(signup_path, ) end |
#add_taxon(taxon, options = {}) ⇒ Object
65 66 67 68 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 65 def add_taxon(taxon, = {}) add(nested_taxons_path(taxon.permalink), .merge(lastmod: taxon.products.last_updated)) if taxon.permalink.present? taxon.children.each { |child| add_taxon(child, ) } end |
#add_taxons(options = {}) ⇒ Object
61 62 63 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 61 def add_taxons( = {}) Spree::Taxon.roots.each { |taxon| add_taxon(taxon, ) } end |
#default_url_options ⇒ Object
5 6 7 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 5 def { host: SitemapGenerator::Sitemap.default_host } end |
#gem_available?(name) ⇒ Boolean
70 71 72 73 74 75 76 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 70 def gem_available?(name) Gem::Specification.find_by_name(name) rescue Gem::LoadError false rescue Gem.available?(name) end |
#main_app ⇒ Object
78 79 80 |
# File 'lib/solidus_sitemap/solidus_defaults.rb', line 78 def main_app Rails.application.routes.url_helpers end |