alchemy_cms 3.1.3 → 3.2.0.beta
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/.editorconfig +2 -2
- data/.hound.yml +2 -0
- data/.rubocop.yml +1063 -0
- data/.travis.yml +14 -10
- data/Gemfile +4 -7
- data/README.md +16 -8
- data/alchemy_cms.gemspec +8 -7
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +10 -11
- data/app/assets/javascripts/alchemy/alchemy.js +1 -1
- data/app/assets/stylesheets/alchemy/{admin.css.scss → admin.scss} +1 -0
- data/app/assets/stylesheets/alchemy/{icon-font.css.scss → icon-font.scss} +0 -0
- data/app/assets/stylesheets/alchemy/{menubar.css.scss → menubar.scss} +0 -0
- data/app/assets/stylesheets/alchemy/{print.css.scss → print.scss} +0 -0
- data/app/assets/stylesheets/alchemy/selects.scss +0 -6
- data/app/controllers/alchemy/admin/contents_controller.rb +3 -4
- data/app/controllers/alchemy/admin/pictures_controller.rb +0 -2
- data/app/controllers/alchemy/api/contents_controller.rb +1 -1
- data/app/controllers/alchemy/api/elements_controller.rb +2 -2
- data/app/controllers/alchemy/api/pages_controller.rb +1 -1
- data/app/controllers/alchemy/elements_controller.rb +0 -6
- data/app/controllers/alchemy/pages_controller.rb +17 -13
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/navigation_helper.rb +1 -1
- data/app/models/alchemy/element.rb +41 -17
- data/app/models/alchemy/page/page_naming.rb +16 -29
- data/bin/alchemy +1 -1
- data/config/routes.rb +1 -2
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -17
- data/lib/alchemy/capistrano.rb +3 -4
- data/lib/alchemy/controller_actions.rb +2 -1
- data/lib/alchemy/engine.rb +1 -0
- data/lib/alchemy/errors.rb +7 -0
- data/lib/alchemy/essence.rb +4 -4
- data/lib/alchemy/permissions.rb +1 -1
- data/lib/alchemy/shell.rb +26 -11
- data/lib/alchemy/test_support/controller_requests.rb +48 -12
- data/lib/alchemy/upgrader.rb +1 -0
- data/lib/alchemy/upgrader/three_point_one.rb +0 -1
- data/lib/alchemy/upgrader/three_point_two.rb +39 -0
- data/lib/alchemy/version.rb +1 -1
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/install.rake +2 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +14 -14
- data/spec/controllers/admin/clipboard_controller_spec.rb +5 -5
- data/spec/controllers/admin/contents_controller_spec.rb +8 -14
- data/spec/controllers/admin/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/admin/elements_controller_spec.rb +30 -31
- data/spec/controllers/admin/essence_files_controller_spec.rb +6 -6
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +17 -17
- data/spec/controllers/admin/languages_controller_spec.rb +3 -3
- data/spec/controllers/admin/layoutpages_controller_spec.rb +3 -3
- data/spec/controllers/admin/pages_controller_spec.rb +48 -48
- data/spec/controllers/admin/pictures_controller_spec.rb +19 -19
- data/spec/controllers/admin/resources_controller_spec.rb +2 -2
- data/spec/controllers/admin/trash_controller_spec.rb +5 -5
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +5 -5
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +46 -11
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +42 -14
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +26 -16
- data/spec/controllers/attachments_controller_spec.rb +7 -7
- data/spec/controllers/elements_controller_spec.rb +16 -19
- data/spec/controllers/messages_controller_spec.rb +15 -15
- data/spec/controllers/pages_controller_spec.rb +16 -25
- data/spec/controllers/pictures_controller_spec.rb +75 -49
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/stylesheets/application.css +5 -3
- data/spec/dummy/config/application.rb +11 -1
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +14 -2
- data/spec/dummy/config/environments/production.rb +18 -21
- data/spec/dummy/config/environments/test.rb +9 -4
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +380 -0
- data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
- data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
- data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
- data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
- data/{db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb → spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +5 -6
- data/{db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb → spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +2 -1
- data/{db/migrate/20140701160225_add_missing_taggable_index.rb → spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb} +1 -0
- data/spec/dummy/db/schema.rb +27 -31
- data/spec/dummy/public/404.html +20 -11
- data/spec/dummy/public/422.html +20 -11
- data/spec/dummy/public/500.html +19 -10
- data/spec/features/admin/page_creation_feature_spec.rb +2 -2
- data/spec/libraries/resource_spec.rb +1 -1
- data/spec/libraries/shell_spec.rb +2 -0
- data/spec/models/page_spec.rb +1 -13
- data/spec/spec_helper.rb +6 -4
- data/spec/support/rspec-activemodel-mocks_patch.rb +8 -0
- metadata +63 -56
- data/app/controllers/alchemy/contents_controller.rb +0 -18
- data/spec/controllers/contents_controller_spec.rb +0 -22
- data/spec/dummy/app/models/dummy_model.rb +0 -3
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
- data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
- data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
- data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
- data/spec/dummy/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +0 -1
- data/spec/dummy/db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb +0 -1
- data/spec/dummy/db/migrate/20140701160225_add_missing_taggable_index.rb +0 -1
- data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
- data/spec/dummy/spec/javascripts +0 -1
- data/spec/models/dummy_model_spec.rb +0 -11
data/.travis.yml
CHANGED
|
@@ -2,22 +2,26 @@ language: ruby
|
|
|
2
2
|
sudo: false
|
|
3
3
|
cache: bundler
|
|
4
4
|
rvm:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
- 2.0.0
|
|
6
|
+
- 2.1
|
|
7
|
+
- 2.2.0
|
|
8
8
|
branches:
|
|
9
9
|
only:
|
|
10
|
-
|
|
11
|
-
before_script:
|
|
12
|
-
script:
|
|
10
|
+
- master
|
|
11
|
+
before_script: bundle exec rake alchemy:spec:prepare
|
|
12
|
+
script: bundle exec rspec
|
|
13
13
|
env:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- RAILS_VERSION=4.0.13
|
|
14
|
+
- DB=mysql
|
|
15
|
+
- DB=postgresql
|
|
17
16
|
notifications:
|
|
18
17
|
irc:
|
|
19
18
|
on_success: change
|
|
20
19
|
on_failure: always
|
|
21
20
|
use_notice: true
|
|
22
21
|
channels:
|
|
23
|
-
|
|
22
|
+
- irc.freenode.org#alchemy_cms
|
|
23
|
+
slack:
|
|
24
|
+
secure: QzOFw1Ph69pzwWBFgtIVkOnjbcRxB9HPRQ+RYjK+2tg+fsbiTJ+wYgHcZL49tPYcLAls4kymkFWzWBF3PCAXJMfKgUCqXzdQ2FuJC/JoVRTLll4wDnZFPG33jsm5tVznmycZ3ma4+ZWfJQ+C+elEBOba6v1kG9eGIy6sH2cvXfE=
|
|
25
|
+
addons:
|
|
26
|
+
code_climate:
|
|
27
|
+
secure: qmOMqc4FUBRP25XqaYIKuxZQ/GrGLKjIc3vUqZa+XfkQKh6xLXvOF7YUM/XJZ5u6D6hk0Ly8UxjctvDY+tQxEAK49lFwK51i7bODfkQjfVBrFzfht7QhxY5HJKx7F0HHmpyNJet4n8mR0gGlhwVyXv+Tz7Rm6O3Hq3+TEbY9+pk=
|
data/Gemfile
CHANGED
|
@@ -2,21 +2,17 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
if ENV['RAILS_VERSION']
|
|
6
|
-
gem 'rails', ENV['RAILS_VERSION']
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
gem 'sqlite3' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
|
|
10
|
-
gem 'mysql2'
|
|
6
|
+
gem 'mysql2' if ENV['DB'] == 'mysql'
|
|
11
7
|
gem 'pg' if ENV['DB'] == 'postgresql'
|
|
12
8
|
|
|
13
9
|
group :development, :test do
|
|
14
10
|
gem 'jasmine-rails', github: 'searls/jasmine-rails'
|
|
15
11
|
gem 'jasmine-jquery-rails', github: 'travisjeffery/jasmine-jquery-rails'
|
|
16
12
|
if ENV['TRAVIS']
|
|
17
|
-
gem
|
|
13
|
+
gem "codeclimate-test-reporter", require: false
|
|
18
14
|
else
|
|
19
|
-
gem 'simplecov',
|
|
15
|
+
gem 'simplecov', require: false
|
|
20
16
|
end
|
|
21
17
|
unless ENV['CI']
|
|
22
18
|
gem 'launchy'
|
|
@@ -27,6 +23,7 @@ group :development, :test do
|
|
|
27
23
|
gem 'pry-byebug'
|
|
28
24
|
gem 'spring'
|
|
29
25
|
gem 'spring-commands-rspec'
|
|
26
|
+
gem 'rubocop', require: false
|
|
30
27
|
end
|
|
31
28
|
end
|
|
32
29
|
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
[](http://badge.fury.io/rb/alchemy_cms)
|
|
2
|
-
[](https://travis-ci.org/AlchemyCMS/alchemy_cms) [](https://codeclimate.com/github/AlchemyCMS/alchemy_cms) [](https://codeclimate.com/github/AlchemyCMS/alchemy_cms)
|
|
3
|
+
|
|
4
|
+
**CAUTION: This master branch is a development branch that *can* contain bugs. For productive environments you should use the [current Ruby gem version](https://rubygems.org/gems/alchemy_cms/versions/3.0.0), or the [latest stable branch (3.1-stable)](https://github.com/AlchemyCMS/alchemy_cms/tree/3.1-stable).**
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
## About
|
|
@@ -29,9 +31,9 @@ Read more about Alchemy on the [website](http://alchemy-cms.com) and in the [gui
|
|
|
29
31
|
|
|
30
32
|
## Rails Version
|
|
31
33
|
|
|
32
|
-
**This version of Alchemy CMS runs with Rails 4
|
|
34
|
+
**This version of Alchemy CMS runs with Rails 4.2**
|
|
33
35
|
|
|
34
|
-
* For Rails 4.
|
|
36
|
+
* For a Rails 4.0/4.1 compatible version use the [`3.1-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.1-stable).
|
|
35
37
|
* For a Rails 3.2 compatible version use the [`2.8-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.8-stable).
|
|
36
38
|
* For a Rails 3.1 compatible version use the [`2.1-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.1-stable).
|
|
37
39
|
* For a Rails 3.0 compatible version use the [`2.0-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.0-stable).
|
|
@@ -40,7 +42,9 @@ Read more about Alchemy on the [website](http://alchemy-cms.com) and in the [gui
|
|
|
40
42
|
|
|
41
43
|
## Ruby Version
|
|
42
44
|
|
|
43
|
-
Alchemy runs with Ruby >=
|
|
45
|
+
Alchemy runs with Ruby >= 2.0.0.
|
|
46
|
+
|
|
47
|
+
For a Ruby 1.9.3 compatible version use the [`3.1-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.1-stable).
|
|
44
48
|
|
|
45
49
|
For a Ruby 1.8.7 compatible version use the [`2.3-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.3-stable).
|
|
46
50
|
|
|
@@ -52,7 +56,7 @@ For a Ruby 1.8.7 compatible version use the [`2.3-stable` branch](https://github
|
|
|
52
56
|
Use the installer:
|
|
53
57
|
|
|
54
58
|
```shell
|
|
55
|
-
$ gem install alchemy_cms
|
|
59
|
+
$ gem install alchemy_cms --pre
|
|
56
60
|
$ alchemy new my_magicpage
|
|
57
61
|
```
|
|
58
62
|
|
|
@@ -71,9 +75,11 @@ $ alchemy --help
|
|
|
71
75
|
Put this into your `Gemfile`:
|
|
72
76
|
|
|
73
77
|
```ruby
|
|
74
|
-
gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: '
|
|
78
|
+
gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: 'master'
|
|
75
79
|
```
|
|
76
80
|
|
|
81
|
+
**NOTE:** You normally want to use a stable branch, like `3.0-stable`.
|
|
82
|
+
|
|
77
83
|
If you want to use Russian translation and have better i18n support, you should put:
|
|
78
84
|
|
|
79
85
|
```ruby
|
|
@@ -98,14 +104,16 @@ the Devise based user model that Alchemy provides and was extracted [into its ow
|
|
|
98
104
|
If you don't have your own user class, you can use the Alchemy user model. Just add the following gem into your `Gemfile`:
|
|
99
105
|
|
|
100
106
|
```ruby
|
|
101
|
-
gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: '
|
|
107
|
+
gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: 'master'
|
|
102
108
|
```
|
|
103
109
|
|
|
110
|
+
**NOTE:** You normally want to use a stable branch, like `2.0-stable`.
|
|
111
|
+
|
|
104
112
|
Then run:
|
|
105
113
|
|
|
106
114
|
```shell
|
|
107
115
|
$ bundle install
|
|
108
|
-
$ bin/
|
|
116
|
+
$ bin/rake alchemy_devise:install:migrations
|
|
109
117
|
```
|
|
110
118
|
|
|
111
119
|
##### Use your User model
|
data/alchemy_cms.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.summary = 'A powerful, userfriendly and flexible CMS for Rails 4'
|
|
13
13
|
gem.description = 'Alchemy is a powerful, userfriendly and flexible Rails 4 CMS.'
|
|
14
14
|
gem.requirements << 'ImageMagick (libmagick), v6.6 or greater.'
|
|
15
|
-
gem.required_ruby_version = '>=
|
|
15
|
+
gem.required_ruby_version = '>= 2.0.0'
|
|
16
16
|
gem.license = 'BSD New'
|
|
17
17
|
gem.files = `git ls-files`.split("\n")
|
|
18
18
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
@@ -20,22 +20,23 @@ Gem::Specification.new do |gem|
|
|
|
20
20
|
gem.require_paths = ['lib']
|
|
21
21
|
|
|
22
22
|
gem.add_runtime_dependency 'actionpack-page_caching', ['~> 1.0.0']
|
|
23
|
-
gem.add_runtime_dependency 'active_model_serializers', ['
|
|
23
|
+
gem.add_runtime_dependency 'active_model_serializers', ['~> 0.9']
|
|
24
24
|
gem.add_runtime_dependency 'acts_as_list', ['~> 0.3']
|
|
25
25
|
gem.add_runtime_dependency 'acts-as-taggable-on', ['~> 3.1']
|
|
26
26
|
gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.0.0']
|
|
27
|
-
gem.add_runtime_dependency 'cancancan', ['~> 1.9'
|
|
27
|
+
gem.add_runtime_dependency 'cancancan', ['~> 1.9']
|
|
28
28
|
gem.add_runtime_dependency 'coffee-rails', ['~> 4.0']
|
|
29
|
-
gem.add_runtime_dependency 'compass-rails', ['~>
|
|
29
|
+
gem.add_runtime_dependency 'compass-rails', ['~> 2.0', '>= 2.0.4']
|
|
30
30
|
gem.add_runtime_dependency 'dragonfly', ['~> 1.0.1']
|
|
31
|
-
gem.add_runtime_dependency 'jquery-rails', ['~>
|
|
31
|
+
gem.add_runtime_dependency 'jquery-rails', ['~> 4.0.3']
|
|
32
32
|
gem.add_runtime_dependency 'jquery-ui-rails', ['~> 5.0.0']
|
|
33
33
|
gem.add_runtime_dependency 'kaminari', ['~> 0.15']
|
|
34
34
|
gem.add_runtime_dependency 'magiclabs-userstamp', ['~> 2.1.0']
|
|
35
35
|
gem.add_runtime_dependency 'non-stupid-digest-assets', ['~> 1.0.3']
|
|
36
|
-
gem.add_runtime_dependency 'rails', ['>= 4.0', '<
|
|
36
|
+
gem.add_runtime_dependency 'rails', ['>= 4.2.0', '< 5.0']
|
|
37
37
|
gem.add_runtime_dependency 'request_store', ['~> 1.1.0']
|
|
38
|
-
gem.add_runtime_dependency '
|
|
38
|
+
gem.add_runtime_dependency 'responders', ['~> 2.0']
|
|
39
|
+
gem.add_runtime_dependency 'sass-rails', ['~> 5.0']
|
|
39
40
|
gem.add_runtime_dependency 'sassy-buttons', ['~> 0.2.6']
|
|
40
41
|
gem.add_runtime_dependency 'select2-rails', ['>= 3.5.9.1', '< 4.0']
|
|
41
42
|
gem.add_runtime_dependency 'simple_form', ['~> 3.0']
|
|
@@ -46,17 +46,16 @@ $.extend Alchemy,
|
|
|
46
46
|
# fades the image after its been loaded
|
|
47
47
|
ImageLoader: (scope = document, options = {color: '#fff'}) ->
|
|
48
48
|
$('img', scope).each ->
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$parent.html('<span class="icon warn"/>')
|
|
49
|
+
image = $(this).hide()
|
|
50
|
+
$parent = image.parent()
|
|
51
|
+
spinner = Alchemy.Spinner.small options
|
|
52
|
+
spinner.spin $parent[0]
|
|
53
|
+
image.on 'load', ->
|
|
54
|
+
spinner.stop()
|
|
55
|
+
image.fadeIn 400
|
|
56
|
+
image.on 'error', ->
|
|
57
|
+
spinner.stop()
|
|
58
|
+
$parent.html('<span class="icon warn"/>')
|
|
60
59
|
|
|
61
60
|
removePicture: (selector) ->
|
|
62
61
|
$form_field = $(selector)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//= require select2
|
|
2
|
-
|
|
3
1
|
select {
|
|
4
2
|
@extend %button-defaults;
|
|
5
3
|
height: 29px;
|
|
@@ -139,10 +137,6 @@ select {
|
|
|
139
137
|
|
|
140
138
|
.select2-search {
|
|
141
139
|
margin: $default-margin 0;
|
|
142
|
-
|
|
143
|
-
.select2-input {
|
|
144
|
-
width: inherit;
|
|
145
|
-
}
|
|
146
140
|
}
|
|
147
141
|
|
|
148
142
|
&.select2-with-searchbox .select2-results > .select2-result:first-child {
|
|
@@ -33,10 +33,9 @@ module Alchemy
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def order
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
36
|
+
params[:content_ids].each do |id|
|
|
37
|
+
content = Content.find(id)
|
|
38
|
+
content.move_to_bottom
|
|
40
39
|
end
|
|
41
40
|
@notice = _t("Successfully saved content position")
|
|
42
41
|
end
|
|
@@ -9,10 +9,10 @@ module Alchemy
|
|
|
9
9
|
#
|
|
10
10
|
def index
|
|
11
11
|
@elements = Element.accessible_by(current_ability, :index)
|
|
12
|
-
if params[:page_id]
|
|
12
|
+
if params[:page_id].present?
|
|
13
13
|
@elements = @elements.where(page_id: params[:page_id])
|
|
14
14
|
end
|
|
15
|
-
if params[:named]
|
|
15
|
+
if params[:named].present?
|
|
16
16
|
@elements = @elements.named(params[:named])
|
|
17
17
|
end
|
|
18
18
|
respond_with @elements
|
|
@@ -13,7 +13,6 @@ module Alchemy
|
|
|
13
13
|
#
|
|
14
14
|
# * html
|
|
15
15
|
# * js (Tries to replace a given +container_id+ with the elements view partial content via jQuery.)
|
|
16
|
-
# * json (A JSON object that includes all contents and their ingredients)
|
|
17
16
|
#
|
|
18
17
|
def show
|
|
19
18
|
@page = @element.page
|
|
@@ -22,12 +21,7 @@ module Alchemy
|
|
|
22
21
|
respond_to do |format|
|
|
23
22
|
format.html
|
|
24
23
|
format.js { @container_id = params[:container_id] }
|
|
25
|
-
format.json do
|
|
26
|
-
ActiveSupport::Deprecation.warn("The Alchemy elements json API moved to `api` namespace. Please use `/api/elements` for json requests instead.")
|
|
27
|
-
render json: @element, serializer: LegacyElementSerializer
|
|
28
|
-
end
|
|
29
24
|
end
|
|
30
25
|
end
|
|
31
|
-
|
|
32
26
|
end
|
|
33
27
|
end
|
|
@@ -26,10 +26,6 @@ module Alchemy
|
|
|
26
26
|
render xml: {error: 'Not found'}, status: 404
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
format.json do
|
|
30
|
-
ActiveSupport::Deprecation.warn('The Alchemy pages json API moved to `api` namespace. Please use `/api/pages` for json requests instead.')
|
|
31
|
-
render json: @page
|
|
32
|
-
end
|
|
33
29
|
end
|
|
34
30
|
end
|
|
35
31
|
end
|
|
@@ -125,13 +121,14 @@ module Alchemy
|
|
|
125
121
|
end
|
|
126
122
|
end
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
# Redirects page to given url with 301 status while keeping all additional params
|
|
125
|
+
def redirect_page(options = {})
|
|
126
|
+
options = {
|
|
127
|
+
lang: (multi_language? ? @page.language_code : nil),
|
|
128
|
+
urlname: @page.urlname
|
|
129
|
+
}.merge(options)
|
|
130
|
+
|
|
131
|
+
redirect_to show_page_path(additional_params.merge(options)), status: 301
|
|
135
132
|
end
|
|
136
133
|
|
|
137
134
|
# Use the bare minimum to redirect to @page
|
|
@@ -145,9 +142,16 @@ module Alchemy
|
|
|
145
142
|
redirect_to show_page_path(options), :status => 301
|
|
146
143
|
end
|
|
147
144
|
|
|
145
|
+
# Returns url parameters that are not internal show page params.
|
|
146
|
+
#
|
|
147
|
+
# * action
|
|
148
|
+
# * controller
|
|
149
|
+
# * urlname
|
|
150
|
+
# * lang
|
|
151
|
+
#
|
|
148
152
|
def additional_params
|
|
149
|
-
params.
|
|
150
|
-
|
|
153
|
+
params.symbolize_keys.delete_if do |key, _|
|
|
154
|
+
[:action, :controller, :urlname, :lang].include?(key)
|
|
151
155
|
end
|
|
152
156
|
end
|
|
153
157
|
|
|
@@ -69,24 +69,32 @@ module Alchemy
|
|
|
69
69
|
class << self
|
|
70
70
|
|
|
71
71
|
# Builds a new element as described in +/config/alchemy/elements.yml+
|
|
72
|
-
|
|
72
|
+
#
|
|
73
|
+
# - Returns a new Alchemy::Element object if no name is given in attributes,
|
|
74
|
+
# because the definition can not be found w/o name
|
|
75
|
+
# - Raises Alchemy::ElementDefinitionError if no definition for given attributes[:name]
|
|
76
|
+
# could be found
|
|
77
|
+
#
|
|
78
|
+
def new_from_scratch(attributes = {})
|
|
73
79
|
attributes = attributes.dup.symbolize_keys
|
|
80
|
+
|
|
74
81
|
return new if attributes[:name].blank?
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if element_scratch = definitions.detect { |el| el['name'] == attributes[:name] }
|
|
79
|
-
new(element_scratch.merge(attributes).except(*FORBIDDEN_DEFINITION_ATTRIBUTES))
|
|
80
|
-
else
|
|
81
|
-
raise ElementDefinitionError, "Element definition for #{attributes[:name]} not found. Please check your elements.yml"
|
|
82
|
-
end
|
|
82
|
+
|
|
83
|
+
new_element_from_definition_by(attributes) ||
|
|
84
|
+
raise(ElementDefinitionError.new(attributes))
|
|
83
85
|
end
|
|
84
86
|
|
|
85
|
-
#
|
|
87
|
+
# Creates a new element as described in +/config/alchemy/elements.yml+
|
|
88
|
+
#
|
|
89
|
+
# - Returns a new Alchemy::Element object if no name is given in attributes,
|
|
90
|
+
# because the definition can not be found w/o name
|
|
91
|
+
# - Raises Alchemy::ElementDefinitionError if no definition for given attributes[:name]
|
|
92
|
+
# could be found
|
|
93
|
+
#
|
|
86
94
|
def create_from_scratch(attributes)
|
|
87
95
|
element = new_from_scratch(attributes)
|
|
88
96
|
element.save if element
|
|
89
|
-
|
|
97
|
+
element
|
|
90
98
|
end
|
|
91
99
|
|
|
92
100
|
# This methods does a copy of source and all depending contents and all of their depending essences.
|
|
@@ -127,6 +135,20 @@ module Alchemy
|
|
|
127
135
|
}
|
|
128
136
|
end
|
|
129
137
|
|
|
138
|
+
private
|
|
139
|
+
|
|
140
|
+
def new_element_from_definition_by(attributes)
|
|
141
|
+
remove_cell_name_from_element_name!(attributes)
|
|
142
|
+
|
|
143
|
+
element_scratch = definitions.detect { |el| el['name'] == attributes[:name] }
|
|
144
|
+
return if element_scratch.nil?
|
|
145
|
+
|
|
146
|
+
new(element_scratch.merge(attributes).except(*FORBIDDEN_DEFINITION_ATTRIBUTES))
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def remove_cell_name_from_element_name!(attributes)
|
|
150
|
+
attributes[:name] = attributes[:name].split('#').first
|
|
151
|
+
end
|
|
130
152
|
end
|
|
131
153
|
|
|
132
154
|
# Returns next public element from same page.
|
|
@@ -192,9 +214,7 @@ module Alchemy
|
|
|
192
214
|
# rss_title: true
|
|
193
215
|
#
|
|
194
216
|
def content_for_rss_title
|
|
195
|
-
|
|
196
|
-
return if rss_title.blank?
|
|
197
|
-
contents.find_by_name(rss_title['name'])
|
|
217
|
+
content_for_rss_meta('title')
|
|
198
218
|
end
|
|
199
219
|
|
|
200
220
|
# Returns the content that is marked as rss description.
|
|
@@ -208,9 +228,7 @@ module Alchemy
|
|
|
208
228
|
# rss_description: true
|
|
209
229
|
#
|
|
210
230
|
def content_for_rss_description
|
|
211
|
-
|
|
212
|
-
return if rss_description.blank?
|
|
213
|
-
contents.find_by_name(rss_description['name'])
|
|
231
|
+
content_for_rss_meta('description')
|
|
214
232
|
end
|
|
215
233
|
|
|
216
234
|
# Returns the array with the hashes for all element contents in the elements.yml file
|
|
@@ -437,6 +455,12 @@ module Alchemy
|
|
|
437
455
|
|
|
438
456
|
private
|
|
439
457
|
|
|
458
|
+
def content_for_rss_meta(type)
|
|
459
|
+
description = content_descriptions.detect { |c| c["rss_#{type}"] }
|
|
460
|
+
return if description.blank?
|
|
461
|
+
contents.find_by(name: description['name'])
|
|
462
|
+
end
|
|
463
|
+
|
|
440
464
|
# creates the contents for this element as described in the elements.yml
|
|
441
465
|
def create_contents
|
|
442
466
|
contents = []
|