Module: PageEngine::InstanceMethods
- Defined in:
- lib/page_engine/instance_methods.rb
Instance Method Summary collapse
- #breadcrumb_replace(models = []) ⇒ Object
- #find_page(permalink = nil) ⇒ Object
- #get_layout ⇒ Object
- #page_title_replace(models = []) ⇒ Object
Instance Method Details
#breadcrumb_replace(models = []) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/page_engine/instance_methods.rb', line 44 def (models=[]) models.each do |m| key = m.class.to_s.underscore @breadcrumbs.each do || if .is_a? Page .title.scan(/\{\{#{key}_([_a-z]*)\}\}/).uniq.flatten.each do |attribute| if m.whitelist.include?(attribute) && m.respond_to?(attribute) .title.gsub!("{{#{key}_#{attribute}}}", m[attribute]) value = m.send(attribute) if value.is_a?(Date) || value.is_a?(Time) value = value.to_formatted_s(:short_ordinal) end .title.gsub!("{{#{key}_#{attribute}}}", value.to_s) else .title.gsub!("{{#{key}_#{attribute}}}", "<span style=\"color: red;\">###NOT SUPPORTED, try one of #{m.whitelist.join(',')}###") end end end end end end |
#find_page(permalink = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/page_engine/instance_methods.rb', line 11 def find_page(permalink=nil) if Page.should_be_found?(params) if permalink @page = Page.includes(:page_parts).published.viewable_by(get_current_page_viewer).where(:permalink => permalink) else @page = Page.includes(:page_parts).published.viewable_by(get_current_page_viewer).with_url(request, params).first end # See http://stackoverflow.com/questions/1595424/request-format-returning # This last format appears when the page is refreshed in IE if request.format.html? || request.format == '*/*' end end |
#get_layout ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/page_engine/instance_methods.rb', line 3 def get_layout if @page @page.layout.blank? ? Page.default_layout.to_s : @page.layout.to_s else Page.default_layout.to_s end end |
#page_title_replace(models = []) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/page_engine/instance_methods.rb', line 24 def page_title_replace(models=[]) models.each do |m| key = m.class.to_s.underscore @page.title.scan(/\{\{#{key}_([_a-z]*)\}\}/).uniq.flatten.each do |attribute| if m.whitelist.include?(attribute) && m.respond_to?(attribute) @page.title.gsub!("{{#{key}_#{attribute}}}", m[attribute]) value = m.send(attribute) if value.is_a?(Date) || value.is_a?(Time) value = value.to_formatted_s(:short_ordinal) end @page.title.gsub!("{{#{key}_#{attribute}}}", value.to_s) else @page.title.gsub!("{{#{key}_#{attribute}}}", "<span style=\"color: red;\">###NOT SUPPORTED, try #{m.whitelist.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or')}###") end end end end |