Class: CamaleonCms::ApplicationDecorator

Inherits:
Draper::Decorator
  • Object
show all
Includes:
MetasDecoratorMethods
Defined in:
app/decorators/camaleon_cms/application_decorator.rb

Instance Method Summary collapse

Methods included from MetasDecoratorMethods

#the_meta, #the_option

Instance Method Details

#_calc_locale(_l) ⇒ Object

return the current locale prefixed to add in frontend routes



55
56
57
58
59
60
61
62
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 55

def _calc_locale(_l)
  _l = (_l || @_deco_locale || begin
    h.cama_get_i18n_frontend
  rescue StandardError
    nil
  end || I18n.locale).to_s
  "_#{_l}"
end

#get_locale(locale = nil) ⇒ Object

get the locale for current decorator



46
47
48
49
50
51
52
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 46

def get_locale(locale = nil)
  locale || @_deco_locale || begin
    h.cama_get_i18n_frontend
  rescue StandardError
    nil
  end || I18n.locale
end

#set_decoration_locale(locale) ⇒ Object




41
42
43
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 41

def set_decoration_locale(locale)
  @_deco_locale = locale.to_sym
end

#the_breadcrumb(add_post_type = true) ⇒ Object

draw breadcrumb for this model add_post_type: true/false to include post type link



35
36
37
38
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 35

def the_breadcrumb(add_post_type = true)
  generate_breadcrumb(add_post_type)
  h.breadcrumb_draw
end

#the_created_at(format = :long) ⇒ Object

return created at date formatted



24
25
26
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 24

def the_created_at(format = :long)
  h.l(object.created_at, format: format.to_sym)
end

#the_idObject

return the identifier



19
20
21
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 19

def the_id
  object.id.to_s
end

#the_keywordsObject

return the keywords for this model



8
9
10
11
12
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 8

def the_keywords
  k = object.get_option('keywords', '')
  k = h.current_site.the_keywords if object.class.name != 'CamaleonCms::Site' && !k.present?
  k.to_s.translate(get_locale)
end

#the_slug(locale = nil) ⇒ Object



14
15
16
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 14

def the_slug(locale = nil)
  object.slug.translate(get_locale(locale))
end

#the_updated_at(format = :long) ⇒ Object

return updated at date formatted



29
30
31
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 29

def the_updated_at(format = :long)
  h.l(object.updated_at, format: format.to_sym)
end