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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e87e8f21b413352ec6dab08ad9aa538a87b59a29b6f0ecaf2e254a71f6c8664b
4
- data.tar.gz: 72256795815accfa41bf8acd813512c9d966b05a68411a2e31875b05e9a3bcfa
3
+ metadata.gz: 2e9dd9cc09cefc19411ab3acd4f132b604a0df4b0cdba7b75f24f6a067565fbc
4
+ data.tar.gz: 86c67eb7e480f165f10cd79ce8b357053d47f9d419e4171e8658fa1ff266753f
5
5
  SHA512:
6
- metadata.gz: c78abbd3f94574a8732c99b2d2368b587bd8f29a7a1ebe366f3386e6940a892644a0e3c195276d6cb1ccf0d3b6e98ad5be8231b806e4d63f35f798a4e1e4f1aa
7
- data.tar.gz: 510a93c15ef45b6efd83f746a7ed71dcb4560bee7a0d9c2ae097d9e9dd2e5c6eade76d7f9d27452ef8ad194001e9f702157c16989707b5e313d33b1f5ab2b7b3
6
+ metadata.gz: f78102a32539492bbcb0cc50b95e274adaf37cd8678f5a2483d3e8213659b155dec8e177259fd4650563489dc0fc79e910cb7f059949c051f7c4ba8ffb072217
7
+ data.tar.gz: 38b0c4ac253499dd99ca3532d47616c176458765661cf2606c11b8e828fd398470534980eb7206b918f0d974cce6fe97c26e76fa0db2535530f872163c645ccd
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rocket_cms (0.27.4)
4
+ rocket_cms (0.27.5)
5
5
  addressable
6
6
  coffee-rails
7
7
  jquery-rails
data/README.md CHANGED
@@ -128,28 +128,128 @@ RocketCMS.configure do |rc|
128
128
  end
129
129
  ```
130
130
 
131
- Add ```rails_admin_hstore_translate``` or ```hstore_translate``` gem if using PostgreSQL:
131
+ Add ```rails_admin_translate```:
132
132
 
133
133
  ```ruby
134
- gem 'rails_admin_hstore_translate'
134
+ gem 'rails_admin_translate'
135
135
  ```
136
136
 
137
- or
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 'hstore_translate'
140
+ gem 'json_translate'
141
141
  ```
142
142
 
143
143
  or
144
144
 
145
145
  ```ruby
146
- gem 'jsonb_translate' # requires postgresql 9.4
146
+ gem 'globalize'
147
147
  ```
148
148
 
149
- Add ```rails_admin_mongoid_localize_field``` gem if using MongoDB:
149
+ Create your models, or, if adding localization to existing app, migrate your locale data.
150
150
 
151
- ```ruby
152
- gem 'rails_admin_mongoid_localize_field'
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
- Page.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
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
 
@@ -1,3 +1,3 @@
1
1
  module RocketCMS
2
- VERSION = '0.27.4'
2
+ VERSION = '0.27.5'
3
3
  end
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.27.4
4
+ version: 0.27.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv