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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +45 -45
  3. data/README.md +64 -5
  4. data/app/assets/javascripts/{rocket_cms.js.coffee → rocket_cms.coffee} +0 -3
  5. data/app/controllers/concerns/rs_errors.rb +8 -4
  6. data/app/controllers/concerns/rs_localizeable.rb +26 -0
  7. data/app/controllers/concerns/rs_menu.rb +9 -2
  8. data/app/controllers/concerns/rs_pages.rb +14 -3
  9. data/app/helpers/gzip_helper.rb +27 -0
  10. data/app/models/concerns/seoable.rb +19 -30
  11. data/app/models/seo.rb +16 -0
  12. data/app/views/devise/registrations/edit.html.slim +21 -0
  13. data/app/views/devise/registrations/new.html.slim +21 -0
  14. data/app/views/devise/sessions/new.html.slim +18 -19
  15. data/app/views/devise/shared/_links.html.slim +4 -18
  16. data/app/views/news/show.html.slim +1 -1
  17. data/config/locales/en.rs.yml +1 -1
  18. data/config/locales/ru.rs.yml +11 -1
  19. data/lib/generators/rocket_cms/migration_generator.rb +1 -1
  20. data/lib/generators/rocket_cms/templates/admin.erb +8 -0
  21. data/lib/generators/rocket_cms/templates/migration_news.rb +10 -5
  22. data/lib/generators/rocket_cms/templates/migration_pages.rb +14 -5
  23. data/lib/generators/rocket_cms/templates/migration_seos.rb +14 -0
  24. data/lib/rocket_cms.rb +4 -0
  25. data/lib/rocket_cms/admin.rb +35 -8
  26. data/lib/rocket_cms/configuration.rb +7 -1
  27. data/lib/rocket_cms/controllers/contacts.rb +2 -2
  28. data/lib/rocket_cms/controllers/news.rb +1 -1
  29. data/lib/rocket_cms/controllers/search.rb +17 -0
  30. data/lib/rocket_cms/engine.rb +3 -3
  31. data/lib/rocket_cms/migration.rb +14 -11
  32. data/lib/rocket_cms/models/active_record/menu.rb +3 -0
  33. data/lib/rocket_cms/models/active_record/news.rb +6 -3
  34. data/lib/rocket_cms/models/active_record/page.rb +3 -0
  35. data/lib/rocket_cms/models/active_record/seo.rb +17 -0
  36. data/lib/rocket_cms/models/contact_message.rb +1 -1
  37. data/lib/rocket_cms/models/embedded_gallery_image.rb +4 -0
  38. data/lib/rocket_cms/models/gallery.rb +2 -0
  39. data/lib/rocket_cms/models/gallery_image.rb +2 -0
  40. data/lib/rocket_cms/models/mongoid/contact_message.rb +5 -5
  41. data/lib/rocket_cms/models/mongoid/embedded_gallery_image.rb +0 -1
  42. data/lib/rocket_cms/models/mongoid/gallery.rb +0 -1
  43. data/lib/rocket_cms/models/mongoid/gallery_image.rb +0 -1
  44. data/lib/rocket_cms/models/mongoid/news.rb +3 -4
  45. data/lib/rocket_cms/models/mongoid/page.rb +3 -2
  46. data/lib/rocket_cms/models/mongoid/seo.rb +23 -0
  47. data/lib/rocket_cms/models/news.rb +13 -5
  48. data/lib/rocket_cms/models/page.rb +7 -3
  49. data/lib/rocket_cms/models/seo.rb +17 -0
  50. data/lib/rocket_cms/seo_helpers.rb +13 -0
  51. data/lib/rocket_cms/version.rb +1 -1
  52. data/template.rb +4 -7
  53. metadata +13 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f562bee2585c443d8d86188edf4930f31dcc9d1e
4
- data.tar.gz: 29510850bf9dd6b7bd79bde2e653c37d9aeb6ed8
3
+ metadata.gz: 2b4be58e811a9fe7a30b6ae6c5dc4afcf8fb4224
4
+ data.tar.gz: 539440be1663279ea0e98d7698b1212fef5066e2
5
5
  SHA512:
