Module: RocketCMS
- Defined in:
- lib/rocket_cms.rb,
lib/rocket_cms/menu.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/seo.rb,
lib/rocket_cms/url_helper.rb,
lib/rocket_cms/models/menu.rb,
lib/rocket_cms/models/news.rb,
lib/rocket_cms/models/page.rb,
lib/rocket_cms/seo_helpers.rb,
lib/rocket_cms/configuration.rb,
lib/rocket_cms/controllers/news.rb,
lib/rocket_cms/controllers/pages.rb,
lib/rocket_cms/controllers/search.rb,
lib/rocket_cms/models/mongoid/seo.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/contact_message.rb,
lib/rocket_cms/models/active_record/seo.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/contact_message.rb,
lib/rocket_cms/models/active_record/contact_message.rb
Defined Under Namespace
Modules: Controller, Controllers, Menu, Migration, Model, Models, Search, SeoHelpers
Classes: Configuration, Engine, PatchDSL, UrlHelper
Constant Summary
collapse
- VERSION =
"0.15.2"
- @@patches =
{}
Class Method Summary
collapse
Class Method Details
.active_record? ⇒ Boolean
35
36
37
|
# File 'lib/rocket_cms.rb', line 35
def active_record?
RocketCMS.orm == :active_record
end
|
.app_url(object) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rocket_cms.rb', line 53
def app_url(object)
if object.class.name == 'Page'
if object.fullpath.blank?
url_helper.page_path(object)
else
object.fullpath
end
else
RocketCMS.custom_app_url(object)
end
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
|
9
10
11
|
# File 'lib/rocket_cms/configuration.rb', line 9
def self.configure
yield configuration
end
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/rocket_cms/admin.rb', line 109
def contact_message_config
Proc.new {
navigation_label I18n.t('rs.settings')
field :created_at do
read_only true
end
field :name
field :content
field :email
field :phone
RocketCMS.apply_patches self
RocketCMS.only_patches self, [:show, :list, :edit, :export]
}
end
|
.custom_app_url(object) ⇒ Object
49
50
51
|
# File 'lib/rocket_cms.rb', line 49
def custom_app_url(object)
url_helper.polymorphic_url(object, routing_type: :path)
end
|
.full? ⇒ Boolean
32
33
34
|
# File 'lib/rocket_cms.rb', line 32
def full?
!RocketCMS.light?
end
|
.map_config(is_active = true) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# 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
}
end
|
99
100
101
102
103
104
105
106
107
|
# File 'lib/rocket_cms/admin.rb', line 99
def
Proc.new {
navigation_label 'CMS'
field :text_slug
field :name
RocketCMS.apply_patches self
RocketCMS.only_patches self, [:show, :list, :edit, :export]
}
end
|
.model_namespace ⇒ Object
38
39
40
|
# File 'lib/rocket_cms.rb', line 38
def model_namespace
"RocketCMS::Models::#{RocketCMS.orm.to_s.camelize}"
end
|
.mongoid? ⇒ Boolean
29
30
31
|
# File 'lib/rocket_cms.rb', line 29
def mongoid?
RocketCMS.orm == :mongoid
end
|
.news_config ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/rocket_cms/admin.rb', line 125
def news_config
Proc.new {
navigation_label I18n.t('rs.cms')
field :enabled, :toggle
field :time do
sort_reverse true
end
field :name
unless RocketCMS.config.news_image_styles.nil?
field :image
end
field :excerpt
RocketCMS.apply_patches self
list do
RocketCMS.apply_patches self
sort_by :time
end
edit do
field :content, :ck_editor
RocketCMS.apply_patches self
group :seo, &RocketCMS.seo_config
end
RocketCMS.only_patches self, [:show, :list, :export]
}
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
41
42
43
|
# File 'lib/rocket_cms.rb', line 41
def orm_specific(name)
"#{model_namespace}::#{name}".constantize
end
|
.page_config ⇒ 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
|
# File 'lib/rocket_cms/admin.rb', line 44
def page_config
Proc.new {
RocketCMS.apply_patches self
navigation_label I18n.t('rs.cms')
list do
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 :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 do
read_only true
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
end
RocketCMS.only_patches self, [:show, :export]
nested_set({
max_depth: RocketCMS.config.
})
}
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 = true) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rocket_cms/admin.rb', line 19
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) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rocket_cms/admin.rb', line 31
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, :paperclip
end
end
|
.url_helper ⇒ Object
45
46
47
|
# File 'lib/rocket_cms.rb', line 45
def url_helper
@@url_helper ||= RocketCMS::UrlHelper.new
end
|