rocket_cms 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +44 -0
- data/app/controllers/concerns/rs_localizeable.rb +24 -0
- data/app/controllers/concerns/rs_pages.rb +8 -1
- data/lib/rocket_cms/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7d1a7472c0f8ae2fd40ccec849bc9d542ff192
|
4
|
+
data.tar.gz: 119638d504d7863bde727bc7b45aa20abf573fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd843366f91cd871d485bb0a02feaf3bf76d64aa2b476d596ef9871ae9e82a575b894b88c109eda7ebf83ce3c2266853e2188b3f6c479fd94485d71da2d63624
|
7
|
+
data.tar.gz: ec6bbd89ec54e54ad37277f79dd5c4faa931d26d20ca66bd6443b842de208c6bbdd0db380f241a894dcbee175ee3e1b3fe8bbe5a1297c5e13fd9ce370394e12f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -64,6 +64,50 @@ All models included in the gem support localization via either hstore_translate
|
|
64
64
|
|
65
65
|
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)
|
66
66
|
|
67
|
+
Add to: ```app/models/page.rb```
|
68
|
+
|
69
|
+
```
|
70
|
+
class Page < ActiveRecord::Base
|
71
|
+
include RocketCMS::Models::Page
|
72
|
+
RocketCMS.apply_patches self
|
73
|
+
rails_admin &RocketCMS.page_config
|
74
|
+
|
75
|
+
def regexp_prefix
|
76
|
+
"(?:\/ru|\/en)?"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
Wrap your routes with locale scope:
|
82
|
+
|
83
|
+
```
|
84
|
+
scope "(:locale)", locale: /en|ru/ do
|
85
|
+
get 'contacts' => 'contacts#new', as: :contacts
|
86
|
+
post 'contacts' => 'contacts#create', as: :create_contacts
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
Add to application_controller.rb:
|
91
|
+
|
92
|
+
```
|
93
|
+
class ApplicationController < ActionController::Base
|
94
|
+
include RocketCMS::Controller
|
95
|
+
include RsLocalizeable
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
Enable localization in RocketCMS:
|
100
|
+
|
101
|
+
```
|
102
|
+
RocketCMS.configure do |rc|
|
103
|
+
rc.news_image_styles = {small: '107x126#'}
|
104
|
+
rc.contacts_captcha = true
|
105
|
+
rc.contacts_message_required = true
|
106
|
+
...
|
107
|
+
rc.localize = true
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
67
111
|
### Documentation
|
68
112
|
|
69
113
|
It's basically Mongoid + Rails Admin + some of our common models and controllers, capistrano config, etc.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RsLocalizeable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
before_filter do
|
5
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
6
|
+
end
|
7
|
+
end
|
8
|
+
private
|
9
|
+
def default_url_options(options={})
|
10
|
+
{locale: params[:locale]}
|
11
|
+
end
|
12
|
+
def nav_get_menu_items(type)
|
13
|
+
pages = ::Menu.find(type.to_s).pages.enabled
|
14
|
+
pages = pages.where(["EXIST(name_translations, ?) = TRUE AND name_translations -> ? != ''", I18n.locale, I18n.locale])
|
15
|
+
pages.sorted.to_a
|
16
|
+
end
|
17
|
+
def nav_get_url(item)
|
18
|
+
(params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect)
|
19
|
+
end
|
20
|
+
def find_seo_extra(path)
|
21
|
+
Page.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -28,6 +28,10 @@ module RsPages
|
|
28
28
|
page = Page.enabled.where(fullpath: "/" + params[:slug]).first
|
29
29
|
end
|
30
30
|
|
31
|
+
if page.nil?
|
32
|
+
page = find_seo_extra(path)
|
33
|
+
end
|
34
|
+
|
31
35
|
if page.nil?
|
32
36
|
do_redirect = true
|
33
37
|
spath = path.chomp(File.extname(path))
|
@@ -42,7 +46,10 @@ module RsPages
|
|
42
46
|
|
43
47
|
page
|
44
48
|
end
|
45
|
-
|
49
|
+
|
50
|
+
def find_seo_extra(path)
|
51
|
+
nil
|
52
|
+
end
|
46
53
|
def rails_admin?
|
47
54
|
self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
|
48
55
|
end
|
data/lib/rocket_cms/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocket_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
@@ -365,6 +365,7 @@ files:
|
|
365
365
|
- app/assets/stylesheets/rocket_cms/normalize.css.scss
|
366
366
|
- app/controllers/concerns/no_cache.rb
|
367
367
|
- app/controllers/concerns/rs_errors.rb
|
368
|
+
- app/controllers/concerns/rs_localizeable.rb
|
368
369
|
- app/controllers/concerns/rs_menu.rb
|
369
370
|
- app/controllers/concerns/rs_pages.rb
|
370
371
|
- app/controllers/contacts_controller.rb
|