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



63
64
65
66
67
68
69
70
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 63

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



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

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

#marshal_dumpObject



7
8
9
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 7

def marshal_dump
  @object
end

#marshal_load(obj) ⇒ Object



11
12
13
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 11

def marshal_load(obj)
  @object = obj
end

#set_decoration_locale(locale) ⇒ Object




49
50
51
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 49

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



43
44
45
46
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 43

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



32
33
34
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 32

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

#the_idObject

return the identifier



27
28
29
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 27

def the_id
  object.id.to_s
end

#the_keywordsObject

return the keywords for this model



16
17
18
19
20
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 16

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



22
23
24
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 22

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

#the_updated_at(format = :long) ⇒ Object

return updated at date formatted



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

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