Class: Nesta::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/nesta-plugin-metadata-extensions/init.rb

Instance Method Summary collapse

Instance Method Details

#contactObject



94
95
96
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 94

def contact
  ('contact')
end

#full_titleObject

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 menu_label
    menu_label
  else
    "<unknown>"
  end
end

#h1Object



69
70
71
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 69

def h1
  ('h1')
end

#headingObject



86
87
88
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 86

def heading
  full_title
end

#inferred_headingObject



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

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
  @menu_label ||= if ('menu label')
    ('menu label')
  elsif inferred_heading
    inferred_heading
  elsif h1
    h1
  else
    "<unknown>"
  end
end

#urlObject



90
91
92
# File 'lib/nesta-plugin-metadata-extensions/init.rb', line 90

def url
  ('url')
end