alchemy_cms 5.1.10 → 5.2.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -1
  3. data/CHANGELOG.md +21 -29
  4. data/Gemfile +2 -6
  5. data/alchemy_cms.gemspec +3 -3
  6. data/app/assets/stylesheets/alchemy/_variables.scss +2 -0
  7. data/app/assets/stylesheets/alchemy/elements.scss +38 -5
  8. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +3 -3
  9. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +7 -7
  10. data/app/controllers/alchemy/admin/base_controller.rb +4 -9
  11. data/app/controllers/alchemy/admin/trash_controller.rb +2 -0
  12. data/app/decorators/alchemy/content_editor.rb +64 -0
  13. data/app/decorators/alchemy/element_editor.rb +1 -25
  14. data/app/helpers/alchemy/admin/contents_helper.rb +3 -8
  15. data/app/helpers/alchemy/elements_helper.rb +0 -18
  16. data/app/helpers/alchemy/pages_helper.rb +1 -1
  17. data/app/models/alchemy/attachment.rb +5 -1
  18. data/app/models/alchemy/content.rb +7 -0
  19. data/app/models/alchemy/element/definitions.rb +5 -22
  20. data/app/models/alchemy/element.rb +39 -1
  21. data/app/models/alchemy/node.rb +1 -1
  22. data/app/models/alchemy/page/page_elements.rb +9 -2
  23. data/app/models/alchemy/page.rb +1 -1
  24. data/app/models/alchemy/picture/transformations.rb +3 -3
  25. data/app/models/alchemy/picture.rb +2 -2
  26. data/app/models/alchemy/picture_variant.rb +1 -1
  27. data/app/views/alchemy/admin/elements/_element.html.erb +1 -1
  28. data/app/views/alchemy/admin/elements/_element_header.html.erb +2 -0
  29. data/app/views/alchemy/essences/_essence_picture_view.html.erb +3 -3
  30. data/config/brakeman.ignore +305 -17
  31. data/config/initializers/dragonfly.rb +0 -8
  32. data/config/locales/alchemy.en.yml +40 -24
  33. data/lib/alchemy/deprecation.rb +1 -1
  34. data/lib/alchemy/element_definition.rb +70 -0
  35. data/lib/alchemy/elements_finder.rb +6 -2
  36. data/lib/alchemy/engine.rb +1 -8
  37. data/lib/alchemy/essence.rb +4 -4
  38. data/lib/alchemy/filetypes.rb +13 -0
  39. data/lib/alchemy/forms/builder.rb +1 -1
  40. data/lib/alchemy/i18n.rb +4 -5
  41. data/lib/alchemy/page_layout.rb +1 -0
  42. data/lib/alchemy/resource.rb +3 -5
  43. data/lib/alchemy/test_support/integration_helpers.rb +5 -5
  44. data/lib/alchemy/upgrader/five_point_zero.rb +0 -32
  45. data/lib/alchemy/version.rb +1 -1
  46. data/lib/alchemy_cms.rb +1 -1
  47. data/lib/generators/alchemy/install/install_generator.rb +1 -2
  48. data/lib/tasks/alchemy/thumbnails.rake +2 -4
  49. data/lib/tasks/alchemy/upgrade.rake +0 -20
  50. data/package/admin.js +0 -2
  51. data/package/src/__tests__/i18n.spec.js +0 -23
  52. data/package/src/i18n.js +3 -1
  53. data/package.json +1 -1
  54. metadata +20 -17
  55. data/lib/alchemy/dragonfly/processors/crop_resize.rb +0 -35
  56. data/lib/alchemy/error_tracking/airbrake_handler.rb +0 -13
  57. data/lib/alchemy/error_tracking.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22e0baf2c4ddddb60434bca77764c2d8b7a885cf164a17e5c1ef67f6e0f4a4ba
4
- data.tar.gz: e74e655f91a8966bfe636504976c06df51675c24343b3fa606c37ae3f7019741
3
+ metadata.gz: f2d282ae615eeffe270108252f3979dbad9a1233d280f8834c1b5420afc27929
4
+ data.tar.gz: '095d174025843dd1c347c17ef6fe9ca93bf80398d6eb33f1d5f6d5c2d1c2e7d4'
5
5
  SHA512:
