Module: Hancock::Admin

Defined in:
lib/hancock_cms.rb,
lib/hancock/admin.rb,
lib/hancock/admin/embedded_element.rb

Defined Under Namespace

Modules: EmbeddedElement

Class Method Summary collapse

Class Method Details

.caching_block(is_active = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hancock/admin.rb', line 23

def self.caching_block(is_active = false)
  Proc.new {
    active is_active
    label I18n.t('hancock.cache')
    field :perform_caching, :toggle
    field :cache_keys_str, :text

    if block_given?
      yield self
    end
  }
end

.content_block(is_active = false, options = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/hancock/admin.rb', line 45

def self.content_block(is_active = false, options = {})
  if is_active.is_a?(Hash)
    is_active, fields = (is_active[:active] || false), is_active
  end

  _excluded_fields = options.delete(:excluded_fields) || []
  Proc.new {
    active is_active
    label I18n.t('hancock.content')
    field :excerpt, :hancock_html unless _excluded_fields.include?(:excerpt)
    field :content, :hancock_html unless _excluded_fields.include?(:content)
  }
end

.map_config(is_active = false) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hancock/admin.rb', line 3

def self.map_config(is_active = false)
  Proc.new {
    active is_active
    label I18n.t('hancock.map')
    field :address, :string
    field :map_address, :string
    field :map_hint, :string
    field :coordinates, :string do
      read_only true
      formatted_value{ bindings[:object].coordinates.to_json }
    end
    field :lat
    field :lon

    if block_given?
      yield self
    end
  }
end

.url_block(is_active = false) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/hancock/admin.rb', line 36

def self.url_block(is_active = false)
  Proc.new {
    active is_active
    label I18n.t('hancock.url')
    field :slugs, :hancock_slugs
    field :text_slug
  }
end