rocket_cms 0.7.1 → 0.8.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +35 -35
  3. data/app/controllers/concerns/rs_errors.rb +1 -1
  4. data/app/models/concerns/seoable.rb +15 -34
  5. data/app/models/seo.rb +12 -0
  6. data/app/views/news/index.html.haml +1 -1
  7. data/app/views/news/show.html.haml +1 -1
  8. data/lib/generators/rocket_cms/migration_generator.rb +1 -1
  9. data/lib/generators/rocket_cms/templates/admin.erb +5 -1
  10. data/lib/generators/rocket_cms/templates/migration_news.rb +10 -5
  11. data/lib/generators/rocket_cms/templates/migration_pages.rb +14 -5
  12. data/lib/generators/rocket_cms/templates/migration_seos.rb +14 -0
  13. data/lib/rocket_cms.rb +3 -0
  14. data/lib/rocket_cms/admin.rb +27 -10
  15. data/lib/rocket_cms/controllers/contacts.rb +2 -2
  16. data/lib/rocket_cms/controllers/news.rb +1 -1
  17. data/lib/rocket_cms/controllers/search.rb +1 -1
  18. data/lib/rocket_cms/engine.rb +1 -1
  19. data/lib/rocket_cms/migration.rb +14 -11
  20. data/lib/rocket_cms/models/active_record/menu.rb +3 -0
  21. data/lib/rocket_cms/models/active_record/news.rb +2 -2
  22. data/lib/rocket_cms/models/active_record/seo.rb +17 -0
  23. data/lib/rocket_cms/models/contact_message.rb +1 -1
  24. data/lib/rocket_cms/models/mongoid/contact_message.rb +1 -1
  25. data/lib/rocket_cms/models/mongoid/news.rb +5 -5
  26. data/lib/rocket_cms/models/mongoid/page.rb +1 -1
  27. data/lib/rocket_cms/models/mongoid/seo.rb +23 -0
  28. data/lib/rocket_cms/models/news.rb +4 -4
  29. data/lib/rocket_cms/models/page.rb +1 -1
  30. data/lib/rocket_cms/models/seo.rb +24 -0
  31. data/lib/rocket_cms/version.rb +1 -1
  32. data/template.rb +1 -1
  33. metadata +9 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e24497b873e1c0fdaa11337bcf79ab60e44adc
4
- data.tar.gz: ba371d9579621d7127501e34c652d09b0e1e5efd
3
+ metadata.gz: a5e6b8f4f4811f703843bb7f92d916540b65f1da
4
+ data.tar.gz: 1fb08b8c8a19ba2b7ea74b9387228420968272ed
5
5
  SHA512:
6
- metadata.gz: 17f988247d191712da293b791e127539488758fcbbc4f30688cbdd95638ef276649222a5fc7d6ff1a2e30274c57b3c5dcdf9b7b4cebdb01b7bd98fef964dd8f9
7
- data.tar.gz: c5da155755ce1a3d5ff4addc5df3bb3cd142df201c1e2809089a0106cf3fd5abfbd259cbd2e44c3876584895f6f7a2d17d3a7d915ede16ad470b56cd6ecdf5c3
6
+ metadata.gz: 1e51e89502bec15e060ce1ff17492e946fb53714667e03dac2509aeaf24f4eae63c4a8ccd4c766ec0b2731219272724f8a5f791e35e11183aa77d4282eb0ffdc
7
+ data.tar.gz: 6c6835cf8fe9339d4b98a14185ca7e8da89ac195c12f9d8a0e7213020da5799fe25f5edaa21d363f17c0d1c2a95161529feb74270fe871dd80ebc6ed0bc29e2c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rocket_cms (0.7.1)
4
+ rocket_cms (0.8.0.pre.1)
5
5
  addressable
6
6
  coffee-rails
7
7
  devise
@@ -27,36 +27,36 @@ PATH
27
27
  GEM
28
28
  remote: https://rubygems.org/
29
29
  specs:
30
- actionmailer (4.2.2)
31
- actionpack (= 4.2.2)
32
- actionview (= 4.2.2)
33
- activejob (= 4.2.2)
30
+ actionmailer (4.2.3)
31
+ actionpack (= 4.2.3)
32
+ actionview (= 4.2.3)
33
+ activejob (= 4.2.3)
34
34
  mail (~> 2.5, >= 2.5.4)
35
35
  rails-dom-testing (~> 1.0, >= 1.0.5)