6
- metadata.gz: 48a915514b32c086f6e77ee06d4b614bbe7ee2ad317efd7ddb691702263b26efbd06ed06cc75e6fb42cb9119e83263062c6486ff6048923f4f4961c64fe21811
7
- data.tar.gz: b4b15b2b11b2f39c611fa76d3447fcfa2cbf60740b017747b59504b8efaed1baf726b6036e15ec16b2154657afdd089a958230ff634e20757057e221fc732b59
6
+ metadata.gz: 5698b19ec72e2357d9d4a1eea81bc1c2e90fcb694e93495c3b866a37e9948d1537286fe934183e497882066e40dbed58ac1bc1f58855559d40d81d90595a845d
7
+ data.tar.gz: 0c8816d2f174cc7453a2401c132da4f8cd81c396d245c1d9ae54741aa260156ec1824bc7db8fe3b23c5da44fae0c5bd1298dd7a98f3576fd02330a00f2f3116d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ack_rocket_cms (0.7.7.1)
4
+ ack_rocket_cms (0.8.0)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -30,49 +30,49 @@ PATH
30
30
  GEM
31
31
  remote: https://rubygems.org/
32
32
  specs:
33
- ack_rails_admin_jcrop (0.0.5)
33
+ ack_rails_admin_jcrop (0.0.6)
34
34
  mini_magick
35
35
  rails (>= 3.0.0)
36
36
  rails_admin (>= 0.3.0)
37
- actionmailer (4.2.1)
38
- actionpack (= 4.2.1)
39
- actionview (= 4.2.1)
40
- activejob (= 4.2.1)
37
+ actionmailer (4.2.3)
38
+ actionpack (= 4.2.3)
39
+ actionview (= 4.2.3)
40
+ activejob (= 4.2.3)
41
41
  mail (~> 2.5, >= 2.5.4)
42
42
  rails-dom-testing (~> 1.0, >= 1.0.5)
43
- actionpack (4.2.1)
44
- actionview (= 4.2.1)
45
- activesupport (= 4.2.1)
43
+ actionpack (4.2.3)
44
+ actionview (= 4.2.3)
45
+ activesupport (= 4.2.3)
46
46
  rack (~> 1.6)
47
47
  rack-test (~> 0.6.2)
48
48
  rails-dom-testing (~> 1.0, >= 1.0.5)
49
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
50
- actionview (4.2.1)
51
- activesupport (= 4.2.1)
49
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
50
+ actionview (4.2.3)
51
+ activesupport (= 4.2.3)
52
52
  builder (~> 3.1)
53
53
  erubis (~> 2.7.0)
54
54
  rails-dom-testing (~> 1.0, >= 1.0.5)
55
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
56
- activejob (4.2.1)
57
- activesupport (= 4.2.1)
55
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
56
+ activejob (4.2.3)
57
+ activesupport (= 4.2.3)
58
58
  globalid (>= 0.3.0)
59
- activemodel (4.2.1)
60
- activesupport (= 4.2.1)
59
+ activemodel (4.2.3)
60
+ activesupport (= 4.2.3)
61
61
  builder (~> 3.1)
62
- activerecord (4.2.1)
63
- activemodel (= 4.2.1)
64
- activesupport (= 4.2.1)
62
+ activerecord (4.2.3)
63
+ activemodel (= 4.2.3)
64
+ activesupport (= 4.2.3)
65
65
  arel (~> 6.0)
66
- activesupport (4.2.1)
66
+ activesupport (4.2.3)
67
67
  i18n (~> 0.7)
68
68
  json (~> 1.7, >= 1.7.7)
69
69
  minitest (~> 5.1)
70
70
  thread_safe (~> 0.3, >= 0.3.4)
71
71
  tzinfo (~> 1.1)
72
72
  addressable (2.3.8)
73
- arel (6.0.0)
73
+ arel (6.0.2)
74
74
  bcrypt (3.1.10)
75
- bson (3.1.0)
75
+ bson (3.1.2)
76
76
  builder (3.2.2)
77
77
  ckeditor (4.1.2)
78
78
  cocaine
@@ -106,9 +106,9 @@ GEM
106
106
  activesupport (>= 4.1.0)
107
107
  haml (4.0.6)
108
108
  tilt
109
- htmlentities (4.3.3)
109
+ htmlentities (4.3.4)
110
110
  i18n (0.7.0)
111
- jquery-rails (4.0.3)
111
+ jquery-rails (4.0.4)
112
112
  rails-dom-testing (~> 1.0)
113
113
  railties (>= 4.2.0)
114
114
  thor (>= 0.14, < 2.0)
@@ -141,22 +141,22 @@ GEM
141
141
  optionable (0.2.0)
