Module: Polygon::Helpers

Defined in:
lib/polygon/helpers.rb

Instance Method Summary collapse

Instance Method Details

#databaseObject



16
17
18
# File 'lib/polygon/helpers.rb', line 16

def database
  Polygon.connection(settings.doc_folder)
end

#dynamicObject



8
9
10
# File 'lib/polygon/helpers.rb', line 8

def dynamic
  settings.dynamic
end

#in_developmentObject



28
29
30
# File 'lib/polygon/helpers.rb', line 28

def in_development
  settings.environment == :development
end

#in_productionObject



20
21
22
# File 'lib/polygon/helpers.rb', line 20

def in_production
  settings.environment == :production
end

#in_testObject



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_localsObject



32
33
34
# File 'lib/polygon/helpers.rb', line 32

def sitemap_locals
  index_locals.merge(:urls => database.query{ sitemap })
end

#staticObject



4
5
6
# File 'lib/polygon/helpers.rb', line 4

def static
  settings.static
end

#templatesObject



12
13
14
# File 'lib/polygon/helpers.rb', line 12

def templates
  settings.templates
end