36
- actionpack (4.2.2)
37
- actionview (= 4.2.2)
38
- activesupport (= 4.2.2)
36
+ actionpack (4.2.3)
37
+ actionview (= 4.2.3)
38
+ activesupport (= 4.2.3)
39
39
  rack (~> 1.6)
40
40
  rack-test (~> 0.6.2)
41
41
  rails-dom-testing (~> 1.0, >= 1.0.5)
42
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
43
- actionview (4.2.2)
44
- activesupport (= 4.2.2)
42
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
43
+ actionview (4.2.3)
44
+ activesupport (= 4.2.3)
45
45
  builder (~> 3.1)
46
46
  erubis (~> 2.7.0)
47
47
  rails-dom-testing (~> 1.0, >= 1.0.5)
48
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
49
- activejob (4.2.2)
50
- activesupport (= 4.2.2)
48
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
49
+ activejob (4.2.3)
50
+ activesupport (= 4.2.3)
51
51
  globalid (>= 0.3.0)
52
- activemodel (4.2.2)
53
- activesupport (= 4.2.2)
52
+ activemodel (4.2.3)
53
+ activesupport (= 4.2.3)
54
54
  builder (~> 3.1)
55
- activerecord (4.2.2)
56
- activemodel (= 4.2.2)
57
- activesupport (= 4.2.2)
55
+ activerecord (4.2.3)
56
+ activemodel (= 4.2.3)
57
+ activesupport (= 4.2.3)
58
58
  arel (~> 6.0)
59
- activesupport (4.2.2)
59
+ activesupport (4.2.3)
60
60
  i18n (~> 0.7)
61
61
  json (~> 1.7, >= 1.7.7)
62
62
  minitest (~> 5.1)
@@ -95,7 +95,7 @@ GEM
95
95
  activesupport (>= 4.1.0)
96
96
  haml (4.0.6)
97
97
  tilt
98
- htmlentities (4.3.3)
98
+ htmlentities (4.3.4)
99
99
  i18n (0.7.0)
100
100
  jquery-rails (4.0.4)
101
101
  rails-dom-testing (~> 1.0)
@@ -125,16 +125,16 @@ GEM
125
125
  rack (~> 1.1)
126
126
  rack-test (0.6.3)
127
127
  rack (>= 1.0)
128
- rails (4.2.2)
129
- actionmailer (= 4.2.2)
130
- actionpack (= 4.2.2)
131
- actionview (= 4.2.2)
132
- activejob (= 4.2.2)
133
- activemodel (= 4.2.2)
134
- activerecord (= 4.2.2)
135
- activesupport (= 4.2.2)
128
+ rails (4.2.3)
129
+ actionmailer (= 4.2.3)
130
+ actionpack (= 4.2.3)
131
+ actionview (= 4.2.3)
132
+ activejob (= 4.2.3)
133
+ activemodel (= 4.2.3)
134
+ activerecord (= 4.2.3)
135
+ activesupport (= 4.2.3)
136
136
  bundler (>= 1.3.0, < 2.0)
137
- railties (= 4.2.2)
137
+ railties (= 4.2.3)
138
138
  sprockets-rails
139
139
  rails-deprecated_sanitizer (1.0.3)
140
140
  activesupport (>= 4.2.0.alpha)
@@ -163,9 +163,9 @@ GEM
163
163
  rails_admin_settings (1.0.0)
164
164
  rails_admin_toggleable (0.5.0)
165
165
  rails_admin (~> 0.6.6)
166
- railties (4.2.2)
167
- actionpack (= 4.2.2)
168
- activesupport (= 4.2.2)
166
+ railties (4.2.3)
167
+ actionpack (= 4.2.3)
168
+ activesupport (= 4.2.3)
169
169
  rake (>= 0.8.7)
170
170
  thor (>= 0.18.1, < 2.0)
171
171
  rake (10.4.2)
@@ -173,7 +173,7 @@ GEM
173
173
  responders (2.1.0)
174
174
  railties (>= 4.2.0, < 5)
175
175
  safe_yaml (1.0.4)
176
- sass (3.4.14)
176
+ sass (3.4.15)
177
177
  sass-rails (5.0.3)
178
178
  railties (>= 4.0.0, < 5.0)
179
179
  sass (~> 3.1)
@@ -192,7 +192,7 @@ GEM
192
192
  htmlentities
193
193
  sprockets (3.2.0)
194
194
  rack (~> 1.0)
195
- sprockets-rails (2.3.1)
195
+ sprockets-rails (2.3.2)
196
196
  actionpack (>= 3.0)
197
197
  activesupport (>= 3.0)
198
198
  sprockets (>= 2.8, < 4.0)
@@ -64,7 +64,7 @@ module RsErrors
64
64
  end
65
65
 
66
66
  def render_error(code = 500)
67
- render template: "errors/error_#{code}", formats: [:html], handlers: [:haml, :slim], layout: RocketCMS.configuration.error_layout, status: code
67
+ render template: "errors/error_#{code}", formats: [:html], handlers: [:haml, :slim], layout: RocketCMS.config.error_layout, status: code
68
68
  end
69
69
 
70
70
  def rails_admin?
@@ -1,42 +1,23 @@
1
1
  module Seoable
2
2
  extend ActiveSupport::Concern
3
- if RocketCMS.mongoid?
4
- include ::Mongoid::Paperclip
5
- end
6
-
7
- included do
8
- if RocketCMS.mongoid?
9
- field :name, type: String, localize: RocketCMS.configuration.localize
10
- field :h1, type: String, localize: RocketCMS.configuration.localize
3
+ LOCALIZED_FIELDS = [:h1, :title, :keywords, :description, :og_title]
4
+ FIELDS = LOCALIZED_FIELDS + [:og_image, :robots]
11
5
 
12
- field :title, type: String, localize: RocketCMS.configuration.localize
13
- field :keywords, type: String, localize: RocketCMS.configuration.localize
14
- field :description, type: String, localize: RocketCMS.configuration.localize
15
- field :robots, type: String, localize: RocketCMS.configuration.localize
6
+ if Seo.table_exists?
7
+ included do
8
+ has_one :seo, as: :seoable, autosave: true
9
+ after_create :create_seo
10
+ accepts_nested_attributes_for :seo
11
+ delegate *FIELDS, to: :seo
12
+ delegate *(FIELDS.map {|f| "#{f}=".to_sym }), to: :seo
16
13
 
17
- field :og_title, type: String, localize: RocketCMS.configuration.localize
18
- has_mongoid_attached_file :og_image, styles: {thumb: "800x600>"}
19
- elsif RocketCMS.active_record?
20
- has_attached_file :og_image, styles: {thumb: "800x600>"}
14
+ if RocketCMS.config.localize
15
+ delegate *(LOCALIZED_FIELDS.map {|f| "#{f}_translations".to_sym }), to: :seo
16
+ delegate *(LOCALIZED_FIELDS.map {|f| "#{f}_translations=".to_sym }), to: :seo
17
+ end
21
18
  end
22
- validates_attachment_content_type :og_image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :og_image?
23
- end
24
-
25
- def page_title
26
- title.blank? ? name : title
27
- end
28
-
29
- def get_og_title
30
- og_title.blank? ? name : og_title
31
- end
32
-
33
- def self.admin
34
- RocketCMS.seo_config
35
- end
36
-
37
- # deprecated
38
- def self.seo_config
39
- RocketCMS.seo_config
19
+ else
20
+ include RocketCMS::Models::Seo
40
21
  end
41
22
  end
42
23
 
@@ -0,0 +1,12 @@
1
+ if RocketCMS.active_record?
2
+ class Seo < ActiveRecord::Base
3
+ end
4
+ end
5
+
6
+ class Seo
7
+ include RocketCMS::Models::Seo
8
+ RocketCMS.apply_patches self
9
+ rails_admin &RocketCMS.seo_config
10
+ belongs_to :seoable, polymorphic: true
11
+ end
12
+
@@ -3,7 +3,7 @@
3
3
  - @news.each do |news|
4
4
  .rs-news-date= l(news.time.to_date)
5
5
  %a.rs-news-title{href: news_path(news)}= news.name
6
- - if !RocketCMS.configuration.news_image_styles.nil? && news.image?
6
+ - if !RocketCMS.config.news_image_styles.nil? && news.image?
7
7
  .rs-news-image= image_tag news.image.url(:thumb)
8
8
  .rs-news-excerpt= news.excerpt
9
9
  = paginate @news
@@ -2,7 +2,7 @@
2
2
  %h1.rs-news-title= @news.name
3
3
  .rs-news-date= l(@news.time.to_date)
4
4
  .rs-news-text= @news.excerpt
