rocket_cms 0.27.4 → 0.27.5
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 +109 -9
- data/app/controllers/concerns/rs_localizeable.rb +11 -2
- data/lib/rocket_cms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e9dd9cc09cefc19411ab3acd4f132b604a0df4b0cdba7b75f24f6a067565fbc
|
4
|
+
data.tar.gz: 86c67eb7e480f165f10cd79ce8b357053d47f9d419e4171e8658fa1ff266753f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78102a32539492bbcb0cc50b95e274adaf37cd8678f5a2483d3e8213659b155dec8e177259fd4650563489dc0fc79e910cb7f059949c051f7c4ba8ffb072217
|
7
|
+
data.tar.gz: 38b0c4ac253499dd99ca3532d47616c176458765661cf2606c11b8e828fd398470534980eb7206b918f0d974cce6fe97c26e76fa0db2535530f872163c645ccd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -128,28 +128,128 @@ RocketCMS.configure do |rc|
|
|
128
128
|
end
|
129
129
|
```
|
130
130
|
|
131
|
-
Add ```
|
131
|
+
Add ```rails_admin_translate```:
|
132
132
|
|
133
133
|
```ruby
|
134
|
-
gem '
|
134
|
+
gem 'rails_admin_translate'
|
135
135
|
```
|
136
136
|
|
137
|
-
|
137
|
+
And, for ActiveRecord a translation gem you wish to use (mongoid should work with built-in localization):
|
138
138
|
|
139
139
|
```ruby
|
140
|
-
gem '
|
140
|
+
gem 'json_translate'
|
141
141
|
```
|
142
142
|
|
143
143
|
or
|
144
144
|
|
145
145
|
```ruby
|
146
|
-
gem '
|
146
|
+
gem 'globalize'
|
147
147
|
```
|
148
148
|
|
149
|
-
|
149
|
+
Create your models, or, if adding localization to existing app, migrate your locale data.
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
Example for globalize (needs adjustment):
|
152
|
+
|
153
|
+
```
|
154
|
+
class AddTranslations < ActiveRecord::Migration
|
155
|
+
def change
|
156
|
+
reversible do |dir|
|
157
|
+
dir.up do
|
158
|
+
I18n.with_locale(:ru) do
|
159
|
+
Page.create_translation_table!({
|
160
|
+
name: :string,
|
161
|
+
content: :text,
|
162
|
+
}, {
|
163
|
+
migrate_data: true,
|
164
|
+
#remove_source_columns: true,
|
165
|
+
})
|
166
|
+
|
167
|
+
News.create_translation_table!({
|
168
|
+
name: :string,
|
169
|
+
excerpt: :string,
|
170
|
+
content: :text,
|
171
|
+
}, {
|
172
|
+
migrate_data: true,
|
173
|
+
#remove_source_columns: true,
|
174
|
+
})
|
175
|
+
|
176
|
+
Seos.create_translation_table!({
|
177
|
+
h1: :string,
|
178
|
+
title: :string,
|
179
|
+
keywords: :text,
|
180
|
+
description: :text,
|
181
|
+
og_title: :string,
|
182
|
+
}, {
|
183
|
+
migrate_data: true,
|
184
|
+
#remove_source_columns: true,
|
185
|
+
})
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
dir.down do
|
190
|
+
I18n.with_locale(:ru) do
|
191
|
+
[Page, News, Menu, Seo].drop_translation_table!(migrate_data: true)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
Example for json_translate (needs adjustment):
|
198
|
+
|
199
|
+
```
|
200
|
+
class AddLocales < ActiveRecord::Migration[5.1]
|
201
|
+
def change
|
202
|
+
add_column :pages, :name_translations, :jsonb, default: {}
|
203
|
+
add_column :pages, :content_translations, :jsonb, default: {}
|
204
|
+
|
205
|
+
add_column :news, :name_translations, :jsonb, default: {}
|
206
|
+
add_column :news, :excerpt_translations, :jsonb, default: {}
|
207
|
+
add_column :news, :content_translations, :jsonb, default: {}
|
208
|
+
|
209
|
+
add_column :menus, :name_translations, :jsonb, default: {}
|
210
|
+
add_column :seos, :h1_translations, :jsonb, default: {}
|
211
|
+
add_column :seos, :title_translations, :jsonb, default: {}
|
212
|
+
add_column :seos, :keywords_translations, :jsonb, default: {}
|
213
|
+
add_column :seos, :description_translations, :jsonb, default: {}
|
214
|
+
add_column :seos, :og_title_translations, :jsonb, default: {}
|
215
|
+
|
216
|
+
reversible do |dir|
|
217
|
+
dir.up do
|
218
|
+
execute "UPDATE pages SET name_translations = json_build_object('ru', \"name\")"
|
219
|
+
execute "UPDATE pages SET content_translations = json_build_object('ru', \"content\")"
|
220
|
+
execute "UPDATE news SET name_translations = json_build_object('ru', \"name\")"
|
221
|
+
execute "UPDATE news SET content_translations = json_build_object('ru', \"content\")"
|
222
|
+
# etc
|
223
|
+
end
|
224
|
+
dir.down do
|
225
|
+
raise 'irreversible'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
```
|
231
|
+
### BACKUP YOUR DB
|
232
|
+
|
233
|
+
then drop old fields, or you will have errors with required fields being null
|
234
|
+
|
235
|
+
```
|
236
|
+
class DropLocale < ActiveRecord::Migration[5.2]
|
237
|
+
def change
|
238
|
+
remove_column :pages, :name
|
239
|
+
remove_column :pages, :content
|
240
|
+
|
241
|
+
remove_column :news, :name
|
242
|
+
remove_column :news, :excerpt
|
243
|
+
remove_column :news, :content
|
244
|
+
|
245
|
+
remove_column :menus, :name
|
246
|
+
remove_column :seos, :h1
|
247
|
+
remove_column :seos, :title
|
248
|
+
remove_column :seos, :keywords
|
249
|
+
remove_column :seos, :description
|
250
|
+
remove_column :seos, :og_title
|
251
|
+
end
|
252
|
+
end
|
153
253
|
```
|
154
254
|
|
155
255
|
### Capistrano generator
|
@@ -159,7 +259,7 @@ gem 'rails_admin_mongoid_localize_field'
|
|
159
259
|
|
160
260
|
designed to be used together with our ansible app setup script.
|
161
261
|
|
162
|
-
### Alternative capistrano task (can be used with non-configured app)
|
262
|
+
### Alternative capistrano task (can be used with non-configured app \ without db)
|
163
263
|
|
164
264
|
bundle exec rocket_cms_capify Games games.ru
|
165
265
|
|
@@ -7,17 +7,20 @@ module RsLocalizeable
|
|
7
7
|
Settings.ns_fallback = "main"
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
10
11
|
private
|
12
|
+
|
11
13
|
def default_url_options(options={})
|
12
14
|
{locale: params[:locale]}
|
13
15
|
end
|
16
|
+
|
14
17
|
def nav_get_menu_items(type)
|
15
18
|
pages = ::Menu.find(type.to_s).pages.enabled
|
16
19
|
if RocketCMS.mongoid?
|
17
20
|
pages = pages.where(:"name.#{I18n.locale}".exists => true)
|
18
21
|
elsif RocketCMS.active_record?
|
19
22
|
if defined?(JsonbTranslate)
|
20
|
-
|
23
|
+
|
21
24
|
pages = pages.where(["(name_translations -> ?)::text != ''", I18n.locale])
|
22
25
|
elsif defined?(HstoreTranslate)
|
23
26
|
pages = pages.where(["EXIST(name_translations, ?) = TRUE AND name_translations -> ? != ''", I18n.locale, I18n.locale])
|
@@ -25,11 +28,17 @@ module RsLocalizeable
|
|
25
28
|
end
|
26
29
|
pages.sorted.to_a
|
27
30
|
end
|
31
|
+
|
28
32
|
def nav_get_url(item)
|
29
33
|
(params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect)
|
30
34
|
end
|
35
|
+
|
31
36
|
def find_seo_extra(path)
|
32
|
-
|
37
|
+
r = path.gsub(/(\/ru|\/en)/, "")
|
38
|
+
if r.blank?
|
39
|
+
r = "/"
|
40
|
+
end
|
41
|
+
Page.enabled.where(fullpath: r).first
|
33
42
|
end
|
34
43
|
end
|
35
44
|
|
data/lib/rocket_cms/version.rb
CHANGED