module Para::SeoTools::Helpers::PageHelper
Public Instance Methods
current_seo_tools_page()
click to toggle source
# File lib/para/seo_tools/helpers/page_helper.rb, line 19 def current_seo_tools_page RequestStore.store['para.seo_tools.current_seo_tools_page'] ||= seo_tools_page_for({ path: request.path }.reverse_merge(seo_tools_scope_for(request))) end
seo_tools_page_for(scope_hash = {})
click to toggle source
Retrieve the first page that matches the given scope conditions
# File lib/para/seo_tools/helpers/page_helper.rb, line 26 def seo_tools_page_for(scope_hash = {}) seo_tools_pages_for(scope_hash).first end
seo_tools_pages_for(scope_hash = {})
click to toggle source
Find all the pages with the given scope conditions, merged with the current page ones.
# File lib/para/seo_tools/helpers/page_helper.rb, line 33 def seo_tools_pages_for(scope_hash = {}) Para::SeoTools::Page.scope_with(scope_hash) end
seo_tools_scoped_sibling_for(*args)
click to toggle source
# File lib/para/seo_tools/helpers/page_helper.rb, line 37 def seo_tools_scoped_sibling_for(*args) seo_tools_scoped_siblings_for(*args).first end
seo_tools_scoped_siblings_for(path, scope_hash = {})
click to toggle source
# File lib/para/seo_tools/helpers/page_helper.rb, line 41 def seo_tools_scoped_siblings_for(path, scope_hash = {}) source_page = if Hash === path scope_hash = path current_seo_tools_page else Para::SeoTools::Page.find_by_path(path) end return Para::SeoTools::Page.none unless source_page scope_hash = scope_hash.reverse_merge(seo_tools_scope_for(request)) source_page.siblings.scope_with(scope_hash) end
Protected Instance Methods
seo_tools_scope_for(request)
click to toggle source
Return a simple scopes hash, letting the Page.scope_with method handle column and JSON field backed attributes
This method is meant to be overriden in app controllers to scope
# File lib/para/seo_tools/helpers/page_helper.rb, line 62 def seo_tools_scope_for(request) {}.tap do |hash| hash[:subdomain] = request.subdomain if Para::SeoTools.handle_subdomain hash[:domain] = request.domain if Para::SeoTools.handle_domain hash[:locale] = I18n.locale if I18n.available_locales.length > 1 end end