5
- - if !RocketCMS.configuration.news_image_styles.nil? && @news.image?
5
+ - if !RocketCMS.config.news_image_styles.nil? && @news.image?
6
6
  .rs-news-image= image_tag @news.image.url(:main)
7
7
  .rs-news-content
8
8
  = render 'shared/obj', obj: @news
@@ -9,7 +9,7 @@ module RocketCms
9
9
  desc 'RocketCMS migration generator'
10
10
  def install
11
11
  if RocketCMS.active_record?
12
- %w(contact_messages news pages).each do |table_name|
12
+ %w(contact_messages news pages seos).each do |table_name|
13
13
  migration_template "migration_#{table_name}.rb", "db/migrate/rocket_cms_create_#{table_name}.rb"
14
14
  end
15
15
  end
@@ -51,7 +51,11 @@ RailsAdmin.config do |config|
51
51
  end
52
52
 
53
53
  toggle
54
- toggle_menu
54
+ toggle_menu do
55
+ visible do
56
+ ['Page'].include? bindings[:abstract_model].model_name
57
+ end
58
+ end
55
59
  end
56
60
 
57
61
  config.main_app_name = ['<%= Rails.application.class.name.split('::')[0] %>', 'Админка']
@@ -3,14 +3,19 @@ class RocketCmsCreateNews < ActiveRecord::Migration
3
3
  create_table :news do |t|
4
4
  t.boolean :enabled, default: true, null: false
5
5
  t.timestamp :time, null: false
6
- t.string :name, null: false
7
- t.text :excerpt
8
- t.text :content
6
+
7
+ if RocketCMS.config.localize
8
+ t.column :name_translations, 'hstore'
9
+ t.column :excerpt_translations, 'hstore'
10
+ t.column :content_translations, 'hstore'
11
+ else
12
+ t.string :name, null: false
13
+ t.text :excerpt
14
+ t.text :content
15
+ end
9
16
 
10
17
  t.string :slug, null: false
11
18
  t.attachment :image
12
- RocketCMS::Migration.seo_fields(t)
13
-
14
19
  t.timestamps
15
20
  end
16
21
 
@@ -1,7 +1,12 @@
1
1
  class RocketCmsCreatePages < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :menus do |t|
4
- t.string :name, null: false
4
+
5
+ if RocketCMS.config.localize
6
+ t.column :name_translations, 'hstore'
7
+ else
8
+ t.string :name, null: false
9
+ end
5
10
  t.string :slug, null: false
6
11
  t.timestamps
7
12
  end
@@ -14,14 +19,18 @@ class RocketCmsCreatePages < ActiveRecord::Migration
14
19
  t.integer :rgt
15
20
  t.integer :depth
16
21
 
17
- t.string :slug, null: false
18
- t.attachment :image
22
+ if RocketCMS.config.localize
23
+ t.column :name_translations, 'hstore'
24
+ t.column :content_translations, 'hstore'
25
+ else
26
+ t.string :name, null: false
27
+ t.text :content
28
+ end
19
29
 
30
+ t.string :slug, null: false
20
31
  t.string :regexp
21
32
  t.string :redirect
22
- t.text :content
23
33
  t.string :fullpath, null: false
24
- RocketCMS::Migration.seo_fields(t)
25
34
  t.timestamps
26
35
  end
27
36
  add_index :pages, :slug, unique: true
@@ -0,0 +1,14 @@
1
+ class RocketCmsCreateSeos < ActiveRecord::Migration
2
+ def change
3
+ create_table :seos do |t|
4
+ t.boolean :enabled, default: true, null: false
5
+ t.integer :seoable_id
6
+ t.string :seoable_type
7
+ RocketCMS::Migration.seo_fields(t)
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :seos, [:seoable_id, :seoable_type], unique: true
12
+ end
13
+ end
14
+
@@ -52,12 +52,14 @@ module RocketCMS
52
52
  autoload :Migration, 'rocket_cms/migration'
53
53
 
54
54
  module Models
55
+ autoload :Seo, 'rocket_cms/models/seo'
55
56
  autoload :Menu, 'rocket_cms/models/menu'
56
57
  autoload :Page, 'rocket_cms/models/page'
57
58
  autoload :News, 'rocket_cms/models/news'
58
59
  autoload :ContactMessage, 'rocket_cms/models/contact_message'
59
60
 
60
61
  module Mongoid
