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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bde856fee99a7ce815e3452f2df4d3db50795fdc
4
- data.tar.gz: dded2bab36ed3115148be3ff23f77ed94bc96cdb
3
+ metadata.gz: 8f7d1a7472c0f8ae2fd40ccec849bc9d542ff192
4
+ data.tar.gz: 119638d504d7863bde727bc7b45aa20abf573fb4
5
5
  SHA512:
6
- metadata.gz: 879158b201d8da62949347753f70e88f998b16dbf6240202806068738527742da297a58085562e10dec6d462971f435fc3e81c52e6552b7f57486298aaf19b0d
7
- data.tar.gz: b6a0bc88d9b26853a62f961b8cb43ad2cd63ae332f12a087df95c3ab4abf7a67cdce071586b1881b7ad901adcb04239a0fef9cf902c845816e3d62cf03dfa96b
6
+ metadata.gz: cd843366f91cd871d485bb0a02feaf3bf76d64aa2b476d596ef9871ae9e82a575b894b88c109eda7ebf83ce3c2266853e2188b3f6c479fd94485d71da2d63624
7
+ data.tar.gz: ec6bbd89ec54e54ad37277f79dd5c4faa931d26d20ca66bd6443b842de208c6bbdd0db380f241a894dcbee175ee3e1b3fe8bbe5a1297c5e13fd9ce370394e12f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rocket_cms (0.8.0)
4
+ rocket_cms (0.8.1)
5
5
  addressable
6
6
  coffee-rails
7
7
  devise
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
@@ -1,3 +1,3 @@
1
1
  module RocketCMS
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
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.8.0
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