Sha256: f7361e77667de6d5001e27a0a9597af3ca6375e59bec16608173e3c9ad6f67fc
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
module PagesHelper def current_page @current_page end def part(name, opts = {}, &block) if @current_page schema = opts.delete(:schema) || PagePart klass = schema.is_a?(Class) ? schema : "#{schema.to_s.camelize}PagePart".constantize p = klass.find_or_create_by_name_and_page_id("#{name}", @current_page) if block_given? capture do block.call(p) end else p end end end def page_path_for(resource_or_page) page = resource_or_page.is_a?(Page) ? resource_or_page : Page.find_by_resource_type(resource_or_page.class.name.underscore) path = page.try(:path) if path.blank? "#not-found" else path.gsub(/:[A-z_]+/) do |seg| meth = seg.gsub(/^:/, "") resource_or_page.send(meth) end end end def page_url_for(resource_or_page) "#{request.protocol}#{request.host_with_port}#{page_path_for(resource_or_page)}" end def current_page_resource() if current_page && current_page.resourceful? controller.instance_variable_get("@#{current_page.resource_type}") end end def home? request.path == "/" end end
Version data entries
5 entries across 5 versions & 1 rubygems