62
+ autoload :Seo, 'rocket_cms/models/mongoid/seo'
61
63
  autoload :Menu, 'rocket_cms/models/mongoid/menu'
62
64
  autoload :Page, 'rocket_cms/models/mongoid/page'
63
65
  autoload :News, 'rocket_cms/models/mongoid/news'
@@ -65,6 +67,7 @@ module RocketCMS
65
67
  end
66
68
 
67
69
  module ActiveRecord
70
+ autoload :Seo, 'rocket_cms/models/active_record/seo'
68
71
  autoload :Menu, 'rocket_cms/models/active_record/menu'
69
72
  autoload :Page, 'rocket_cms/models/active_record/page'
70
73
  autoload :News, 'rocket_cms/models/active_record/news'
@@ -16,19 +16,27 @@ module RocketCMS
16
16
  }
17
17
  end
18
18
 
19
- def seo_config(is_active = false)
19
+ def seo_config(is_active = true)
20
20
  Proc.new {
21
- active is_active
22
- label "SEO"
21
+ if respond_to?(:active)
22
+ active is_active
23
+ label "SEO"
24
+ end
25
+ RocketCMS.seo_fields(self)
26
+ }
27
+ end
28
+
29
+ def seo_fields(s)
30
+ s.instance_eval do
23
31
  field :h1, :string
24
32
  field :title, :string
25
- field :keywords, :string
26
- field :description, :string
33
+ field :keywords, :text
34
+ field :description, :text
27
35
  field :robots, :string
28
36
 
29
37
  field :og_title, :string
30
- field :og_image
31
- }
38
+ field :og_image, :paperclip
39
+ end
32
40
  end
33
41
 
34
42
  def page_config
@@ -68,11 +76,20 @@ module RocketCMS
68
76
  read_only true
69
77
  end
70
78
  end
71
- group :seo, &RocketCMS.seo_config
79
+ if Seo.table_exists?
80
+ group :seo do
81
+ active true
82
+ field :seo do
83
+ active true
84
+ end
85
+ end
86
+ else
87
+ group :seo, &RocketCMS.seo_config(true)
88
+ end
72
89
  end
73
90
  RocketCMS.only_patches self, [:show, :export]
74
91
  nested_set({
75
- max_depth: RocketCMS.configuration.menu_max_depth
92
+ max_depth: RocketCMS.config.menu_max_depth
76
93
  })
77
94
  }
78
95
  end
@@ -110,7 +127,7 @@ module RocketCMS
110
127
  field :enabled, :toggle
111
128
  field :time
112
129
  field :name
113
- unless RocketCMS.configuration.news_image_styles.nil?
130
+ unless RocketCMS.config.news_image_styles.nil?
114
131
  field :image
115
132
  end
116
133
  field :excerpt
@@ -10,7 +10,7 @@ module RocketCMS
10
10
  def create
11
11
  @contact_message = model.new(message_params)
12
12
  after_initialize
13
- if RocketCMS.configuration.contacts_captcha
13
+ if RocketCMS.config.contacts_captcha
14
14
  meth = :save_with_captcha
15
15
  else
16
16
  meth = :save
@@ -58,7 +58,7 @@ module RocketCMS
58
58
  ContactMessage
59
59
  end
60
60
  def message_params
61
- params.require(:contact_message).permit(RocketCMS.configuration.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
61
+ params.require(:contact_message).permit(RocketCMS.config.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
62
62
  end
63
63
  end
64
64
  end
@@ -6,7 +6,7 @@ module RocketCMS
6
6
  def index
7
7
  @news = model.enabled.after_now.by_date
8
8
 
9
- unless RocketCMS.configuration.news_per_page.nil?
9
+ unless RocketCMS.config.news_per_page.nil?
10
10
  @news = @news.page(params[:page])
11
11
  end
12
12
  end
@@ -21,7 +21,7 @@ module RocketCMS
21
21
  }
22
22
  }},
23
23
  page: params[:page],
24
- per_page: RocketCMS.configuration.search_per_page,
24
+ per_page: RocketCMS.config.search_per_page,
25
25
  )
26
26
  end
27
27
  end
@@ -18,7 +18,7 @@ module RocketCMS
18
18
 
19
19
  config.after_initialize do
20
20
  # trigger autoload so models are registered in Mongoid::Elasticearch
21
- RocketCMS.configuration.search_models.map(&:constantize)
21
+ RocketCMS.config.search_models.map(&:constantize)
22
22
 
