Module: RocketCMS
- Defined in:
- lib/rocket_cms.rb,
lib/rocket_cms/admin.rb,
lib/rocket_cms/model.rb,
lib/rocket_cms/patch.rb,
lib/rocket_cms/engine.rb,
lib/rocket_cms/version.rb,
lib/rocket_cms/migration.rb,
lib/rocket_cms/models/menu.rb,
lib/rocket_cms/models/news.rb,
lib/rocket_cms/models/page.rb,
lib/rocket_cms/configuration.rb,
lib/rocket_cms/models/gallery.rb,
lib/rocket_cms/controllers/news.rb,
lib/rocket_cms/controllers/pages.rb,
lib/rocket_cms/controllers/search.rb,
lib/rocket_cms/models/mongoid/menu.rb,
lib/rocket_cms/models/mongoid/news.rb,
lib/rocket_cms/models/mongoid/page.rb,
lib/rocket_cms/controllers/contacts.rb,
lib/rocket_cms/models/gallery_image.rb,
lib/rocket_cms/models/contact_message.rb,
lib/rocket_cms/models/mongoid/gallery.rb,
lib/rocket_cms/models/embedded_element.rb,
lib/rocket_cms/models/active_record/menu.rb,
lib/rocket_cms/models/active_record/news.rb,
lib/rocket_cms/models/active_record/page.rb,
lib/rocket_cms/models/mongoid/gallery_image.rb,
lib/rocket_cms/models/embedded_gallery_image.rb,
lib/rocket_cms/models/mongoid/contact_message.rb,
lib/rocket_cms/models/mongoid/embedded_element.rb,
lib/rocket_cms/models/active_record/contact_message.rb,
lib/rocket_cms/models/mongoid/embedded_gallery_image.rb
Defined Under Namespace
Modules: Controller, Controllers, ElasticSearch, Migration, Model, Models Classes: Configuration, Engine, PatchDSL
Constant Summary collapse
- VERSION =
"0.7.7.1"- @@patches =
{}
Class Method Summary collapse
- .active_record? ⇒ Boolean
- .apply_patches(s) ⇒ Object
- .config ⇒ Object
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .contact_message_config ⇒ Object
- .embedded_element_config(navigation_label = I18n.t('rs.cms'), fields = {}) ⇒ Object
- .embedded_image_config(fields = {}) ⇒ Object
- .gallery_config ⇒ Object
- .image_config(without_gallery = false, fields = {}) ⇒ Object
- .map_config(is_active = true) ⇒ Object
- .menu_config ⇒ Object
- .model_namespace ⇒ Object
- .mongoid? ⇒ Boolean
- .news_config(fields = {}) ⇒ Object
- .only_patches(s, sections) ⇒ Object
- .orm_specific(name) ⇒ Object
- .page_config(fields = {}) ⇒ Object
- .patch(model, &blk) ⇒ Object
- .seo_config(is_active = false) ⇒ Object
- .sitemap_data_config(is_active = false) ⇒ Object
Class Method Details
.active_record? ⇒ Boolean
46 47 48 |
# File 'lib/rocket_cms.rb', line 46 def active_record? RocketCMS.orm == :active_record end |
.apply_patches(s) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 ⇒ Object
5 6 7 |
# File 'lib/rocket_cms/configuration.rb', line 5 def self.config @configuration ||= Configuration.new end |
.configuration ⇒ Object
2 3 4 |
# File 'lib/rocket_cms/configuration.rb', line 2 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
9 10 11 |
# File 'lib/rocket_cms/configuration.rb', line 9 def self.configure yield configuration end |
.contact_message_config ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/rocket_cms/admin.rb', line 124 def Proc.new { I18n.t('rs.settings') field :created_at do read_only true end field :name field :content, :text field :email field :phone RocketCMS.apply_patches self RocketCMS.only_patches self, [:show, :list, :edit, :export] if block_given? yield end } end |
.embedded_element_config(navigation_label = I18n.t('rs.cms'), fields = {}) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/rocket_cms/admin.rb', line 222 def ( = I18n.t('rs.cms'), fields = {}) Proc.new { () unless .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 = {}) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/rocket_cms/admin.rb', line 245 def (fields = {}) jcrop_proc = Proc.new do :image_jcrop_options end if block_given? RocketCMS.( nil, {image: [:jcrop, jcrop_proc]}.merge(fields), yield ) else RocketCMS.( nil, {image: [:jcrop, jcrop_proc]}.merge(fields) ) end end |
.gallery_config ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/rocket_cms/admin.rb', line 264 def gallery_config Proc.new { 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 :image_jcrop_options end if block_given? yield end } end |
.image_config(without_gallery = false, fields = {}) ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/rocket_cms/admin.rb', line 293 def image_config(without_gallery = false, fields = {}) Proc.new { I18n.t('rs.gallery') field :enabled, :toggle unless without_gallery field :gallery end field :name, :string field :image, :jcrop do :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) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |
.menu_config ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rocket_cms/admin.rb', line 108 def Proc.new { 'CMS' field :enabled, :toggle field :text_slug field :name RocketCMS.apply_patches self RocketCMS.only_patches self, [:show, :list, :edit, :export] if block_given? yield end } end |
.model_namespace ⇒ Object
49 50 51 |
# File 'lib/rocket_cms.rb', line 49 def model_namespace "RocketCMS::Models::#{RocketCMS.orm.to_s.camelize}" end |
.mongoid? ⇒ Boolean
43 44 45 |
# File 'lib/rocket_cms.rb', line 43 def mongoid? RocketCMS.orm == :mongoid end |
.news_config(fields = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/rocket_cms/admin.rb', line 144 def news_config(fields = {}) Proc.new { I18n.t('rs.cms') list do scopes [:by_date, :enabled, nil] end field :enabled, :toggle field :time field :name unless RocketCMS.configuration.news_image_styles.nil? field :image, :jcrop do :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 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 end } end |
.only_patches(s, sections) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# 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) ⇒ Object
52 53 54 |
# File 'lib/rocket_cms.rb', line 52 def orm_specific(name) "#{model_namespace}::#{name}".constantize end |
.page_config(fields = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rocket_cms/admin.rb', line 44 def page_config(fields = {}) Proc.new { RocketCMS.apply_patches self 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 group :seo, &RocketCMS.seo_config group :sitemap_data, &RocketCMS.sitemap_data_config end RocketCMS.only_patches self, [:show, :export] nested_set({ max_depth: RocketCMS.configuration., scopes: [] }) if block_given? yield end } end |
.patch(model, &blk) ⇒ Object
55 56 57 |
# File 'lib/rocket_cms/patch.rb', line 55 def self.patch(model, &blk) @@patches[model] = PatchDSL.call(&blk) end |
.seo_config(is_active = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rocket_cms/admin.rb', line 23 def seo_config(is_active = false) Proc.new { active is_active label "SEO" field :h1, :string field :title, :string field :keywords, :text field :description, :text field :robots, :string field :og_title, :string field :og_image, :jcrop do :og_image_jcrop_options end if block_given? yield end } end |
.sitemap_data_config(is_active = false) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/rocket_cms/admin.rb', line 201 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 |