alchemy_cms 3.2.0.beta → 3.2.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +661 -863
- data/README.md +5 -63
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +11 -10
- data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +6 -0
- data/app/assets/stylesheets/alchemy/_extends.scss +0 -6
- data/app/assets/stylesheets/alchemy/_mixins.scss +6 -0
- data/app/assets/stylesheets/alchemy/buttons.scss +1 -1
- data/app/assets/stylesheets/alchemy/elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/menubar.scss +1 -1
- data/app/assets/stylesheets/alchemy/selects.scss +5 -1
- data/app/assets/stylesheets/alchemy/upload.scss +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +4 -57
- data/app/controllers/alchemy/messages_controller.rb +2 -2
- data/app/controllers/alchemy/pages_controller.rb +22 -31
- data/app/controllers/alchemy/pictures_controller.rb +2 -2
- data/app/helpers/alchemy/admin/base_helper.rb +7 -0
- data/app/helpers/alchemy/admin/elements_helper.rb +31 -15
- data/app/helpers/alchemy/admin/pages_helper.rb +17 -0
- data/app/helpers/alchemy/base_helper.rb +0 -28
- data/app/helpers/alchemy/pages_helper.rb +18 -12
- data/app/helpers/alchemy/url_helper.rb +2 -2
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content/factory.rb +12 -6
- data/app/models/alchemy/element.rb +3 -3
- data/app/models/alchemy/element/definitions.rb +1 -1
- data/app/models/alchemy/element_to_page.rb +7 -0
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/page.rb +8 -1
- data/app/models/alchemy/page/page_cells.rb +2 -2
- data/app/models/alchemy/page/page_elements.rb +23 -5
- data/app/models/alchemy/page/page_natures.rb +3 -3
- data/app/models/alchemy/page/page_scopes.rb +1 -1
- data/app/models/alchemy/picture.rb +1 -1
- data/app/views/alchemy/admin/pages/_create_language_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_form.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
- data/app/views/alchemy/breadcrumb/_page.html.erb +3 -2
- data/app/views/alchemy/breadcrumb/_separator.html.erb +1 -0
- data/app/views/alchemy/breadcrumb/_wrapper.html.erb +13 -0
- data/app/views/alchemy/language_links/_language.html.erb +1 -1
- data/app/views/alchemy/navigation/_link.html.erb +1 -1
- data/app/views/alchemy/pages/show.rss.builder +5 -7
- data/app/views/layouts/alchemy/admin.html.erb +5 -0
- data/config/routes.rb +13 -10
- data/lib/alchemy/configuration_methods.rb +29 -0
- data/lib/alchemy/controller_actions.rb +12 -4
- data/lib/alchemy/engine.rb +3 -0
- data/lib/alchemy/errors.rb +1 -1
- data/lib/alchemy/essence.rb +14 -12
- data/lib/alchemy/on_page_layout.rb +58 -0
- data/lib/alchemy/page_layout.rb +1 -1
- data/lib/alchemy/permissions.rb +21 -16
- data/lib/alchemy/routing_constraints.rb +49 -0
- data/lib/alchemy/seeder.rb +4 -2
- data/lib/alchemy/ssl_protection.rb +30 -0
- data/lib/alchemy/test_support/essence_shared_examples.rb +118 -25
- data/lib/alchemy/test_support/factories.rb +5 -8
- data/lib/alchemy/test_support/integration_helpers.rb +16 -10
- data/lib/alchemy/upgrader/three_point_two.rb +34 -4
- data/lib/alchemy/version.rb +1 -1
- data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_editor.html.erb +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_view.html.erb +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/_standard.html.erb +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.de.yml +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.elements.css.scss +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.en.yml +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.es.yml +0 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/files/application.html.erb +0 -0
- data/lib/rails/generators/alchemy/install/install_generator.rb +69 -0
- data/lib/rails/generators/alchemy/{scaffold/files/elements.yml → install/templates/elements.yml.tt} +2 -0
- data/lib/rails/generators/alchemy/{scaffold → install}/templates/page_layouts.yml.tt +2 -0
- data/lib/rails/generators/alchemy/views/views_generator.rb +41 -0
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +0 -5
- data/lib/tasks/alchemy/install.rake +10 -5
- data/lib/tasks/alchemy/tidy.rake +2 -0
- data/spec/controllers/admin/attachments_controller_spec.rb +1 -1
- data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
- data/spec/controllers/admin/contents_controller_spec.rb +1 -1
- data/spec/controllers/admin/dashboard_controller_spec.rb +2 -2
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_files_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +1 -1
- data/spec/controllers/admin/languages_controller_spec.rb +1 -1
- data/spec/controllers/admin/layoutpages_controller_spec.rb +1 -1
- data/spec/controllers/admin/pages_controller_spec.rb +4 -4
- data/spec/controllers/admin/pictures_controller_spec.rb +1 -1
- data/spec/controllers/admin/resources_controller_spec.rb +1 -1
- data/spec/controllers/admin/trash_controller_spec.rb +1 -1
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +1 -1
- data/spec/controllers/attachments_controller_spec.rb +1 -1
- data/spec/controllers/base_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +15 -16
- data/spec/controllers/pictures_controller_spec.rb +212 -162
- data/spec/dummy/app/controllers/login_controller.rb +5 -0
- data/spec/dummy/app/models/dummy_model.rb +3 -0
- data/spec/dummy/config/alchemy/cells.yml +4 -1
- data/spec/dummy/config/alchemy/elements.yml +8 -0
- data/spec/dummy/config/alchemy/page_layouts.yml +5 -1
- data/spec/dummy/config/routes.rb +1 -2
- data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +7 -0
- data/spec/dummy/db/schema.rb +30 -26
- data/spec/features/admin/dashboard_spec.rb +11 -9
- data/spec/features/admin/language_tree_feature_spec.rb +5 -6
- data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
- data/spec/features/admin/link_overlay_spec.rb +1 -1
- data/spec/features/admin/locale_select_feature_spec.rb +1 -1
- data/spec/features/admin/modules_integration_spec.rb +1 -1
- data/spec/features/admin/navigation_feature_spec.rb +1 -1
- data/spec/features/admin/page_creation_feature_spec.rb +1 -1
- data/spec/features/admin/page_editing_feature_spec.rb +3 -3
- data/spec/features/admin/picture_library_integration_spec.rb +1 -1
- data/spec/features/admin/resources_integration_spec.rb +1 -1
- data/spec/features/admin/site_select_feature_spec.rb +32 -0
- data/spec/features/admin/tinymce_feature_spec.rb +1 -3
- data/spec/features/page_feature_spec.rb +36 -27
- data/spec/features/security_spec.rb +1 -1
- data/spec/features/translation_integration_spec.rb +3 -3
- data/spec/helpers/admin/elements_helper_spec.rb +103 -26
- data/spec/helpers/admin/pages_helper_spec.rb +32 -1
- data/spec/helpers/base_helper_spec.rb +0 -45
- data/spec/helpers/pages_helper_spec.rb +18 -17
- data/spec/helpers/url_helper_spec.rb +8 -5
- data/spec/libraries/controller_actions_spec.rb +2 -2
- data/spec/libraries/on_page_layout_spec.rb +112 -0
- data/spec/libraries/page_layout_spec.rb +5 -1
- data/spec/libraries/permissions_spec.rb +13 -15
- data/spec/models/cell_spec.rb +4 -0
- data/spec/models/content_spec.rb +6 -0
- data/spec/models/dummy_model_spec.rb +11 -0
- data/spec/models/element_spec.rb +6 -1
- data/spec/models/element_to_page_spec.rb +14 -0
- data/spec/models/page_spec.rb +111 -19
- data/spec/routing/routing_spec.rb +120 -101
- data/spec/spec_helper.rb +3 -3
- metadata +36 -21
- data/app/views/alchemy/breadcrumb/_spacer.html.erb +0 -1
- data/lib/alchemy/capistrano.rb +0 -230
- data/lib/alchemy/test_support/auth_helpers.rb +0 -35
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +0 -90
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +0 -113
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -63
- data/spec/dummy/app/controllers/errors_controller.rb +0 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Alchemy
|
|
2
|
+
|
|
3
|
+
# Routing constraints for Alchemy's strong catch all route.
|
|
4
|
+
#
|
|
5
|
+
# Alchemy has a very strong catch all route.
|
|
6
|
+
# But we don't want to handle all requests.
|
|
7
|
+
#
|
|
8
|
+
# For instance we only want to handle html requests and
|
|
9
|
+
# don't want to swallow the rails/info routes in development mode.
|
|
10
|
+
#
|
|
11
|
+
class RoutingConstraints
|
|
12
|
+
LOCALE_REGEXP = /[a-z]{2}(-[a-z]{2})?/
|
|
13
|
+
|
|
14
|
+
def matches?(request)
|
|
15
|
+
@request = request
|
|
16
|
+
@params = @request.params
|
|
17
|
+
|
|
18
|
+
handable_format? && no_rails_route?
|
|
19
|
+
rescue ArgumentError => e
|
|
20
|
+
handle_invalid_byte_sequence(e)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# We only want html requests to be handled by us.
|
|
26
|
+
#
|
|
27
|
+
# If an unknown format is requested we want to handle this,
|
|
28
|
+
# because it could be a legacy route that needs to be redirected.
|
|
29
|
+
#
|
|
30
|
+
def handable_format?
|
|
31
|
+
@request.format.symbol.nil? || (@request.format.symbol == :html)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# We don't want to handle the Rails info routes.
|
|
35
|
+
def no_rails_route?
|
|
36
|
+
return true if !%w(development test).include?(Rails.env)
|
|
37
|
+
(@params['urlname'] =~ /\Arails\//).nil?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Handle invalid byte sequence in UTF-8 errors with 400 status.
|
|
41
|
+
def handle_invalid_byte_sequence(e)
|
|
42
|
+
if e.message =~ /invalid byte sequence/
|
|
43
|
+
raise ActionController::BadRequest
|
|
44
|
+
else
|
|
45
|
+
raise
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/alchemy/seeder.rb
CHANGED
|
@@ -6,8 +6,10 @@ module Alchemy
|
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
8
|
|
|
9
|
-
# This seed builds the necessary page structure for
|
|
10
|
-
#
|
|
9
|
+
# This seed builds the necessary page structure for Alchemy in your database.
|
|
10
|
+
#
|
|
11
|
+
# Call this from your db/seeds.rb file with the rake db:seed task.
|
|
12
|
+
#
|
|
11
13
|
def seed!
|
|
12
14
|
create_default_site
|
|
13
15
|
create_root_page
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Alchemy
|
|
2
|
+
module SSLProtection
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
# Enforce ssl for login and all admin modules.
|
|
6
|
+
#
|
|
7
|
+
# Default is +false+
|
|
8
|
+
#
|
|
9
|
+
# === Usage
|
|
10
|
+
#
|
|
11
|
+
# # config/alchemy/config.yml
|
|
12
|
+
# ...
|
|
13
|
+
# require_ssl: true
|
|
14
|
+
# ...
|
|
15
|
+
#
|
|
16
|
+
# === Note
|
|
17
|
+
#
|
|
18
|
+
# You have to create a ssl certificate
|
|
19
|
+
# if you want to use the ssl protection.
|
|
20
|
+
#
|
|
21
|
+
def ssl_required?
|
|
22
|
+
!Rails.env.test? && Config.get(:require_ssl)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Redirects current request to https.
|
|
26
|
+
def enforce_ssl
|
|
27
|
+
redirect_to url_for(request.params.merge(protocol: 'https'))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -84,27 +84,67 @@ shared_examples_for "an essence" do
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
describe 'presence' do
|
|
87
|
-
|
|
88
|
-
allow(essence).to receive(:description).and_return({'validate' => ['presence']})
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context 'when the ingredient column is empty' do
|
|
87
|
+
context 'with string given as validation type' do
|
|
92
88
|
before do
|
|
93
|
-
essence.
|
|
89
|
+
allow(essence).to receive(:description).and_return({'validate' => ['presence']})
|
|
94
90
|
end
|
|
95
91
|
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
context 'when the ingredient column is empty' do
|
|
93
|
+
before do
|
|
94
|
+
essence.update(essence.ingredient_column.to_sym => nil)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should not be valid' do
|
|
98
|
+
expect(essence).to_not be_valid
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
context 'when the ingredient column is not nil' do
|
|
103
|
+
before do
|
|
104
|
+
essence.update(essence.ingredient_column.to_sym => ingredient_value)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'should be valid' do
|
|
108
|
+
expect(essence).to be_valid
|
|
109
|
+
end
|
|
98
110
|
end
|
|
99
111
|
end
|
|
100
112
|
|
|
101
|
-
context '
|
|
102
|
-
|
|
103
|
-
|
|
113
|
+
context 'with hash given as validation type' do
|
|
114
|
+
context 'where the value is true' do
|
|
115
|
+
before do
|
|
116
|
+
allow(essence).to receive(:description).and_return({'validate' => [{'presence' => true}]})
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context 'when the ingredient column is empty' do
|
|
120
|
+
before do
|
|
121
|
+
essence.update(essence.ingredient_column.to_sym => nil)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should not be valid' do
|
|
125
|
+
expect(essence).to_not be_valid
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context 'when the ingredient column is not nil' do
|
|
130
|
+
before do
|
|
131
|
+
essence.update(essence.ingredient_column.to_sym => ingredient_value)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'should be valid' do
|
|
135
|
+
expect(essence).to be_valid
|
|
136
|
+
end
|
|
137
|
+
end
|
|
104
138
|
end
|
|
105
139
|
|
|
106
|
-
|
|
107
|
-
|
|
140
|
+
context 'where the value is false' do
|
|
141
|
+
before do
|
|
142
|
+
allow(essence).to receive(:description).and_return({'validate' => [{'presence' => false}]})
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'should be valid' do
|
|
146
|
+
expect(essence).to be_valid
|
|
147
|
+
end
|
|
108
148
|
end
|
|
109
149
|
end
|
|
110
150
|
end
|
|
@@ -112,22 +152,37 @@ shared_examples_for "an essence" do
|
|
|
112
152
|
describe 'uniqueness' do
|
|
113
153
|
before do
|
|
114
154
|
allow(essence).to receive(:element).and_return(build_stubbed(:element))
|
|
115
|
-
expect(essence).to receive(:description).at_least(:once).and_return({'validate' => ['uniqueness']})
|
|
116
155
|
essence.update(essence.ingredient_column.to_sym => ingredient_value)
|
|
117
156
|
end
|
|
118
157
|
|
|
119
|
-
context '
|
|
158
|
+
context 'with string given as validation type' do
|
|
120
159
|
before do
|
|
121
|
-
|
|
160
|
+
expect(essence).to receive(:description).at_least(:once).and_return({'validate' => ['uniqueness']})
|
|
122
161
|
end
|
|
123
162
|
|
|
124
|
-
|
|
125
|
-
|
|
163
|
+
context 'when a duplicate exists' do
|
|
164
|
+
before do
|
|
165
|
+
allow(essence).to receive(:duplicates).and_return([essence.dup])
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'should not be valid' do
|
|
169
|
+
expect(essence).to_not be_valid
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
context 'when validated essence is not public' do
|
|
173
|
+
before do
|
|
174
|
+
expect(essence).to receive(:public?).and_return(false)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it 'should be valid' do
|
|
178
|
+
expect(essence).to be_valid
|
|
179
|
+
end
|
|
180
|
+
end
|
|
126
181
|
end
|
|
127
182
|
|
|
128
|
-
context 'when
|
|
183
|
+
context 'when no duplicate exists' do
|
|
129
184
|
before do
|
|
130
|
-
expect(essence).to receive(:
|
|
185
|
+
expect(essence).to receive(:duplicates).and_return([])
|
|
131
186
|
end
|
|
132
187
|
|
|
133
188
|
it 'should be valid' do
|
|
@@ -136,13 +191,51 @@ shared_examples_for "an essence" do
|
|
|
136
191
|
end
|
|
137
192
|
end
|
|
138
193
|
|
|
139
|
-
context '
|
|
140
|
-
|
|
141
|
-
|
|
194
|
+
context 'with hash given as validation type' do
|
|
195
|
+
context 'where the value is true' do
|
|
196
|
+
before do
|
|
197
|
+
expect(essence).to receive(:description).at_least(:once).and_return({'validate' => [{'uniqueness' => true}]})
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
context 'when a duplicate exists' do
|
|
201
|
+
before do
|
|
202
|
+
allow(essence).to receive(:duplicates).and_return([essence.dup])
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'should not be valid' do
|
|
206
|
+
expect(essence).to_not be_valid
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
context 'when validated essence is not public' do
|
|
210
|
+
before do
|
|
211
|
+
expect(essence).to receive(:public?).and_return(false)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'should be valid' do
|
|
215
|
+
expect(essence).to be_valid
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context 'when no duplicate exists' do
|
|
221
|
+
before do
|
|
222
|
+
expect(essence).to receive(:duplicates).and_return([])
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'should be valid' do
|
|
226
|
+
expect(essence).to be_valid
|
|
227
|
+
end
|
|
228
|
+
end
|
|
142
229
|
end
|
|
143
230
|
|
|
144
|
-
|
|
145
|
-
|
|
231
|
+
context 'where the value is false' do
|
|
232
|
+
before do
|
|
233
|
+
allow(essence).to receive(:description).and_return({'validate' => [{'uniqueness' => false}]})
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it 'should be valid' do
|
|
237
|
+
expect(essence).to be_valid
|
|
238
|
+
end
|
|
146
239
|
end
|
|
147
240
|
end
|
|
148
241
|
end
|
|
@@ -2,23 +2,20 @@ require 'factory_girl'
|
|
|
2
2
|
|
|
3
3
|
FactoryGirl.define do
|
|
4
4
|
|
|
5
|
-
factory :
|
|
5
|
+
factory :alchemy_dummy_user, class: 'DummyUser' do
|
|
6
6
|
sequence(:email) { |n| "john.#{n}@doe.com" }
|
|
7
7
|
password 's3cr3t'
|
|
8
|
+
alchemy_roles ['member']
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
trait :as_admin do
|
|
10
11
|
alchemy_roles ['admin']
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
alchemy_roles ['member']
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
factory :author_user do
|
|
14
|
+
trait :as_author do
|
|
18
15
|
alchemy_roles ['author']
|
|
19
16
|
end
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
trait :as_editor do
|
|
22
19
|
alchemy_roles ['editor']
|
|
23
20
|
end
|
|
24
21
|
end
|
|
@@ -3,24 +3,30 @@ module Alchemy
|
|
|
3
3
|
|
|
4
4
|
# Helpers for integration specs
|
|
5
5
|
#
|
|
6
|
-
# This file is included in
|
|
6
|
+
# This file is included in spec_helper.rb
|
|
7
7
|
#
|
|
8
8
|
module IntegrationHelpers
|
|
9
9
|
|
|
10
|
-
# Used
|
|
10
|
+
# Used to stub the current_alchemy_user
|
|
11
11
|
#
|
|
12
|
-
#
|
|
12
|
+
# Pass either a user object or a symbol in the format of ':as_admin'.
|
|
13
|
+
# The browser language is set to english ('en')
|
|
13
14
|
#
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if !user
|
|
20
|
-
user = mock_model('DummyUser', alchemy_roles: %w(admin), language: 'en')
|
|
15
|
+
def authorize_user(user_or_role = nil)
|
|
16
|
+
if user_or_role.is_a?(Alchemy.user_class)
|
|
17
|
+
user = user_or_role
|
|
18
|
+
else
|
|
19
|
+
user = build(:alchemy_dummy_user, user_or_role)
|
|
21
20
|
end
|
|
21
|
+
set_phantomjs_browser_language("en")
|
|
22
22
|
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
|
|
23
23
|
end
|
|
24
|
+
|
|
25
|
+
def set_phantomjs_browser_language(lang = nil)
|
|
26
|
+
if Capybara.current_driver == :poltergeist
|
|
27
|
+
page.driver.headers = {"Accept-Language" => lang}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
24
30
|
end
|
|
25
31
|
|
|
26
32
|
end
|
|
@@ -22,6 +22,10 @@ class Alchemy::Upgrader::ThreePointTwoTask < Thor
|
|
|
22
22
|
{ after: sentinel, verbose: true }
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
def inject_seeder
|
|
27
|
+
append_file "./db/seeds.rb", "Alchemy::Seeder.seed!\n"
|
|
28
|
+
end
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
31
|
|
|
@@ -30,10 +34,36 @@ module Alchemy
|
|
|
30
34
|
private
|
|
31
35
|
|
|
32
36
|
def upgrade_acts_as_taggable_on_migrations
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
desc 'Installs acts_as_taggable_on migrations.'
|
|
38
|
+
if !`bundle exec rake railties:install:migrations FROM=acts_as_taggable_on_engine`.empty?
|
|
39
|
+
Alchemy::Upgrader::ThreePointTwoTask.new.patch_acts_as_taggable_on_migrations
|
|
40
|
+
end
|
|
41
|
+
`bundle exec rake db:migrate`
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def inject_seeder
|
|
45
|
+
desc 'Add Alchemy seeder to `db/seeds.rb` file.'
|
|
46
|
+
Alchemy::Upgrader::ThreePointTwoTask.new.inject_seeder
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def alchemy_3_2_todos
|
|
50
|
+
notice = <<-NOTE
|
|
51
|
+
|
|
52
|
+
Capistrano 2 deploy script removed
|
|
53
|
+
----------------------------------
|
|
54
|
+
|
|
55
|
+
The Capistrano 2 based deploy script has been removed and replaced by an Capistrano 3 extension.
|
|
56
|
+
|
|
57
|
+
Please update your Gemfile:
|
|
58
|
+
|
|
59
|
+
group :development do
|
|
60
|
+
gem 'capistrano-alchemy', github: 'AlchemyCMS/capistrano-alchemy', branch: 'master', require: false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
For more information please visit https://github.com/AlchemyCMS/capistrano-alchemy.
|
|
64
|
+
|
|
65
|
+
NOTE
|
|
66
|
+
todo notice, 'Alchemy v3.2 changes'
|
|
37
67
|
end
|
|
38
68
|
end
|
|
39
69
|
end
|
data/lib/alchemy/version.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
|
|
3
|
+
module Alchemy
|
|
4
|
+
module Generators
|
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
6
|
+
|
|
7
|
+
desc "Installs Alchemy into your App."
|
|
8
|
+
|
|
9
|
+
class_option :skip_demo_files,
|
|
10
|
+
type: :boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
desc: "Skip creation of demo element, page and application layout."
|
|
13
|
+
|
|
14
|
+
source_root File.expand_path('files', File.dirname(__FILE__))
|
|
15
|
+
|
|
16
|
+
def create_view_dirs
|
|
17
|
+
%w(elements page_layouts).each do |dir|
|
|
18
|
+
empty_directory Rails.root.join("app/views/alchemy/#{dir}")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def copy_config
|
|
23
|
+
copy_file "#{config_path}/config.yml",
|
|
24
|
+
Rails.root.join("config/alchemy/config.yml")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def copy_yml_files
|
|
28
|
+
%w(elements page_layouts).each do |file|
|
|
29
|
+
template "#{current_path}/templates/#{file}.yml.tt",
|
|
30
|
+
Rails.root.join("config/alchemy/#{file}.yml")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def copy_demo_views
|
|
35
|
+
return if @options[:skip_demo_files]
|
|
36
|
+
|
|
37
|
+
copy_file "application.html.erb",
|
|
38
|
+
Rails.root.join("app/views/layouts/application.html.erb")
|
|
39
|
+
copy_file "alchemy.elements.css.scss",
|
|
40
|
+
Rails.root.join("app/assets/stylesheets/alchemy.elements.css.scss")
|
|
41
|
+
|
|
42
|
+
[
|
|
43
|
+
"_article_editor.html.erb",
|
|
44
|
+
"_article_view.html.erb"
|
|
45
|
+
].each do |file|
|
|
46
|
+
copy_file file, Rails.root.join("app/views/alchemy/elements/#{file}")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
copy_file "_standard.html.erb",
|
|
50
|
+
Rails.root.join("app/views/alchemy/page_layouts/_standard.html.erb")
|
|
51
|
+
|
|
52
|
+
%w(de en es).each do |locale|
|
|
53
|
+
copy_file "alchemy.#{locale}.yml",
|
|
54
|
+
Rails.root.join("config/locales/alchemy.#{locale}.yml")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def config_path
|
|
61
|
+
@_config_path ||= File.expand_path('../../../../../config/alchemy', current_path)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def current_path
|
|
65
|
+
@_current_path ||= File.dirname(__FILE__)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|