23
23
  # Write default email settings to DB so they can be changed.
24
24
  if Settings.table_exists?
@@ -3,19 +3,21 @@ module RocketCMS
3
3
  extend self
4
4
 
5
5
  def seo_fields(t)
6
- t.string :name, null: false
7
- t.string :h1
8
- t.string :title
9
- t.text :keywords
10
- t.text :description
6
+ if RocketCMS.config.localize
7
+ t.column :h1_translations, 'hstore'
8
+ t.column :title_translations, 'hstore'
9
+ t.column :keywords_translations, 'hstore'
10
+ t.column :description_translations, 'hstore'
11
+ t.column :og_title_translations, 'hstore'
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
+
@@ -6,6 +6,9 @@ module RocketCMS
6
6
  included do
7
7
  has_paper_trail
8
8
  validates_lengths_from_database
9
+ if RocketCMS.config.localize
10
+ translates :name
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -4,8 +4,8 @@ module RocketCMS
4
4
  module News
5
5
  extend ActiveSupport::Concern
6
6
  included do
7
- unless RocketCMS.configuration.news_image_styles.nil?
8
- has_attached_file :image, styles: RocketCMS.configuration.news_image_styles
7
+ unless RocketCMS.config.news_image_styles.nil?
8
+ has_attached_file :image, styles: RocketCMS.config.news_image_styles
9
9
  validates_attachment_content_type :image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :image?
10
10
  end
11
11
 
@@ -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
+
@@ -8,7 +8,7 @@ module RocketCMS
8
8
  included do
9
9
  apply_simple_captcha
10
10
  validates_email_format_of :email, unless: 'email.blank?'
11
- if RocketCMS.configuration.contacts_message_required
11
+ if RocketCMS.config.contacts_message_required
12
12
  validates_presence_of :content
13
13
  end
14
14
  validate do
@@ -8,7 +8,7 @@ module RocketCMS
8
8
  field :email, type: String
9
9
  field :phone, type: String
10
10
  field :content, type: String
11
- RocketCMS.configuration.contacts_fields.each_pair do |fn, ft|
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
@@ -3,19 +3,19 @@ module RocketCMS
3
3
  module Mongoid
4
4
  module News
5
5
  extend ActiveSupport::Concern
6
- unless RocketCMS.configuration.news_image_styles.nil?
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.configuration.news_image_styles.nil?
13
- has_mongoid_attached_file :image, styles: RocketCMS.configuration.news_image_styles
12
+ unless RocketCMS.config.news_image_styles.nil?
13
+ has_mongoid_attached_file :image, styles: RocketCMS.config.news_image_styles
14
14
  validates_attachment_content_type :image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :image?
15
15
  end
16
16
 
17
- field :excerpt, type: String, localize: RocketCMS.configuration.localize
18
- field :content, type: String, localize: RocketCMS.configuration.localize
17
+ field :excerpt, type: String, localize: RocketCMS.config.localize
18
+ field :content, type: String, localize: RocketCMS.config.localize
19
19
 
20
20
  scope :after_now, -> { where(:time.lt => Time.now) }
21
21
  scope :by_date, -> { desc(:time) }
@@ -6,7 +6,7 @@ module RocketCMS
6
6
  included do
7
7
  field :regexp, type: String
8
8
  field :redirect, type: String
9
- field :content, type: String, localize: RocketCMS.configuration.localize
9
+ field :content, type: String, localize: RocketCMS.config.localize
10
10
  field :fullpath, type: String
11
11
  has_and_belongs_to_many :menus, inverse_of: :pages
12
12
  acts_as_nested_set
@@ -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
+
@@ -8,7 +8,7 @@ module RocketCMS
8
8
  include RocketCMS.orm_specific('News')
9
9
  include ManualSlug
10
10
 
11
- if RocketCMS.configuration.search_enabled
11
+ if RocketCMS.config.search_enabled
12
12
  include RocketCMS::ElasticSearch
13
13
  end
14
14
 
@@ -18,10 +18,10 @@ module RocketCMS
18
18
  self.time = Time.now if self.time.blank?
19
19
  end
20
20
  scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
21
- unless RocketCMS.configuration.news_per_page.nil?
22
- paginates_per RocketCMS.configuration.news_per_page
21
+ unless RocketCMS.config.news_per_page.nil?
22
+ paginates_per RocketCMS.config.news_per_page
23
23
  end
