Class: Fullstack::Cms::Configuration
- Inherits:
-
Object
- Object
- Fullstack::Cms::Configuration
- Defined in:
- lib/fullstack/cms/configuration.rb
Instance Attribute Summary collapse
- #linkables ⇒ Object
- #localized ⇒ Object (also: #localize, #localized?)
- #prepend_locale_to_path ⇒ Object
Instance Method Summary collapse
- #default_locale ⇒ Object
-
#menu(uid, options = {}) ⇒ Object
config.menu( ‘main’, :localized => true ).
- #resources(&block) ⇒ Object
-
#setting(key, options = {}) ⇒ Object
config.setting(‘description’, :kind => :text, :localized => true, :group => group) setting(‘website/description’, :locale => I18n.locale).
Instance Attribute Details
#linkables ⇒ Object
21 22 23 |
# File 'lib/fullstack/cms/configuration.rb', line 21 def linkables @linkables || [] end |
#localized ⇒ Object Also known as: localize, localized?
11 12 13 |
# File 'lib/fullstack/cms/configuration.rb', line 11 def localized @localized.nil? ? true : @localized end |
#prepend_locale_to_path ⇒ Object
17 18 19 |
# File 'lib/fullstack/cms/configuration.rb', line 17 def prepend_locale_to_path @prepend_locale_to_path.nil? ? true : @prepend_locale_to_path end |
Instance Method Details
#default_locale ⇒ Object
7 8 9 |
# File 'lib/fullstack/cms/configuration.rb', line 7 def default_locale "#{I18n.default_locale}" || "en" end |
#menu(uid, options = {}) ⇒ Object
config.menu( ‘main’, :localized => true )
… menu( ‘main’, :locale => I18n.locale ) menu_items( ‘main’, :locale => I18n.locale )
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fullstack/cms/configuration.rb', line 37 def (uid, = {}) return nil unless Menu.table_exists? = .reverse_merge({:localized => localized?}) = .delete(:localized) if && localized? # ignores the option if CMS is not localized I18n.available_locales.each do |locale| m = Menu.find_or_create_by_uid_and_locale(uid.to_s, locale.to_s) raise m.errors..join("\n") if m.errors.any? end else m = Menu.find_or_create_by_uid(uid.to_s) raise m.errors..join("\n") if m.errors.any? end end |
#resources(&block) ⇒ Object
25 26 27 |
# File 'lib/fullstack/cms/configuration.rb', line 25 def resources(&block) Fullstack::Admin.resources(&block) end |
#setting(key, options = {}) ⇒ Object
config.setting(‘description’, :kind => :text, :localized => true, :group => group) setting(‘website/description’, :locale => I18n.locale)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fullstack/cms/configuration.rb', line 58 def setting(key, = {}) return nil unless Setting.table_exists? = .reverse_merge({ :localized => localized? }).merge({ :autocreate => true }) localized_setting = .delete(:localized) if localized_setting && localized? # ignores the option if CMS is not localized I18n.available_locales.each do |locale| Setting.global(key.to_s, .merge(:locale => locale.to_s)) end else Setting.global(key.to_s, ) end end |