142
142
  origin (2.1.1)
143
143
  orm_adapter (0.5.0)
144
- rack (1.6.1)
144
+ rack (1.6.4)
145
145
  rack-pjax (0.8.0)
146
146
  nokogiri (~> 1.5)
147
147
  rack (~> 1.1)
148
148
  rack-test (0.6.3)
149
149
  rack (>= 1.0)
150
- rails (4.2.1)
151
- actionmailer (= 4.2.1)
152
- actionpack (= 4.2.1)
153
- actionview (= 4.2.1)
154
- activejob (= 4.2.1)
155
- activemodel (= 4.2.1)
156
- activerecord (= 4.2.1)
157
- activesupport (= 4.2.1)
150
+ rails (4.2.3)
151
+ actionmailer (= 4.2.3)
152
+ actionpack (= 4.2.3)
153
+ actionview (= 4.2.3)
154
+ activejob (= 4.2.3)
155
+ activemodel (= 4.2.3)
156
+ activerecord (= 4.2.3)
157
+ activesupport (= 4.2.3)
158
158
  bundler (>= 1.3.0, < 2.0)
159
- railties (= 4.2.1)
159
+ railties (= 4.2.3)
160
160
  sprockets-rails
161
161
  rails-deprecated_sanitizer (1.0.3)
162
162
  activesupport (>= 4.2.0.alpha)
@@ -185,14 +185,14 @@ GEM
185
185
  mongoid (>= 3.0)
186
186
  rails (>= 3.0)
187
187
  rails_admin (>= 0.5)
188
- rails_admin_nested_set (0.4.2)
189
- rails_admin (~> 0.6.6)
190
- rails_admin_settings (1.0.0)
191
- rails_admin_toggleable (0.5.0)
192
- rails_admin (~> 0.6.6)
193
- railties (4.2.1)
194
- actionpack (= 4.2.1)
195
- activesupport (= 4.2.1)
188
+ rails_admin_nested_set (0.4.4)
189
+ rails_admin
190
+ rails_admin_settings (1.0.1)
191
+ rails_admin_toggleable (0.5.1)
192
+ rails_admin
193
+ railties (4.2.3)
194
+ actionpack (= 4.2.3)
195
+ activesupport (= 4.2.3)
196
196
  rake (>= 0.8.7)
197
197
  thor (>= 0.18.1, < 2.0)
198
198
  rake (10.4.2)
@@ -200,7 +200,7 @@ GEM
200
200
  responders (2.1.0)
201
201
  railties (>= 4.2.0, < 5)
202
202
  safe_yaml (1.0.4)
203
- sass (3.4.14)
203
+ sass (3.4.16)
204
204
  sass-rails (5.0.3)
205
205
  railties (>= 4.0.0, < 5.0)
206
206
  sass (~> 3.1)
@@ -219,7 +219,7 @@ GEM
219
219
  htmlentities
220
220
  sprockets (3.2.0)
221
221
  rack (~> 1.0)
222
- sprockets-rails (2.3.1)
222
+ sprockets-rails (2.3.2)
223
223
  actionpack (>= 3.0)
224
224
  activesupport (>= 3.0)
225
225
  sprockets (>= 2.8, < 4.0)
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # RocketCMS
2
2
 
3
- rails_admin + mongoid/activerecord + elasticsearch CMS
3
+ Rails + RailsAdmin + Mongoid/PostgreSQL + Elasticsearch CMS
4
4
 
5
5
  Very opinionated and tuned for my needs.
6
6
 
7
- Sorry, no documentation or examples are availiable yet. Stay tuned
8
-
9
- **Before 1.0 API and class names should be considered unstable and can change at
10
- any time!**
7
+ **Before 1.0 API and class names should be considered unstable and can change at any time!**
11
8
 
12
9
  ## Installation
13
10
 
@@ -58,6 +55,68 @@ for ActiveRecord:
58
55
 
59
56
  generator creates a new RVM gemset, so after cd'ing to app dir, you should run `bundle install` again if you use rvm.
60
57
 