6
- metadata.gz: 60e262f8c6f3683ba502ffb9cf07031216021d04c5db3c8743748dea49a499e310f0ee0d98a2bb5c06896510fe7c913a526e791ee82637def10012611706aad3
7
- data.tar.gz: 05515f3c002cbaa8a797e156d3e83d296e3fff58e4a01d1c47bd7c61ca9487b34f12c29149e9616c33ef5200e1b491e15bafb101477b361457c6e93603969046
6
+ metadata.gz: 260ad000c50c5466d49644054541829229f4eebf0bb75e375c25aeffd835a61acfe5fd8d4accf45bc7724c707966fc8501c21f7ee1e080d73e84c1435265d4b0
7
+ data.tar.gz: '08af0b5dab164cfda123d3d600f486592ffc2f5ac59caf63a4c8b6642cf3febff9371c394adab35811c3c7e0c11601bf0b63e17211906dbd31300e7e9d70964a'
@@ -4,7 +4,7 @@ on: [push, pull_request]
4
4
 
5
5
  jobs:
6
6
  RSpec:
7
- runs-on: ubuntu-latest
7
+ runs-on: ubuntu-18.04
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
@@ -14,6 +14,7 @@ jobs:
14
14
  ruby:
15
15
  - '2.5.x'
16
16
  - '2.6.x'
17
+ - '2.7.x'
17
18
  database:
18
19
  - mysql
19
20
  - postgresql
data/CHANGELOG.md CHANGED
@@ -1,43 +1,35 @@
1
- ## 5.1.10 (2022-02-28)
1
+ ## 5.2.0.b1 (2021-02-11)
2
2
 
