module RocketCMS
Constants
- VERSION
Public Class Methods
active_record?()
click to toggle source
# File lib/rocket_cms.rb, line 47 def active_record? RocketCMS.orm == :active_record end
apply_patches(s)
click to toggle source
# File lib/rocket_cms/patch.rb, line 41 def self.apply_patches(s) if s.class.name.index('RailsAdmin::Config::Sections::').nil? if s.class.name == 'RailsAdmin::Config::Model' s.instance_eval(&@@patches[s.abstract_model.model_name][:admin]) unless @@patches[s.abstract_model.model_name].nil? else s.instance_eval(&@@patches[s.name][:model]) unless @@patches[s.name].nil? end else model = s.abstract_model.model_name action = s.class.name.split('::')[-1].downcase.to_sym s.instance_eval(&@@patches[model][action]) unless @@patches[model].nil? end end
config()
click to toggle source
# File lib/rocket_cms/configuration.rb, line 5 def self.config @configuration ||= Configuration.new end
configuration()
click to toggle source
# File lib/rocket_cms/configuration.rb, line 2 def self.configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
# File lib/rocket_cms/configuration.rb, line 9 def self.configure yield configuration end
contact_message_config() { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 144 def contact_message_config Proc.new { navigation_label I18n.t('rs.settings') field :c_at do read_only true end field :name field :content, :text field :email field :phone RocketCMS.config.contacts_fields.each_pair do |fn, ft| next if ft.nil? if ft.is_a?(Array) field fn, ft[1].to_sym else field fn end end if block_given? yield end RocketCMS.apply_patches self RocketCMS.only_patches self, [:show, :list, :edit, :export] } end
embedded_element_config(navigation_label = I18n.t('rs.cms'), fields = {}) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 258 def embedded_element_config(navigation_label = I18n.t('rs.cms'), fields = {}) Proc.new { navigation_label(navigation_label) unless navigation_label.nil? field :enabled, :toggle field :name, :string fields.each_pair do |name, type| if type.nil? field name else if type.is_a?(Array) field name, type[0], &type[1] else field name, type end end end if block_given? yield end } end
embedded_image_config(fields = {}) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 281 def embedded_image_config(fields = {}) jcrop_proc = Proc.new do jcrop_options :image_jcrop_options end if block_given? RocketCMS.embedded_element_config( nil, {image: [:jcrop, jcrop_proc]}.merge(fields), yield ) else RocketCMS.embedded_element_config( nil, {image: [:jcrop, jcrop_proc]}.merge(fields) ) end end
gallery_config() { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 300 def gallery_config Proc.new { navigation_label I18n.t('rs.gallery') field :enabled, :toggle field :name, :string field :slugs, :enum do enum_method do :slugs end visible do bindings[:view].current_user.admin? end multiple do true end end field :text_slug field :image, :jcrop do jcrop_options :image_jcrop_options end if block_given? yield end } end
image_config(without_gallery = false, fields = {}) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 329 def image_config(without_gallery = false, fields = {}) Proc.new { navigation_label I18n.t('rs.gallery') field :enabled, :toggle unless without_gallery field :gallery end field :name, :string field :image, :jcrop do jcrop_options :image_jcrop_options end fields.each_pair do |name, type| if type.nil? field name else field name, type end end if block_given? yield end } end
map_config(is_active = true) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 3 def map_config(is_active = true) Proc.new { active is_active label I18n.t('rs.map') field :address, :string field :map_address, :string field :map_hint, :string field :coordinates, :string do read_only true formatted_value{ bindings[:object].coordinates.to_json } end field :lat field :lon if block_given? yield end } end
model_namespace()
click to toggle source
# File lib/rocket_cms.rb, line 50 def model_namespace "RocketCMS::Models::#{RocketCMS.orm.to_s.camelize}" end
mongoid?()
click to toggle source
# File lib/rocket_cms.rb, line 44 def mongoid? RocketCMS.orm == :mongoid end
news_config(fields = {}) { |self| ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 173 def news_config(fields = {}) Proc.new { navigation_label I18n.t('rs.cms') list do scopes [:by_date, :enabled, nil] end field :enabled, :toggle field :time do sort_reverse true end field :name unless RocketCMS.config.news_image_styles.nil? field :image, :jcrop do jcrop_options :image_jcrop_options end end field :excerpt, :ck_editor field :slugs, :enum do enum_method do :slugs end visible do bindings[:view].current_user.admin? end multiple do true end end field :text_slug RocketCMS.apply_patches self list do RocketCMS.apply_patches self sort_by :time end edit do field :content, :ck_editor fields.each_pair do |name, type| if type.nil? field name else if type.is_a?(Array) field name, type[0], &type[1] else field name, type end end end RocketCMS.apply_patches self group :seo, &RocketCMS.seo_config group :sitemap_data, &RocketCMS.sitemap_data_config end RocketCMS.only_patches self, [:show, :list, :export] if block_given? yield(self) end } end
only_patches(s, sections)
click to toggle source
# File lib/rocket_cms/patch.rb, line 31 def self.only_patches(s, sections) s.instance_eval do sections.each do |section| send section do RocketCMS.apply_patches self end end end end
orm_specific(name)
click to toggle source
# File lib/rocket_cms.rb, line 53 def orm_specific(name) "#{model_namespace}::#{name}".constantize end
page_config(fields = {}) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 55 def page_config(fields = {}) Proc.new { RocketCMS.apply_patches self navigation_label I18n.t('rs.cms') list do scopes [:sorted, :enabled, nil] field :enabled, :toggle field :menus, :menu field :name field :fullpath do pretty_value do bindings[:view].content_tag(:a, bindings[:object].fullpath, href: bindings[:object].fullpath) end end field :redirect field :slug RocketCMS.apply_patches self end edit do field :name field :excerpt, :ck_editor field :content, :ck_editor RocketCMS.apply_patches self group :menu do label I18n.t('rs.menu') field :menus field :fullpath, :string do help I18n.t('rs.with_final_slash') end field :regexp, :string do help I18n.t('rs.page_url_regex') end field :redirect, :string do help I18n.t('rs.final_in_menu') end field :text_slug end fields.each_pair do |name, type| if type.nil? field name else if type.is_a?(Array) field name, type[0], &type[1] else field name, type end end end if Seo.separate_table? group :seo do active true field :seo do active true end end else group :seo, &RocketCMS.seo_config(true) end group :sitemap_data, &RocketCMS.sitemap_data_config end RocketCMS.only_patches self, [:show, :export] nested_set({ max_depth: RocketCMS.config.menu_max_depth, scopes: [] }) if block_given? yield end } end
patch(model, &blk)
click to toggle source
# File lib/rocket_cms/patch.rb, line 55 def self.patch(model, &blk) @@patches[model] = PatchDSL.call(&blk) end
seo_config(is_active = true)
click to toggle source
# File lib/rocket_cms/admin.rb, line 23 def seo_config(is_active = true) Proc.new { if respond_to?(:active) active is_active label "SEO" else visible false end RocketCMS.seo_fields(self) } end
seo_fields(s) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 35 def seo_fields(s) s.instance_eval do field :h1, :string field :title, :string field :keywords, :text field :description, :text field :robots, :string field :og_title, :string field :og_image, :jcrop do jcrop_options :og_image_jcrop_options end if block_given? yield end end end
sitemap_data_config(is_active = false) { || ... }
click to toggle source
# File lib/rocket_cms/admin.rb, line 237 def sitemap_data_config(is_active = false) Proc.new { active is_active label I18n.t('rs.sitemap_data') field :sitemap_show field :sitemap_lastmod field :sitemap_changefreq, :enum do enum do SitemapData::SITEMAP_CHANGEFREQ_ARRAY end end field :sitemap_priority if block_given? yield end } end