58
+ ### Localization
59
+
60
+ All models included in the gem support localization via either [hstore_translate](https://github.com/Leadformance/hstore_translate) or built-in Mongoid localize: true option.
61
+
62
+ You can get a nice admin UI for editing locales by adding [rails_admin_hstore_translate](https://github.com/glebtv/rails_admin_hstore_translate) or [rails_admin_mongoid_localize_field](https://github.com/sudosu/rails_admin_mongoid_localize_field)
63
+
64
+ Add to: ```app/models/page.rb```
65
+
66
+ ```ruby
67
+ class Page < ActiveRecord::Base
68
+ include RocketCMS::Models::Page
69
+ RocketCMS.apply_patches self
70
+ rails_admin &RocketCMS.page_config
71
+
72
+ def regexp_prefix
73
+ "(?:\/ru|\/en)?"
74
+ end
75
+ end
76
+ ```
77
+
78
+ Wrap your routes with locale scope:
79
+
80
+ ```ruby
81
+ scope "(:locale)", locale: /en|ru/ do
82
+ get 'contacts' => 'contacts#new', as: :contacts
83
+ post 'contacts' => 'contacts#create', as: :create_contacts
84
+ end
85
+ ```
86
+
87
+ Add to application_controller.rb:
88
+
89
+ ```ruby
90
+ class ApplicationController < ActionController::Base
91
+ include RocketCMS::Controller
92
+ include RsLocalizeable
93
+ end
94
+ ```
95
+
96
+ Enable localization in RocketCMS:
97
+
98
+ ```ruby
99
+ RocketCMS.configure do |rc|
100
+ rc.news_image_styles = {small: '107x126#'}
101
+ rc.contacts_captcha = true
102
+ rc.contacts_message_required = true
103
+ ...
104
+ rc.localize = true
105
+ end
106
+ ```
107
+
108
+ Add ```rails_admin_hstore_translate``` or ```hstore_translate``` gem if using PostgreSQL:
109
+
110
+ ```ruby
111
+ gem 'rails_admin_hstore_translate'
112
+ ```
113
+
114
+ or
115
+
116
+ ```ruby
117
+ gem 'hstore_translate'
118
+ ```
119
+
61
120
  ### Documentation
62
121
 
63
122
  It's basically Mongoid + Rails Admin + some of my common models and controllers, capistrano config (from root repo), etc.
@@ -4,7 +4,4 @@
4
4
  #= require head.load.js
5
5
  #= require rocket_cms/map
6
6
  #= require rocket_cms/flash
7
- #= require jquery.placeholder.js
8
7
 
9
- $(document).on 'page:change', ->
10
- $('input, textarea').placeholder()
@@ -43,7 +43,7 @@ module RsErrors
43
43
  end
44
44
  end
45
45
 
46
- protected
46
+ private
47
47
  def render_404(exception = nil)
48
48
  Rails.logger.error "__________________________"
49
49
  Rails.logger.error "Error 404"
@@ -71,16 +71,20 @@ module RsErrors
71
71
  Rails.logger.error "__________________________"
72
72
  begin
73
73
  if rails_admin?
74
- render text: t('rs.errors.internal_error'), status: 500
74
+ render text: t('rs.errors.internal_error', klass: exception.class.name, message: exception.message), status: 500
75
75
  return
76
76
  end
77
- rescue
77
+ rescue Exception => e
78
+ puts "error while rendering rails admin exception"
79
+ puts e.class.name
80
+ puts e.message
81
+ puts e.backtrace.join("\n")
78
82
  end
79
83
  render_error(500)
80
84
  end
81
85
 
82
86
  def render_error(code = 500)
83
- render template: "errors/error_#{code}", formats: [:html], handlers: [:haml, :slim], layout: RocketCMS.configuration.error_layout, status: code
87
+ render template: "errors/error_#{code}", formats: [:html], handlers: [:haml, :slim], layout: RocketCMS.config.error_layout, status: code
84
88
  end
85
89
 
86
90
  def rails_admin?
@@ -0,0 +1,26 @@
1
+ module RsLocalizeable
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ before_filter do
5
+ I18n.locale = params[:locale] || I18n.default_locale
6
+ Settings.ns_default = "main_#{I18n.locale}"
7
+ Settings.ns_fallback = "main"
8
+ end
9
+ end
10
+ private
11
+ def default_url_options(options={})
12
+ {locale: params[:locale]}
13
+ end
14
+ def nav_get_menu_items(type)
15
+ pages = ::Menu.find(type.to_s).pages.enabled
16
+ pages = pages.where(["EXIST(name_translations, ?) = TRUE AND name_translations -> ? != ''", I18n.locale, I18n.locale])
17
+ pages.sorted.to_a
18
+ end
19
+ def nav_get_url(item)
20
+ (params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect)
21
+ end
22
+ def find_seo_extra(path)
23
+ Page.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
24
+ end
25
+ end
26
+
@@ -4,6 +4,7 @@ module RsMenu
4
4
  helper_method :navigation
5
5
  end
6
6
 
7
+ private
7
8
  def render_with_subs(items, primary, item)
8
9
  subs = items.select { |i| i.parent_id == item.id && !i.name.blank? && i.enabled }
9
10
  if subs.empty?
@@ -18,7 +19,7 @@ module RsMenu
18
19
  end
19
20
 
20
21
  def navigation_item(primary, item, block=nil)
21
- url = item.redirect.blank? ? item.fullpath : item.redirect
22
+ url = nav_get_url(item)
22
23
  if block.nil?
23
24
  primary.item(item.slug, item.name, url, item.nav_options)
24
25
  else
@@ -31,7 +32,7 @@ module RsMenu
31
32
  SimpleNavigation.config.autogenerate_item_ids = false
32
33
  begin
33
34
  nav_extra_data_before(type, primary)
34
- items = ::Menu.find(type.to_s).pages.enabled.sorted.to_a
35
+ items = nav_get_menu_items(type)
35
36
  items.select { |i| i.parent_id.nil? && !i.name.blank? && i.enabled }.each do |item|
36
37
  render_with_subs(items, primary, item) if primary
37
38
  end
@@ -45,6 +46,12 @@ module RsMenu
45
46
  end
46
47
  end
47
48
 
49
+ def nav_get_url(item)
50
+ item.redirect.blank? ? item.fullpath : item.redirect
51
+ end
52
+ def nav_get_menu_items(type)
53
+ ::Menu.find(type.to_s).pages.enabled.sorted.to_a
54
+ end
48
55
  def nav_extra_data_before(type, primary)
49
56
  # override for additional config or items
50
57
  end
@@ -5,7 +5,6 @@ module RsPages
5
5
  end
6
6
 
7
7
  private
8
-
9
8
  def find_page
10
9
  return if rails_admin?
11
10
  @seo_page = find_seo_page request.path
@@ -23,8 +22,16 @@ module RsPages
23
22
  path = path[0..-2]
24
23
  do_redirect = true
25
24
  end
26
-
27
25
  page = Page.enabled.where(fullpath: path).first
26
+
27
+ if page.nil? && !params[:slug].blank?
28
+ page = Page.enabled.where(fullpath: "/" + params[:slug]).first
29
+ end
30
+
31
+ if page.nil?
32
+ page = find_seo_extra(path)
33
+ end
34
+
28
35
  if page.nil?
29
36
  do_redirect = true
30
37
  spath = path.chomp(File.extname(path))
@@ -32,6 +39,7 @@ module RsPages
32
39
  page = Page.enabled.where(fullpath: spath).first
33
40
  end
34
41
  end
42
+
35
43
  if !page.nil? && do_redirect
36
44
  redirect_to path, status: :moved_permanently
37
45
  end
@@ -39,7 +47,6 @@ module RsPages
39
47
  page
40
48
  end
41
49
 
42
-
43
50
  def find_seo_page_with_redirect(path)
44
51
  do_redirect = false
45
52
  if path[0] != '/'
@@ -65,6 +72,10 @@ module RsPages
65
72
  page
66
73
 
67
74
  end
75
+
76
+ def find_seo_extra(path)
77
+ nil
78
+ end
68
79
 
69
80
  def rails_admin?
70
81
  self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
@@ -0,0 +1,27 @@
1
+ module GzipHelper
2
+ def gzip_javascript_include_tag(*sources)
3
+ # Grab the asset html include tag
4
+ tag = javascript_include_tag *sources
5
+
6
+ # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
7
+ if Rails.env.production? && request.accept_encoding =~ /gzip/i
8
+ tag = tag.gsub(/\.js/i, ".js.gz")
9
+ end
10
+
11
+ # Return the asset whether or not it was modified
12
+ tag.html_safe
13
+ end
14
+
15
+ def gzip_stylesheet_link_tag(*sources)
16
+ # Grab the asset html include tag
17
+ tag = stylesheet_link_tag *sources
18
+
19
+ # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
20
+ if Rails.env.production? && request.accept_encoding =~ /gzip/i
21
+ tag = tag.gsub(/\.css/i, ".css.gz")
22
+ end
23
+
24
+ # Return the asset whether or not it was modified
25
+ tag.html_safe
26
+ end
27
+ end