3
- - Add crop_resize Dragonfly processor ([tvdeyen](https://github.com/tvdeyen))
4
-
5
- ## 5.1.9 (2021-11-24)
6
-
7
- - Adjust tinymce skin assets urls again ([tvdeyen](https://github.com/tvdeyen))
8
-
9
- ## 5.1.8 (2021-11-17)
10
-
11
- - Set stampable user_class_name without root identifier ([tvdeyen](https://github.com/tvdeyen))
12
- - Use relative path for tinymce font-face ([tvdeyen](https://github.com/tvdeyen))
13
-
14
- ## 5.1.7 (2021-10-26)
15
-
16
- - Make sure to install correct npm package ([tvdeyen](https://github.com/tvdeyen))
17
-
18
- ## 5.1.6 (2021-09-17)
19
-
20
- - Use self_and_ancestors in page_active? helper [#2194](https://github.com/AlchemyCMS/alchemy_cms/pull/2194) ([mamhoff](https://github.com/mamhoff))
3
+ ### Features
21
4
 
22
- ## 5.1.5 (2021-09-15)
5
+ - Allow Element and Content deprecation notices [#1988](https://github.com/AlchemyCMS/alchemy_cms/pull/1988) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Add element definition api (based on PageLayout definitions) [#1986](https://github.com/AlchemyCMS/alchemy_cms/pull/1986) ([stockime](https://github.com/stockime))
23
7
 
24
- - generate picture thumbnails only for pictures with convertible format [#2131](https://github.com/AlchemyCMS/alchemy_cms/pull/2131) ([afdev82](https://github.com/afdev82))
25
- - Backport #2115 to v5.1 [#2125](https://github.com/AlchemyCMS/alchemy_cms/pull/2125) ([dbwinger](https://github.com/dbwinger))
26
- - Backport #2114 to v5.1 [#2117](https://github.com/AlchemyCMS/alchemy_cms/pull/2117) ([afdev82](https://github.com/afdev82))
8
+ ### Changes
27
9
 
28
- ## 5.1.4 (2021-05-13)
10
+ - Fix jpeg quality option for jpeg files [#2016](https://github.com/AlchemyCMS/alchemy_cms/pull/2016) ([kulturbande](https://github.com/kulturbande))
11
+ - Pin Ransack to below 2.4.2 [#2012](https://github.com/AlchemyCMS/alchemy_cms/pull/2012) ([tvdeyen](https://github.com/tvdeyen))
12
+ - Fix setting current_user in integration helper [#2006](https://github.com/AlchemyCMS/alchemy_cms/pull/2006) ([tvdeyen](https://github.com/tvdeyen))
13
+ - Update mime type icons and translations [#2002](https://github.com/AlchemyCMS/alchemy_cms/pull/2002) ([tvdeyen](https://github.com/tvdeyen))
14
+ - Deprecate page layout change [#1993](https://github.com/AlchemyCMS/alchemy_cms/pull/1993) ([tvdeyen](https://github.com/tvdeyen))
15
+ - Fix Ruby 2.7 deprecations [#1989](https://github.com/AlchemyCMS/alchemy_cms/pull/1989) ([tvdeyen](https://github.com/tvdeyen))
16
+ - Deprecate trash [#1985](https://github.com/AlchemyCMS/alchemy_cms/pull/1985) ([tvdeyen](https://github.com/tvdeyen))
17
+ - Deprecate elements fallbacks [#1982](https://github.com/AlchemyCMS/alchemy_cms/pull/1982) ([tvdeyen](https://github.com/tvdeyen))
29
18
 
30
- - Fix alchemy:generate:thumbnails task [#2092](https://github.com/AlchemyCMS/alchemy_cms/pull/2092) ([afdev82](https://github.com/afdev82))
31
- - Do not attempt to generate thumbs for svg files. [#2090](https://github.com/AlchemyCMS/alchemy_cms/pull/2090) ([oneiros](https://github.com/oneiros))
19
+ ### Misc
32
20
 
33
- ## 5.1.3 (2021-05-06)
21
+ - Use Ubuntu 18.04 on GH actions [#2018](https://github.com/AlchemyCMS/alchemy_cms/pull/2018) ([tvdeyen](https://github.com/tvdeyen))
22
+ - [ruby - main] Upgrade rubocop to version 1.9.0 [#2011](https://github.com/AlchemyCMS/alchemy_cms/pull/2011) ([depfu](https://github.com/apps/depfu))
23
+ - [ruby - main] Upgrade rubocop to version 1.8.1 [#1999](https://github.com/AlchemyCMS/alchemy_cms/pull/1999) ([depfu](https://github.com/apps/depfu))
24
+ - Update brakeman ignores [#1992](https://github.com/AlchemyCMS/alchemy_cms/pull/1992) ([tvdeyen](https://github.com/tvdeyen))
25
+ - [ruby - main] Upgrade rubocop to version 1.6.1 [#1978](https://github.com/AlchemyCMS/alchemy_cms/pull/1978) ([depfu](https://github.com/apps/depfu))
26
+ - [ruby - main] Upgrade simplecov to version 0.20.0 [#1971](https://github.com/AlchemyCMS/alchemy_cms/pull/1971) ([depfu](https://github.com/apps/depfu))
34
27
 
35
- - Use symbols in polymorphic routes for resources [#2087](https://github.com/AlchemyCMS/alchemy_cms/pull/2087) ([tvdeyen](https://github.com/tvdeyen))
36
- - Backport #2049 to 5.1 [#2059](https://github.com/AlchemyCMS/alchemy_cms/pull/2059) ([rickythefox](https://github.com/rickythefox))
37
28
  ## 5.1.2 (2021-01-26)
38
29
 
39
30
  - Allow to safe hidden elements [#2007](https://github.com/AlchemyCMS/alchemy_cms/pull/2007) ([tvdeyen](https://github.com/tvdeyen))
40
31
 
32
+
41
33
  ## 5.1.1 (2021-01-12)
42
34
 
43
35
  - Fix copy element feature [#1996](https://github.com/AlchemyCMS/alchemy_cms/pull/1996) ([tvdeyen](https://github.com/tvdeyen))
data/Gemfile CHANGED
@@ -13,11 +13,6 @@ gem "mysql2", "~> 0.5.1" if ENV["DB"] == "mysql"
13
13
  gem "pg", "~> 1.0" if ENV["DB"] == "postgresql"
14
14
 
15
15
  group :development, :test do
16
- # execjs 2.8 removes deprecation warnings but also breaks a number of dependent projects.
17
- # in our case the culprit is `handlebars-assets`. The changes between 2.7.0 and 2.8.0 are
18
- # minimal, but breaking.
19
- gem "execjs", "= 2.7.0"
20
-
21
16
  if ENV["GITHUB_ACTIONS"]
22
17
  gem "sassc", "~> 2.4.0" # https://github.com/sass/sassc-ruby/issues/146
23
18
  else
@@ -27,7 +22,7 @@ group :development, :test do
27
22
  gem "yard"
28
23
  gem "redcarpet"
29
24
  gem "pry-byebug"
30
- gem "rubocop", "~> 1.1.0", require: false
25
+ gem "rubocop", "~> 1.9.0", require: false
31
26
  gem "listen"
32
27
  gem "localeapp", "~> 3.0", require: false
33
28
  gem "dotenv", "~> 2.2"
@@ -35,5 +30,6 @@ group :development, :test do
35
30
  gem "active_record_query_trace", require: false
36
31
  gem "rack-mini-profiler", require: false
37
32
  gem "rufo", require: false
33
+ gem "brakeman", require: false
38
34
  end
39
35
  end
data/alchemy_cms.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.1']
24
24
  gem.add_runtime_dependency 'cancancan', ['>= 2.1', '< 4.0']
25
25
  gem.add_runtime_dependency 'coffee-rails', ['>= 4.0', '< 6.0']
26
- gem.add_runtime_dependency 'dragonfly', ['~> 1.4']
26
+ gem.add_runtime_dependency 'dragonfly', ['~> 1.0', '>= 1.0.7']
27
27
  gem.add_runtime_dependency 'dragonfly_svg', ['~> 0.0.4']
28
28
  gem.add_runtime_dependency 'gutentag', ['~> 2.2', '>= 2.2.1']
29
29
  gem.add_runtime_dependency 'handlebars_assets', ['~> 0.23']
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
33
33
  gem.add_runtime_dependency 'originator', ['~> 3.1']
34
34
  gem.add_runtime_dependency 'non-stupid-digest-assets', ['~> 1.0.8']
35
35
  gem.add_runtime_dependency 'rails', ['>= 5.2.0', '< 6.1']
36
- gem.add_runtime_dependency 'ransack', ['>= 1.8', '< 3.0']
36
+ gem.add_runtime_dependency 'ransack', ['>= 1.8', '< 2.4.2'] # 2.4.2 dropped Ruby 2.5 support in a patch level release
37
37
  gem.add_runtime_dependency 'request_store', ['~> 1.2']
38
38
  gem.add_runtime_dependency 'responders', ['>= 2.0', '< 4.0']
39
39
  gem.add_runtime_dependency 'sassc-rails', ['~> 2.1']
@@ -49,7 +49,7 @@ Gem::Specification.new do |gem|
49
49
  gem.add_development_dependency 'rails-controller-testing', ['~> 1.0']
50
50
  gem.add_development_dependency 'rspec-activemodel-mocks', ['~> 1.0']
51
51
  gem.add_development_dependency 'rspec-rails', ['>= 4.0.0.beta2']
52
- gem.add_development_dependency 'simplecov', ['~> 0.17.1']
52
+ gem.add_development_dependency 'simplecov', ['~> 0.20']
53
53
  gem.add_development_dependency 'webdrivers', ['~> 4.0']
54
54
  gem.add_development_dependency 'webmock', ['~> 3.3']
55
55
  gem.add_development_dependency 'shoulda-matchers', ['~> 4.0']
@@ -145,6 +145,8 @@ $elements-window-min-width: 400px !default;
145
145
  $element-header-bg-color: $medium-gray !default;
146
146
  $element-header-active-bg-color: $dark-blue !default;
147
147
  $element-header-active-color: $white !default;
148
+ $element-header-deprecated-bg-color: rgba(253, 213, 175, 0.25) !default;
149
+ $element-deprecated-border-color: rgb(253, 213, 175) !default;
148
150
  $top-menu-height: 75px !default;
149
151
 
150
152
  $tabs-height: 31px !default;
@@ -170,13 +170,32 @@
170
170
  }
171
171
  }
172
172
 
173
+ &.deprecated {
174
+ border-color: $element-deprecated-border-color;
175
+
176
+ > .element-header {
177
+ background-color: $element-header-deprecated-bg-color;
178
+ background-image: linear-gradient(
179
+ 45deg,
180
+ $element-header-deprecated-bg-color 25%,
181
+ $element-header-bg-color 25%,
182
+ $element-header-bg-color 50%,
183
+ $element-header-deprecated-bg-color 50%,
184
+ $element-header-deprecated-bg-color 75%,
185
+ $element-header-bg-color 75%,
186
+ $element-header-bg-color 100%
187
+ );
188
+ background-size: 28.28px 28.28px;
189
+ }
190
+ }
191
+
173
192
  &.selected:not(.is-fixed), &:hover {
174
193
  &:not(.hidden) {
175
194
  box-shadow: 0 2px 8px rgba(#9b9b9b, 0.75);
176
195
  }
177
196
  }
178
197
 
179
- &.selected:not(.is-fixed):not(.folded):not(.dirty):not(.hidden) {
198
+ &.selected:not(.is-fixed):not(.folded):not(.dirty):not(.hidden):not(.deprecated) {
180
199
  > .element-header {
181
200
  background-color: $element-header-active-bg-color;
182
201
  color: $element-header-active-color;
@@ -670,6 +689,24 @@ select.long {
670
689
  }
671
690
  }
672
691
 
692
+ &.deprecated {
693
+ border-radius: $default-border-radius;
694
+ background-color: $element-header-deprecated-bg-color;
695
+ background-image: linear-gradient(
696
+ 45deg,
697
+ $element-header-deprecated-bg-color 25%,
698
+ $element-header-bg-color 25%,
699
+ $element-header-bg-color 50%,
700
+ $element-header-deprecated-bg-color 50%,
701
+ $element-header-deprecated-bg-color 75%,
702
+ $element-header-bg-color 75%,
703
+ $element-header-bg-color 100%
704
+ );
705
+ background-size: 28.28px 28.28px;
706
+ padding-left: 2px;
707
+ padding-right: 2px;
708
+ }
709
+
673
710
  label {
674
711
  display: block;
675
712
  margin: $default-margin 0;
@@ -802,10 +839,6 @@ textarea.has_tinymce {
802
839
  }
803
840
  }
804
841
 
805
- .element-handle .hint-with-icon {
806
- top: -1px;
807
- }
808
-
809
842
  .is-fixed {
810
843
  &.with-contents {
811
844
  >.element-footer {
@@ -30,7 +30,7 @@ td,th {
30
30
 
31
31
  .mce-object {
32
32
  border: 1px dotted #3a3a3a;
33
- background: #d5d5d5 url('tinymce/skins/alchemy/fonts/img/object.gif') no-repeat center;
33
+ background: #d5d5d5 url(img/object.gif) no-repeat center;
34
34
  }
35
35
 
36
36
  .mce-pagebreak {
@@ -55,7 +55,7 @@ td,th {
55
55
  width: 9px!important;
56
56
  height: 9px!important;
57
57
  border: 1px dotted #3a3a3a;
58
- background: #d5d5d5 url('tinymce/skins/alchemy/fonts/img/anchor.gif') no-repeat center;
58
+ background: #d5d5d5 url(img/anchor.gif) no-repeat center;
59
59
  }
60
60
 
61
61
  .mce-nbsp {
@@ -77,7 +77,7 @@ hr {
77
77
  }
78
78
 
79
79
  .mce-spellchecker-word {
80
- background: url('tinymce/skins/alchemy/fonts/img/wline.gif') repeat-x bottom left;
80
+ background: url(img/wline.gif) repeat-x bottom left;
81
81
  cursor: default;
82
82
  }
83
83
 
@@ -1561,23 +1561,23 @@ i.mce-i-resize {
1561
1561
  opacity: 0.6;
1562
1562
  filter: alpha(opacity=60);
1563
1563
  zoom: 1;
1564
- background: #fff url('tinymce/skins/alchemy/fonts/img/loader.gif') no-repeat center center;
1564
+ background: #fff url('img/loader.gif') no-repeat center center;
1565
1565
  }
1566
1566
 
1567
1567
  @font-face {
1568
1568
  font-family: 'tinymce';
1569
- src: url('tinymce/skins/alchemy/fonts/tinymce.woff') format('woff'),
1570
- url('tinymce/skins/alchemy/fonts/tinymce.ttf') format('truetype'),
1571
- url('tinymce/skins/alchemy/fonts/tinymce.svg#tinymce') format('svg');
1569
+ src: url('fonts/tinymce.woff') format('woff'),
1570
+ url('fonts/tinymce.ttf') format('truetype'),
1571
+ url('fonts/tinymce.svg#tinymce') format('svg');
1572
1572
  font-weight: normal;
1573
1573
  font-style: normal;
1574
1574
  }
1575
1575
 
1576
1576
  @font-face {
1577
1577
  font-family: 'tinymce-small';
1578
- src: url('tinymce/skins/alchemy/fonts/tinymce-small.woff') format('woff'),
1579
- url('tinymce/skins/alchemy/fonts/tinymce-small.ttf') format('truetype'),
1580
- url('tinymce/skins/alchemy/fonts/tinymce-small.svg#tinymce') format('svg');
1578
+ src: url('fonts/tinymce-small.woff') format('woff'),
1579
+ url('fonts/tinymce-small.ttf') format('truetype'),
1580
+ url('fonts/tinymce-small.svg#tinymce') format('svg');
1581
1581
  font-weight: normal;
1582
1582
  font-style: normal;
1583
1583
  }
@@ -40,7 +40,9 @@ module Alchemy
40
40
  def exception_handler(error)
41
41
  exception_logger(error)
42
42
  show_error_notice(error)
43
- notify_error_tracker(error)
43
+ if defined?(Airbrake)
44
+ notify_airbrake(error) unless Rails.env.development? || Rails.env.test?
45
+ end
44
46
  end
45
47
 
46
48
  # Displays an error notice in the Alchemy backend.
@@ -70,6 +72,7 @@ module Alchemy
70
72
  def trash_empty?(category)
71
73
  "alchemy/#{category.singularize}".classify.constantize.trashed.blank?
72
74
  end
75
+ deprecate :trash_empty?, deprecator: Alchemy::Deprecation
73
76
 
74
77
  def set_stamper
75
78
  if Alchemy.user_class < ActiveRecord::Base
@@ -145,14 +148,6 @@ module Alchemy
145
148
  site
146
149
  end
147
150
  end
148
-
149
- def notify_error_tracker(exception)
150
- if ::Alchemy::ErrorTracking.notification_handler.respond_to?(:call)
151
- ::Alchemy::ErrorTracking.notification_handler.call(exception)
152
- else
153
- Rails.logger.warn("To use the Alchemy::ErrorTracking.notification_handler, it must respond to #call.")
154
- end
155
- end
156
151
  end
157
152
  end
158
153
  end
@@ -12,12 +12,14 @@ module Alchemy
12
12
  @page = Page.find(params[:page_id])
13
13
  @allowed_elements = @page.available_element_definitions
14
14
  end
15
+ deprecate :index, deprecator: Alchemy::Deprecation
15
16
 
16
17
  def clear
17
18
  @page = Page.find(params[:page_id])
18
19
  @elements = Element.trashed
19
20
  @elements.map(&:destroy)
20
21
  end
22
+ deprecate :clear, deprecator: Alchemy::Deprecation
21
23
 
22
24
  private
23
25
 
@@ -12,6 +12,7 @@ module Alchemy
12
12
  [
13
13
  "content_editor",
14
14
  essence_partial_name,
15
+ deprecated? ? "deprecated" : nil,
15
16
  ].compact
16
17
  end
17
18
 
@@ -51,5 +52,68 @@ module Alchemy
51
52
 
52
53
  super
53
54
  end
55
+
56
+ def has_warnings?
57
+ definition.blank? || deprecated?
58
+ end
59
+
60
+ def warnings
61
+ return unless has_warnings?
62
+
63
+ if definition.blank?
64
+ Logger.warn("Content #{name} is missing its definition", caller(1..1))
65
+ Alchemy.t(:content_definition_missing)
66
+ else
67
+ deprecation_notice
68
+ end
69
+ end
70
+
71
+ # Returns a deprecation notice for contents marked deprecated
72
+ #
73
+ # You can either use localizations or pass a String as notice
74
+ # in the content definition.
75
+ #
76
+ # == Custom deprecation notices
77
+ #
78
+ # Use general content deprecation notice
79
+ #
80
+ # - name: element_name
81
+ # contents:
82
+ # - name: old_content
83
+ # type: EssenceText
84
+ # deprecated: true
85
+ #
86
+ # Add a translation to your locale file for a per content notice.
87
+ #
88
+ # en:
89
+ # alchemy:
90
+ # content_deprecation_notices:
91
+ # element_name:
92
+ # old_content: Foo baz widget is deprecated
93
+ #
94
+ # or use the global translation that apply to all deprecated contents.
95
+ #
96
+ # en:
97
+ # alchemy:
98
+ # content_deprecation_notice: Foo baz widget is deprecated
99
+ #
100
+ # or pass string as deprecation notice.
101
+ #
102
+ # - name: element_name
103
+ # contents:
104
+ # - name: old_content
105
+ # type: EssenceText
106
+ # deprecated: This content will be removed soon.
107
+ #
108
+ def deprecation_notice
109
+ case definition["deprecated"]
110
+ when String
111
+ definition["deprecated"]
112
+ when TrueClass
113
+ Alchemy.t(name,
114
+ scope: [:content_deprecation_notices, element.name],
115
+ default: Alchemy.t(:content_deprecated))
116
+ end
117
+ end
54
118
  end
55
119
  end
@@ -8,17 +8,6 @@ module Alchemy
8
8
  "alchemy/admin/elements/element"
9
9
  end
10
10
 
11
- # Returns content editor instances for defined contents
12
- #
13
- # Creates contents on demand if the content is not yet present on the element
14
- #
15
- # @return Array<Alchemy::ContentEditor>
16
- def contents
17
- element.definition.fetch(:contents, []).map do |content|
18
- Alchemy::ContentEditor.new(find_or_create_content(content[:name]))
19
- end
20
- end
21
-
22
11
  # CSS classes for the element editor partial.
23
12
  def css_classes
24
13
  [
@@ -28,6 +17,7 @@ module Alchemy
28
17
  taggable? ? "taggable" : "not-taggable",
29
18
  folded ? "folded" : "expanded",
30
19
  compact? ? "compact" : nil,
20
+ deprecated? ? "deprecated" : nil,
31
21
  fixed? ? "is-fixed" : "not-fixed",
32
22
  public? ? "visible" : "hidden",
33
23
  ].join(" ")
@@ -88,19 +78,5 @@ module Alchemy
88
78
  default: Alchemy.t(:element_deprecated))
89
79
  end
90
80
  end
91
-
92
- private
93
-
94
- def find_or_create_content(name)
95
- find_content(name) || create_content(name)
96
- end
97
-
98
- def find_content(name)
99
- element.contents.find { |content| content.name == name }
100
- end
101
-
102
- def create_content(name)
103
- Alchemy::Content.create(element: element, name: name)
104
- end
105
81
  end
106
82
  end
@@ -19,13 +19,8 @@ module Alchemy
19
19
 
20
20
  content_name = content.name_for_label
21
21
 
22
- if content.definition.blank?
23
- warning("Content #{content.name} is missing its definition")
24
-
25
- icon = hint_with_tooltip(
26
- Alchemy.t(:content_definition_missing),
27
- )
28
-
22
+ if content.has_warnings?
23
+ icon = hint_with_tooltip(content.warnings)
29
24
  content_name = "#{icon} #{content_name}".html_safe
30
25
  end
31
26
 
@@ -39,7 +34,7 @@ module Alchemy
39
34
  # Renders the label and a remove link for a content.
40
35
  def content_label(content)
41
36
  content_tag :label, for: content.form_field_id do
42
- [render_hint_for(content), render_content_name(content)].compact.join("&nbsp;").html_safe
37
+ [render_content_name(content), render_hint_for(content)].compact.join("&nbsp;").html_safe
43
38
  end
44
39
  end
45
40
  end
@@ -28,22 +28,6 @@ module Alchemy
28
28
  # <%= render_elements from_page: 'footer' %>
29
29
  # </footer>
30
30
  #
31
- # === Fallback to elements from global page:
32
- #
33
- # You can use the fallback option as an override for elements that are stored on another page.
34
- # So you can take elements from a global page and only if the user adds an element on current page the
35
- # local one gets rendered.
36
- #
37
- # 1. You have to pass the the name of the element the fallback is for as <tt>for</tt> key.
38
- # 2. You have to pass a <tt>page_layout</tt> name or {Alchemy::Page} from where the fallback elements is taken from as <tt>from</tt> key.
39
- # 3. You can pass the name of element to fallback with as <tt>with</tt> key. This is optional (the element name from the <tt>for</tt> key is taken as default).
40
- #
41
- # <%= render_elements(fallback: {
42
- # for: 'contact_teaser',
43
- # from: 'sidebar',
44
- # with: 'contact_teaser'
45
- # }) %>
46
- #
47
31
  # === Custom elements finder:
48
32
  #
49
33
  # Having a custom element finder class:
@@ -76,8 +60,6 @@ module Alchemy
76
60
  # The amount of elements to be rendered (begins with first element found)
77
61
  # @option options [Number] :offset
78
62
  # The offset to begin loading elements from
79
- # @option options [Hash] :fallback
80
- # Define elements that are rendered from another page.
81
63
  # @option options [Boolean] :random (false)
82
64
  # Randomize the output of elements
83
65
  # @option options [Boolean] :reverse (false)
@@ -100,7 +100,7 @@ module Alchemy
100
100
 
101
101
  # Returns true if page is in the active branch
102
102
  def page_active?(page)
103
- @_page_ancestors ||= @page.self_and_ancestors.contentpages
103
+ @_page_ancestors ||= Page.ancestors_for(@page)
104
104
  @_page_ancestors.include?(page)
105
105
  end
106
106
 
@@ -28,7 +28,7 @@ module Alchemy
28
28
  after_assign { |f| write_attribute(:file_mime_type, f.mime_type) }
29
29
  end
30
30
 
31
- stampable stamper_class_name: Alchemy.user_class.name
31
+ stampable stamper_class_name: Alchemy.user_class_name
32
32
 
33
33
  has_many :essence_files, class_name: "Alchemy::EssenceFile", foreign_key: "attachment_id"
34
34
  has_many :contents, through: :essence_files
@@ -125,6 +125,10 @@ module Alchemy
125
125
  "file-alt"
126
126
  when *EXCEL_FILE_TYPES
127
127
  "file-excel"
128
+ when *POWERPOINT_FILE_TYPES
129
+ "file-powerpoint"
130
+ when *WORD_FILE_TYPES
131
+ "file-word"
128
132
  when *VCARD_FILE_TYPES
129
133
  "address-card"
130
134
  when *ARCHIVE_FILE_TYPES
@@ -46,9 +46,12 @@ module Alchemy
46
46
 
47
47
  delegate :restricted?, to: :page, allow_nil: true
48
48
  delegate :trashed?, to: :element, allow_nil: true
49
+ deprecate :trashed?, deprecator: Alchemy::Deprecation
49
50
  delegate :public?, to: :element, allow_nil: true
50
51
 
51
52
  class << self
53
+ deprecate :not_trashed, deprecator: Alchemy::Deprecation
54
+
52
55
  # Returns the translated label for a content name.
53
56
  #
54
57
  # Translate it in your locale yml file:
@@ -189,6 +192,10 @@ module Alchemy
189
192
  essence && !essence.link.blank?
190
193
  end
191
194
 
195
+ def deprecated?
196
+ !!definition["deprecated"]
197
+ end
198
+
192
199
  # Returns true if this content should be taken for element preview.
193
200
  def preview_content?
194
201
  !!definition["as_element_title"]
@@ -13,41 +13,24 @@ module Alchemy
13
13
  # your own set of elements
14
14
  #
15
15
  def definitions
16
- @definitions ||= read_definitions_file.map(&:with_indifferent_access)
16
+ ElementDefinition.all
17
17
  end
18
18
 
19
19
  # Returns one element definition by given name.
20
20
  #
21
21
  def definition_by_name(name)
22
- definitions.detect { |d| d["name"] == name }
23
- end
24
-
25
- private
26
-
27
- # Reads the element definitions file named +elements.yml+ from +config/alchemy/+ folder.
28
- #
29
- def read_definitions_file
30
- if ::File.exist?(definitions_file_path)
31
- ::YAML.safe_load(ERB.new(File.read(definitions_file_path)).result, YAML_WHITELIST_CLASSES, [], true) || []
32
- else
33
- raise LoadError, "Could not find elements.yml file! Please run `rails generate alchemy:install`"
34
- end
35
- end
36
-
37
- # Returns the +elements.yml+ file path
38
- #
39
- def definitions_file_path
40
- Rails.root.join "config/alchemy/elements.yml"
22
+ ElementDefinition.get(name)
41
23
  end
42
24
  end
43
25
 
44
26
  # The definition of this element.
45
27
  #
46
28
  def definition
47
- if definition = self.class.definitions.detect { |d| d["name"] == name }
29
+ if definition = self.class.definition_by_name(name)
48
30
  definition
49
31
  else
50
- log_warning "Could not find element definition for #{name}. Please check your elements.yml file!"
32
+ log_warning "Could not find element definition for #{name}. " \
33
+ "Please check your elements.yml file!"
51
34
  {}
52
35
  end
53
36
  end