Class: CamaleonCms::ApplicationDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- CamaleonCms::ApplicationDecorator
- Includes:
- MetasDecoratorMethods
- Defined in:
- app/decorators/camaleon_cms/application_decorator.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Direct Known Subclasses
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
58 59 60 61 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 58 def _calc_locale(_l) _l = (_l || @_deco_locale || (h.cama_get_i18n_frontend rescue false) || I18n.locale).to_s "_#{_l}" end |
#get_locale(locale = nil) ⇒ Object
get the locale for current decorator
53 54 55 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 53 def get_locale(locale = nil) locale || @_deco_locale || (h.cama_get_i18n_frontend rescue false) || I18n.locale end |
#set_decoration_locale(locale) ⇒ Object
48 49 50 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 48 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
42 43 44 45 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 42 def (add_post_type = true) (add_post_type) h. end |
#the_created_at(format = :long) ⇒ Object
return created at date formatted
31 32 33 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 31 def the_created_at(format = :long) h.l(object.created_at, format: format.to_sym) end |
#the_id ⇒ Object
return the identifier
26 27 28 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 26 def the_id "#{object.id}" end |
#the_keywords ⇒ Object
return the keywords for this model
15 16 17 18 19 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 15 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
21 22 23 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 21 def the_slug(locale = nil) object.slug.translate(get_locale(locale)) end |
#the_updated_at(format = :long) ⇒ Object
return updated at date formatted
36 37 38 |
# File 'app/decorators/camaleon_cms/application_decorator.rb', line 36 def the_updated_at(format = :long) h.l(object.created_at, format: format.to_sym) end |