Class: Nesta::Page
- Inherits:
-
Object
- Object
- Nesta::Page
- Defined in:
- lib/nesta-plugin-metadata-extensions/init.rb
Instance Method Summary collapse
- #contact ⇒ Object
-
#full_title ⇒ Object
Custom login to infer the page title, useful if you want to template the page heading.
- #h1 ⇒ Object
- #heading ⇒ Object
- #inferred_heading ⇒ Object
-
#menu_label ⇒ Object
A label for this page to be used in menus.
- #url ⇒ Object
Instance Method Details
#contact ⇒ Object
94 95 96 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 94 def contact ('contact') end |
#full_title ⇒ Object
Custom login to infer the page title, useful if you want to template the page heading
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 44 def full_title @full_title ||= if inferred_heading inferred_heading elsif h1 h1 elsif else "<unknown>" end end |
#h1 ⇒ Object
69 70 71 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 69 def h1 ('h1') end |
#heading ⇒ Object
86 87 88 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 86 def heading full_title end |
#inferred_heading ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 73 def inferred_heading regex = case @format when :mdown /^#\s*(.*?)(\s*#+|$)/ when :haml /^\s*%h1\s+(.*)/ when :textile /^\s*h1\.\s+(.*)/ end markup =~ regex Regexp.last_match(1) end |
#menu_label ⇒ Object
A label for this page to be used in menus
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 57 def @menu_label ||= if ('menu label') ('menu label') elsif inferred_heading inferred_heading elsif h1 h1 else "<unknown>" end end |
#url ⇒ Object
90 91 92 |
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 90 def url ('url') end |