Module: Polygon::Helpers
- Defined in:
- lib/polygon/helpers.rb
Instance Method Summary collapse
- #database ⇒ Object
- #dynamic ⇒ Object
- #in_development ⇒ Object
- #in_production ⇒ Object
- #in_test ⇒ Object
- #normalize_path(path) ⇒ Object
- #page_locals(path = "") ⇒ Object (also: #index_locals)
- #sitemap_locals ⇒ Object
- #static ⇒ Object
- #templates ⇒ Object
Instance Method Details
#database ⇒ Object
16 17 18 |
# File 'lib/polygon/helpers.rb', line 16 def database Polygon.connection(settings.doc_folder) end |
#dynamic ⇒ Object
8 9 10 |
# File 'lib/polygon/helpers.rb', line 8 def dynamic settings.dynamic end |
#in_development ⇒ Object
28 29 30 |
# File 'lib/polygon/helpers.rb', line 28 def in_development settings.environment == :development end |
#in_production ⇒ Object
20 21 22 |
# File 'lib/polygon/helpers.rb', line 20 def in_production settings.environment == :production end |
#in_test ⇒ Object
24 25 26 |
# File 'lib/polygon/helpers.rb', line 24 def in_test settings.environment == :test end |
#normalize_path(path) ⇒ Object
36 37 38 39 40 |
# File 'lib/polygon/helpers.rb', line 36 def normalize_path(path) path = path[1..-1] if path =~ /^\// path = path[0...-1] if path =~ /\/$/ path end |
#page_locals(path = "") ⇒ Object Also known as: index_locals
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/polygon/helpers.rb', line 42 def page_locals(path = "") path = normalize_path(path) rel = database.relvar{ unwrap( extend( restrict(sitemap, path: path), data: ->{ entry }), :data) } rel && rel.to_a.first end |
#sitemap_locals ⇒ Object
32 33 34 |
# File 'lib/polygon/helpers.rb', line 32 def sitemap_locals index_locals.merge(:urls => database.query{ sitemap }) end |
#static ⇒ Object
4 5 6 |
# File 'lib/polygon/helpers.rb', line 4 def static settings.static end |
#templates ⇒ Object
12 13 14 |
# File 'lib/polygon/helpers.rb', line 12 def templates settings.templates end |