ack_rocket_cms 0.7.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +45 -45
- data/README.md +64 -5
- data/app/assets/javascripts/{rocket_cms.js.coffee → rocket_cms.coffee} +0 -3
- data/app/controllers/concerns/rs_errors.rb +8 -4
- data/app/controllers/concerns/rs_localizeable.rb +26 -0
- data/app/controllers/concerns/rs_menu.rb +9 -2
- data/app/controllers/concerns/rs_pages.rb +14 -3
- data/app/helpers/gzip_helper.rb +27 -0
- data/app/models/concerns/seoable.rb +19 -30
- data/app/models/seo.rb +16 -0
- data/app/views/devise/registrations/edit.html.slim +21 -0
- data/app/views/devise/registrations/new.html.slim +21 -0
- data/app/views/devise/sessions/new.html.slim +18 -19
- data/app/views/devise/shared/_links.html.slim +4 -18
- data/app/views/news/show.html.slim +1 -1
- data/config/locales/en.rs.yml +1 -1
- data/config/locales/ru.rs.yml +11 -1
- data/lib/generators/rocket_cms/migration_generator.rb +1 -1
- data/lib/generators/rocket_cms/templates/admin.erb +8 -0
- data/lib/generators/rocket_cms/templates/migration_news.rb +10 -5
- data/lib/generators/rocket_cms/templates/migration_pages.rb +14 -5
- data/lib/generators/rocket_cms/templates/migration_seos.rb +14 -0
- data/lib/rocket_cms.rb +4 -0
- data/lib/rocket_cms/admin.rb +35 -8
- data/lib/rocket_cms/configuration.rb +7 -1
- data/lib/rocket_cms/controllers/contacts.rb +2 -2
- data/lib/rocket_cms/controllers/news.rb +1 -1
- data/lib/rocket_cms/controllers/search.rb +17 -0
- data/lib/rocket_cms/engine.rb +3 -3
- data/lib/rocket_cms/migration.rb +14 -11
- data/lib/rocket_cms/models/active_record/menu.rb +3 -0
- data/lib/rocket_cms/models/active_record/news.rb +6 -3
- data/lib/rocket_cms/models/active_record/page.rb +3 -0
- data/lib/rocket_cms/models/active_record/seo.rb +17 -0
- data/lib/rocket_cms/models/contact_message.rb +1 -1
- data/lib/rocket_cms/models/embedded_gallery_image.rb +4 -0
- data/lib/rocket_cms/models/gallery.rb +2 -0
- data/lib/rocket_cms/models/gallery_image.rb +2 -0
- data/lib/rocket_cms/models/mongoid/contact_message.rb +5 -5
- data/lib/rocket_cms/models/mongoid/embedded_gallery_image.rb +0 -1
- data/lib/rocket_cms/models/mongoid/gallery.rb +0 -1
- data/lib/rocket_cms/models/mongoid/gallery_image.rb +0 -1
- data/lib/rocket_cms/models/mongoid/news.rb +3 -4
- data/lib/rocket_cms/models/mongoid/page.rb +3 -2
- data/lib/rocket_cms/models/mongoid/seo.rb +23 -0
- data/lib/rocket_cms/models/news.rb +13 -5
- data/lib/rocket_cms/models/page.rb +7 -3
- data/lib/rocket_cms/models/seo.rb +17 -0
- data/lib/rocket_cms/seo_helpers.rb +13 -0
- data/lib/rocket_cms/version.rb +1 -1
- data/template.rb +4 -7
- metadata +13 -3
@@ -14,6 +14,7 @@ module RocketCMS
|
|
14
14
|
attr_accessor :news_image_styles
|
15
15
|
attr_accessor :news_per_page
|
16
16
|
attr_accessor :news_excerpt
|
17
|
+
attr_accessor :news_content_required
|
17
18
|
|
18
19
|
attr_accessor :error_layout
|
19
20
|
attr_accessor :menu_max_depth
|
@@ -27,6 +28,8 @@ module RocketCMS
|
|
27
28
|
attr_accessor :contacts_message_required
|
28
29
|
attr_accessor :contacts_captcha_error_message
|
29
30
|
|
31
|
+
attr_accessor :separate_seo_table
|
32
|
+
|
30
33
|
attr_accessor :localize
|
31
34
|
|
32
35
|
attr_accessor :recreate_contact_message_action
|
@@ -38,6 +41,7 @@ module RocketCMS
|
|
38
41
|
}
|
39
42
|
@news_per_page = 10
|
40
43
|
@news_excerpt = 12
|
44
|
+
@news_content_required = true
|
41
45
|
|
42
46
|
@error_layout = 'application'
|
43
47
|
@menu_max_depth = 2
|
@@ -54,6 +58,8 @@ module RocketCMS
|
|
54
58
|
@recreate_contact_message_action = "new"
|
55
59
|
|
56
60
|
@localize = false
|
61
|
+
|
62
|
+
@separate_seo_table = false
|
57
63
|
end
|
58
64
|
|
59
65
|
def search_enabled=(val)
|
@@ -64,4 +70,4 @@ module RocketCMS
|
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|
67
|
-
end
|
73
|
+
end
|
@@ -15,7 +15,7 @@ module RocketCMS
|
|
15
15
|
def create
|
16
16
|
@contact_message = model.new(message_params)
|
17
17
|
after_initialize
|
18
|
-
if RocketCMS.
|
18
|
+
if RocketCMS.config.contacts_captcha
|
19
19
|
meth = :save_with_captcha
|
20
20
|
else
|
21
21
|
meth = :save
|
@@ -63,7 +63,7 @@ module RocketCMS
|
|
63
63
|
ContactMessage
|
64
64
|
end
|
65
65
|
def message_params
|
66
|
-
params.require(:contact_message).permit(RocketCMS.
|
66
|
+
params.require(:contact_message).permit(RocketCMS.config.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -38,6 +38,23 @@ module RocketCMS
|
|
38
38
|
page: params[:page],
|
39
39
|
per_page: RocketCMS.configuration.search_per_page
|
40
40
|
)
|
41
|
+
# @results = Mongoid::Elasticsearch.search({
|
42
|
+
# body: {
|
43
|
+
# query: {
|
44
|
+
# query_string: {
|
45
|
+
# query: Mongoid::Elasticsearch::Utils.clean(params[:query])
|
46
|
+
# }
|
47
|
+
# },
|
48
|
+
# highlight: {
|
49
|
+
# fields: {
|
50
|
+
# name: {},
|
51
|
+
# content: {}
|
52
|
+
# }
|
53
|
+
# }
|
54
|
+
# }},
|
55
|
+
# page: params[:page],
|
56
|
+
# per_page: RocketCMS.config.search_per_page,
|
57
|
+
# )
|
41
58
|
end
|
42
59
|
end
|
43
60
|
end
|
data/lib/rocket_cms/engine.rb
CHANGED
@@ -31,12 +31,12 @@ module RocketCMS
|
|
31
31
|
|
32
32
|
config.after_initialize do
|
33
33
|
# trigger autoload so models are registered in Mongoid::Elasticearch
|
34
|
-
RocketCMS.
|
34
|
+
RocketCMS.config.search_models.map(&:constantize)
|
35
35
|
|
36
36
|
# Write default email settings to DB so they can be changed.
|
37
37
|
if Settings.table_exists?
|
38
|
-
Settings.default_email_from(default: 'noreply@
|
39
|
-
Settings.form_email(default: '
|
38
|
+
Settings.default_email_from(default: 'noreply@site.domain')
|
39
|
+
Settings.form_email(default: 'admin@site.domain')
|
40
40
|
Settings.email_topic(default: 'с сайта')
|
41
41
|
end
|
42
42
|
end
|
data/lib/rocket_cms/migration.rb
CHANGED
@@ -3,19 +3,21 @@ module RocketCMS
|
|
3
3
|
extend self
|
4
4
|
|
5
5
|
def seo_fields(t)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
if RocketCMS.config.localize
|
7
|
+
t.column :h1_translations, 'hstore', default: {}
|
8
|
+
t.column :title_translations, 'hstore', default: {}
|
9
|
+
t.column :keywords_translations, 'hstore', default: {}
|
10
|
+
t.column :description_translations, 'hstore', default: {}
|
11
|
+
t.column :og_title_translations, 'hstore', default: {}
|
12
|
+
else
|
13
|
+
t.string :h1
|
14
|
+
t.string :title
|
15
|
+
t.text :keywords
|
16
|
+
t.text :description
|
17
|
+
t.string :og_title
|
18
|
+
end
|
11
19
|
t.string :robots
|
12
|
-
t.string :og_title
|
13
20
|
t.attachment :og_image
|
14
|
-
|
15
|
-
#if RocketCMS.localize
|
16
|
-
#t.column :name_translations, 'hstore'
|
17
|
-
#t.column :name_translations, 'hstore'
|
18
|
-
#end
|
19
21
|
end
|
20
22
|
|
21
23
|
def map_fields(t)
|
@@ -29,3 +31,4 @@ module RocketCMS
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
34
|
+
|
@@ -4,9 +4,8 @@ module RocketCMS
|
|
4
4
|
module News
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
included do
|
7
|
-
unless RocketCMS.
|
8
|
-
has_attached_file :image, styles: RocketCMS.
|
9
|
-
validates_attachment_content_type :image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :image?
|
7
|
+
unless RocketCMS.config.news_image_styles.nil?
|
8
|
+
has_attached_file :image, styles: RocketCMS.config.news_image_styles
|
10
9
|
end
|
11
10
|
|
12
11
|
has_paper_trail
|
@@ -15,6 +14,10 @@ module RocketCMS
|
|
15
14
|
|
16
15
|
scope :after_now, -> { where("time < ?", Time.now) }
|
17
16
|
scope :by_date, -> { order(time: :desc) }
|
17
|
+
|
18
|
+
if RocketCMS.config.localize
|
19
|
+
translates :name, :excerpt, :content
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -9,6 +9,9 @@ module RocketCMS
|
|
9
9
|
has_paper_trail
|
10
10
|
validates_lengths_from_database only: [:name, :title, :content, :excerpt, :h1, :keywords, :robots, :og_title, :regexp, :redirect, :fullpath]
|
11
11
|
scope :sorted, -> { order(lft: :asc) }
|
12
|
+
if RocketCMS.config.localize
|
13
|
+
translates :name, :content
|
14
|
+
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RocketCMS
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Seo
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
has_attached_file :og_image, styles: {thumb: "800x600>"}
|
8
|
+
if RocketCMS.config.localize
|
9
|
+
translates :h1, :title, :keywords, :description, :og_title
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -10,7 +10,7 @@ module RocketCMS
|
|
10
10
|
apply_simple_captcha message: RocketCMS.configuration.contacts_captcha_error_message
|
11
11
|
|
12
12
|
validates_email_format_of :email, unless: 'email.blank?'
|
13
|
-
if RocketCMS.
|
13
|
+
if RocketCMS.config.contacts_message_required
|
14
14
|
validates_presence_of :content
|
15
15
|
end
|
16
16
|
validate do
|
@@ -4,11 +4,11 @@ module RocketCMS
|
|
4
4
|
module ContactMessage
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
included do
|
7
|
-
field :name, type: String
|
8
|
-
field :email, type: String
|
9
|
-
field :phone, type: String
|
10
|
-
field :content, type: String
|
11
|
-
RocketCMS.
|
7
|
+
field :name, type: String
|
8
|
+
field :email, type: String
|
9
|
+
field :phone, type: String
|
10
|
+
field :content, type: String
|
11
|
+
RocketCMS.config.contacts_fields.each_pair do |fn, ft|
|
12
12
|
next if ft.nil?
|
13
13
|
field fn, type: ft
|
14
14
|
end
|
@@ -11,7 +11,6 @@ module RocketCMS
|
|
11
11
|
include EmbeddedElement
|
12
12
|
|
13
13
|
has_mongoid_attached_file :image # need to override
|
14
|
-
validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
15
14
|
|
16
15
|
def image_file_name=(val)
|
17
16
|
return self[:image_file_name] = "" if val == ""
|
@@ -12,7 +12,6 @@ module RocketCMS
|
|
12
12
|
scope :sorted, -> { order_by([:lft, :asc]) }
|
13
13
|
|
14
14
|
has_mongoid_attached_file :image # need to override
|
15
|
-
validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
16
15
|
|
17
16
|
def image_file_name=(val)
|
18
17
|
return self[:image_file_name] = "" if val == ""
|
@@ -10,7 +10,6 @@ module RocketCMS
|
|
10
10
|
scope :sorted, -> { order_by([:lft, :asc]) }
|
11
11
|
|
12
12
|
has_mongoid_attached_file :image # need to override
|
13
|
-
validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
14
13
|
|
15
14
|
def image_file_name=(val)
|
16
15
|
return self[:image_file_name] = "" if val == ""
|
@@ -3,15 +3,14 @@ module RocketCMS
|
|
3
3
|
module Mongoid
|
4
4
|
module News
|
5
5
|
extend ActiveSupport::Concern
|
6
|
-
unless RocketCMS.
|
6
|
+
unless RocketCMS.config.news_image_styles.nil?
|
7
7
|
include ::Mongoid::Paperclip
|
8
8
|
end
|
9
9
|
included do
|
10
10
|
field :time, type: Time
|
11
11
|
index({enabled: 1, time: 1})
|
12
|
-
unless RocketCMS.
|
13
|
-
has_mongoid_attached_file :image, styles: RocketCMS.
|
14
|
-
validates_attachment_content_type :image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :image?
|
12
|
+
unless RocketCMS.config.news_image_styles.nil?
|
13
|
+
has_mongoid_attached_file :image, styles: RocketCMS.config.news_image_styles
|
15
14
|
|
16
15
|
def image_file_name=(val)
|
17
16
|
return self[:image_file_name] = "" if val == ""
|
@@ -6,9 +6,10 @@ module RocketCMS
|
|
6
6
|
included do
|
7
7
|
field :regexp, type: String, default: ""
|
8
8
|
field :redirect, type: String, default: ""
|
9
|
-
field :excerpt, type: String, localize: RocketCMS.
|
10
|
-
field :content, type: String, localize: RocketCMS.
|
9
|
+
field :excerpt, type: String, localize: RocketCMS.config.localize, default: ""
|
10
|
+
field :content, type: String, localize: RocketCMS.config.localize, default: ""
|
11
11
|
field :fullpath, type: String, default: ""
|
12
|
+
|
12
13
|
has_and_belongs_to_many :menus, inverse_of: :pages
|
13
14
|
acts_as_nested_set
|
14
15
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RocketCMS
|
2
|
+
module Models
|
3
|
+
module Mongoid
|
4
|
+
module Seo
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include ::Mongoid::Paperclip
|
7
|
+
included do
|
8
|
+
field :name, type: String, localize: RocketCMS.config.localize
|
9
|
+
field :h1, type: String, localize: RocketCMS.config.localize
|
10
|
+
|
11
|
+
field :title, type: String, localize: RocketCMS.config.localize
|
12
|
+
field :keywords, type: String, localize: RocketCMS.config.localize
|
13
|
+
field :description, type: String, localize: RocketCMS.config.localize
|
14
|
+
field :robots, type: String, localize: RocketCMS.config.localize
|
15
|
+
|
16
|
+
field :og_title, type: String, localize: RocketCMS.config.localize
|
17
|
+
has_mongoid_attached_file :og_image, styles: {thumb: "800x600>"}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -9,21 +9,29 @@ module RocketCMS
|
|
9
9
|
include SitemapData
|
10
10
|
include RocketCMS.orm_specific('News')
|
11
11
|
|
12
|
-
if RocketCMS.
|
12
|
+
if RocketCMS.config.search_enabled
|
13
13
|
include RocketCMS::ElasticSearch
|
14
14
|
end
|
15
15
|
|
16
16
|
included do
|
17
17
|
|
18
|
-
|
18
|
+
unless RocketCMS.config.news_image_styles.nil?
|
19
|
+
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
20
|
+
end
|
21
|
+
|
22
|
+
validates_presence_of :name
|
23
|
+
if RocketCMS.config.news_content_required
|
24
|
+
validates_presence_of :content
|
25
|
+
end
|
26
|
+
|
19
27
|
before_validation do
|
20
28
|
self.time = Time.now if self.time.blank?
|
21
29
|
end
|
22
30
|
scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
|
23
|
-
unless RocketCMS.
|
24
|
-
paginates_per RocketCMS.
|
31
|
+
unless RocketCMS.config.news_per_page.nil?
|
32
|
+
paginates_per RocketCMS.config.news_per_page
|
25
33
|
end
|
26
|
-
smart_excerpt :excerpt, :content, RocketCMS.
|
34
|
+
smart_excerpt :excerpt, :content, RocketCMS.config.news_excerpt
|
27
35
|
manual_slug :report_slug
|
28
36
|
|
29
37
|
RocketCMS.apply_patches self
|
@@ -10,7 +10,7 @@ module RocketCMS
|
|
10
10
|
|
11
11
|
include RocketCMS.orm_specific('Page')
|
12
12
|
|
13
|
-
if RocketCMS.
|
13
|
+
if RocketCMS.config.search_enabled
|
14
14
|
include RocketCMS::ElasticSearch
|
15
15
|
end
|
16
16
|
|
@@ -54,10 +54,14 @@ module RocketCMS
|
|
54
54
|
url.match(clean_regexp)
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
|
+
def regexp_prefix
|
59
|
+
""
|
60
|
+
end
|
61
|
+
|
58
62
|
def clean_regexp
|
59
63
|
if regexp.blank?
|
60
|
-
/^#{Regexp.escape(fullpath)}$/
|
64
|
+
/^#{regexp_prefix}#{Regexp.escape(fullpath)}$/
|
61
65
|
else
|
62
66
|
begin
|
63
67
|
/#{regexp}/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RocketCMS
|
2
|
+
module Models
|
3
|
+
module Seo
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include RocketCMS::Model
|
6
|
+
include Enableable
|
7
|
+
include RocketCMS.orm_specific('Seo')
|
8
|
+
include RocketCMS::SeoHelpers
|
9
|
+
|
10
|
+
included do
|
11
|
+
RocketCMS.apply_patches self
|
12
|
+
validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|