24
- smart_excerpt :excerpt, :content, RocketCMS.configuration.news_excerpt
24
+ smart_excerpt :excerpt, :content, RocketCMS.config.news_excerpt
25
25
  manual_slug :report_slug
26
26
 
27
27
  RocketCMS.apply_patches self
@@ -9,7 +9,7 @@ module RocketCMS
9
9
 
10
10
  include RocketCMS.orm_specific('Page')
11
11
 
12
- if RocketCMS.configuration.search_enabled
12
+ if RocketCMS.config.search_enabled
13
13
  include RocketCMS::ElasticSearch
14
14
  end
15
15
 
@@ -0,0 +1,24 @@
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
+
9
+ included do
10
+ RocketCMS.apply_patches self
11
+ validates_attachment_content_type :og_image, content_type: %w(image/gif image/jpeg image/jpg image/png), if: :og_image?
12
+ end
13
+ end
14
+ end
15
+
16
+ def page_title
17
+ title.blank? ? name : title
18
+ end
19
+
20
+ def get_og_title
21
+ og_title.blank? ? name : og_title
22
+ end
23
+ end
24
+
@@ -1,3 +1,3 @@
1
1
  module RocketCMS
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0.pre.1"
3
3
  end
@@ -19,7 +19,7 @@ gem 'rails', '4.2.1'
19
19
 
20
20
  gem 'sass', '~> 3.4.4'
21
21
 
22
- #{if mongoid then "gem 'rocket_cms_mongoid'" else "gem 'rocket_cms_activerecord'" end}, '~> 0.7.0'
22
+ #{if mongoid then "gem 'rocket_cms_mongoid'" else "gem 'rocket_cms_activerecord'" end}, '~> 0.8.0.pre.1'
23
23
 
24
24
  gem 'sass-rails'
25
25
  gem 'compass-rails', '~> 2.0.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -384,6 +384,7 @@ files:
384
384
  - app/models/menu.rb
385
385
  - app/models/news.rb
386
386
  - app/models/page.rb
387
+ - app/models/seo.rb
387
388
  - app/views/blocks/_footer.html.haml
388
389
  - app/views/contact_mailer/new_message_email.html.haml
389
390
  - app/views/contacts/new.html.haml
@@ -434,6 +435,7 @@ files:
434
435
  - lib/generators/rocket_cms/templates/migration_contact_messages.rb
435
436
  - lib/generators/rocket_cms/templates/migration_news.rb
436
437
  - lib/generators/rocket_cms/templates/migration_pages.rb
438
+ - lib/generators/rocket_cms/templates/migration_seos.rb
437
439
  - lib/generators/rocket_cms/templates/production.erb
438
440
  - lib/generators/rocket_cms/templates/unicorn.erb
439
441
  - lib/generators/rocket_cms/utils.rb
@@ -457,14 +459,17 @@ files:
457
459
  - lib/rocket_cms/models/active_record/menu.rb
458
460
  - lib/rocket_cms/models/active_record/news.rb
459
461
  - lib/rocket_cms/models/active_record/page.rb
462
+ - lib/rocket_cms/models/active_record/seo.rb
460
463
  - lib/rocket_cms/models/contact_message.rb
461
464
  - lib/rocket_cms/models/menu.rb
462
465
  - lib/rocket_cms/models/mongoid/contact_message.rb
463
466
  - lib/rocket_cms/models/mongoid/menu.rb
464
467
  - lib/rocket_cms/models/mongoid/news.rb
465
468
  - lib/rocket_cms/models/mongoid/page.rb
469
+ - lib/rocket_cms/models/mongoid/seo.rb
466
470
  - lib/rocket_cms/models/news.rb
467
471
  - lib/rocket_cms/models/page.rb
472
+ - lib/rocket_cms/models/seo.rb
468
473
  - lib/rocket_cms/patch.rb
469
474
  - lib/rocket_cms/rails_admin_menu.rb
470
475
  - lib/rocket_cms/simple_form_patch.rb
@@ -488,9 +493,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
488
493
  version: '0'
489
494
  required_rubygems_version: !ruby/object:Gem::Requirement
490
495
  requirements:
491
- - - ">="
496
+ - - ">"
492
497
  - !ruby/object:Gem::Version
493
- version: '0'
498
+ version: 1.3.1
494
499
  requirements: []
495
500
  rubyforge_project:
496
501
  rubygems_version: 2.4.5