Class: CamaleonCms::ApplicationDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- CamaleonCms::ApplicationDecorator
- Includes:
- MetasDecoratorMethods
- Defined in:
- app/decorators/camaleon_cms/application_decorator.rb
Direct Known Subclasses
PostDecorator, TermTaxonomyDecorator, UserDecorator, UserRoleDecorator
Instance Method Summary collapse
-
#_calc_locale(_l) ⇒ Object
return the current locale prefixed to add in frontend routes.
-
#get_locale(locale = nil) ⇒ Object
get the locale for current decorator.
-
#set_decoration_locale(locale) ⇒ Object
———————.
-
#the_breadcrumb(add_post_type = true) ⇒ Object
draw breadcrumb for this model add_post_type: true/false to include post type link.
-
#the_created_at(format = :long) ⇒ Object
return created at date formatted.
-
#the_id ⇒ Object
return the identifier.
-
#the_keywords ⇒ Object
return the keywords for this model.
- #the_slug(locale = nil) ⇒ Object
-
#the_updated_at(format = :long) ⇒ Object
return updated at date formatted.
Methods included from MetasDecoratorMethods
Instance Method Details
#_calc_locale(_l) ⇒ Object
return the current locale prefixed to add in frontend routes
50 51 52 53 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 50 def _calc_locale(_l) _l = (_l || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale).to_s "_#{_l}" end |
#get_locale(locale = nil) ⇒ Object
get the locale for current decorator
45 46 47 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 45 def get_locale(locale = nil) locale || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale end |
#set_decoration_locale(locale) ⇒ Object
40 41 42 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 40 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
34 35 36 37 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 34 def (add_post_type = true) (add_post_type) h. end |
#the_created_at(format = :long) ⇒ Object
return created at date formatted
23 24 25 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 23 def the_created_at(format = :long) h.l(object.created_at, format: format.to_sym) end |
#the_id ⇒ Object
return the identifier
18 19 20 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 18 def the_id "#{object.id}" end |
#the_keywords ⇒ Object
return the keywords for this model
7 8 9 10 11 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 7 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
13 14 15 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 13 def the_slug(locale = nil) object.slug.translate(get_locale(locale)) end |
#the_updated_at(format = :long) ⇒ Object
return updated at date formatted
28 29 30 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 28 def the_updated_at(format = :long) h.l(object.updated_at, format: format.to_sym) end |