alchemy_cms 4.5.1 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +11 -14
  3. data/.rubocop.yml +7 -15
  4. data/CHANGELOG.md +18 -8
  5. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +5 -5
  6. data/app/assets/javascripts/alchemy/templates/page.hbs +1 -1
  7. data/app/assets/stylesheets/alchemy/_mixins.scss +2 -3
  8. data/app/assets/stylesheets/alchemy/_variables.scss +2 -2
  9. data/app/assets/stylesheets/alchemy/lists.scss +0 -8
  10. data/app/assets/stylesheets/alchemy/nodes.scss +1 -1
  11. data/app/assets/stylesheets/alchemy/sitemap.scss +59 -21
  12. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +6 -6
  13. data/app/controllers/alchemy/admin/pages_controller.rb +0 -1
  14. data/app/controllers/alchemy/api/pages_controller.rb +2 -0
  15. data/app/decorators/alchemy/content_editor.rb +55 -0
  16. data/app/helpers/alchemy/admin/pages_helper.rb +16 -16
  17. data/app/models/alchemy/attachment.rb +1 -1
  18. data/app/models/alchemy/content.rb +9 -23
  19. data/app/models/alchemy/element.rb +1 -1
  20. data/app/models/alchemy/node.rb +9 -8
  21. data/app/models/alchemy/page/url_path.rb +66 -0
  22. data/app/models/alchemy/page.rb +12 -1
  23. data/app/models/alchemy/picture.rb +1 -1
  24. data/app/serializers/alchemy/page_serializer.rb +2 -1
  25. data/app/serializers/alchemy/page_tree_serializer.rb +4 -3
  26. data/app/views/alchemy/admin/layoutpages/index.html.erb +5 -1
  27. data/app/views/alchemy/admin/nodes/_form.html.erb +2 -2
  28. data/app/views/alchemy/admin/pages/_form.html.erb +1 -1
  29. data/app/views/alchemy/admin/pages/_menu_fields.html.erb +33 -29
  30. data/app/views/alchemy/admin/pages/_page.html.erb +3 -6
  31. data/app/views/alchemy/admin/pages/_sitemap.html.erb +6 -0
  32. data/app/views/alchemy/admin/pages/info.html.erb +1 -1
  33. data/config/alchemy/config.yml +0 -6
  34. data/config/locales/alchemy.en.yml +6 -6
  35. data/lib/alchemy/config.rb +30 -2
  36. data/lib/alchemy/essence.rb +1 -1
  37. data/lib/alchemy/resource.rb +4 -6
  38. data/lib/alchemy/ssl_protection.rb +3 -1
  39. data/lib/alchemy/upgrader/four_point_six.rb +50 -0
  40. data/lib/alchemy/upgrader/four_point_two.rb +0 -1
  41. data/lib/alchemy/upgrader/tasks/cells_migration.rb +1 -2
  42. data/lib/alchemy/upgrader/tasks/cells_upgrader.rb +3 -21
  43. data/lib/alchemy/upgrader/tasks/element_partial_name_variable_updater.rb +4 -8
  44. data/lib/alchemy/userstamp.rb +1 -1
  45. data/lib/alchemy/version.rb +1 -1
  46. data/lib/tasks/alchemy/convert.rake +2 -0
  47. data/lib/tasks/alchemy/upgrade.rake +67 -46
  48. metadata +8 -6
  49. data/lib/alchemy/upgrader/tasks/fixed_element_name_finder.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f640cf9df17528d45476a6edb303f9d4d3fadc0e78f6bb8bbbe0a0b79f57059
4
- data.tar.gz: '09d6e935c44b7fede23439298f68ee9055118bd6b0a645a2294ad05161271a8e'
3
+ metadata.gz: f321858feead1aacab75385da9c01e7a8db1018adaf2e5f2ccb714be4c8edf44
4
+ data.tar.gz: 68ae5e042e449693217ab9390a04b5a6bab6d6810011e1c0aaaf8c3f80065f43
5
5
  SHA512:
6
- metadata.gz: 9975ccf31bd9e74791149c2426e6dbf350d6cb4df000018bcba509f9bed88c23808e8fc0a2f690bfcb791c550384fd3d18c9f1f73b3a08115b5251efae2a3559
7
- data.tar.gz: a315453502650bbddf31e4c60cf1ff1abf7797b2ed9a8d12a502cfc02e91bb2fde457ede616769a06ce9f2cc805a6ad5bc252bc90003a5894daa1a9c0d95f252
6
+ metadata.gz: 78af2956df792c714818a8cdf91b3e3d87afa53c62617dd2d373eb168ce0bcc62c561f1a1343cb1ee9515f827a45e671330d1622abac789cdcff27b1658d1a8e
7
+ data.tar.gz: 54995595358bd0692c01892f4c1fc2691725f0e89846483c2d23bb519304e90177997ef61f4fb37e760100e10baf28dc4d8a3664ff1a9e4c431e64f2ce2bc5da
@@ -42,7 +42,7 @@ jobs:
42
42
  MYSQL_PASSWORD: password
43
43
  MYSQL_DATABASE: alchemy_cms_dummy_test
44
44
  MYSQL_ROOT_PASSWORD: password
45
- options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
45
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
46
46
  steps:
47
47
  - uses: actions/checkout@v1
48
48
  - name: Set up Ruby
@@ -61,15 +61,15 @@ jobs:
61
61
  if: matrix.database == 'postgresql'
62
62
  run: |
63
63
  mkdir -p /home/runner/apt/cache
64
- sudo apt-get update -qq
65
- sudo apt-get install -qq --fix-missing libpq-dev -o dir::cache::archives="/home/runner/apt/cache"
64
+ sudo apt update -qq
65
+ sudo apt install -qq --fix-missing libpq-dev -o dir::cache::archives="/home/runner/apt/cache"
66
66
  sudo chown -R runner /home/runner/apt/cache
67
67
  - name: Install MySQL headers
68
68
  if: matrix.database == 'mysql'
69
69
  run: |
70
70
  mkdir -p /home/runner/apt/cache
71
- sudo apt-get update -qq
72
- sudo apt-get install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache"
71
+ sudo apt update -qq
72
+ sudo apt install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache"
73
73
  sudo chown -R runner /home/runner/apt/cache
74
74
  - name: Install bundler
75
75
  run: |
@@ -89,15 +89,12 @@ jobs:
89
89
  - name: Prepare database
90
90
  run: |
91
91
  bundle exec rake alchemy:spec:prepare
92
- - name: Install code climate test reporter
93
- run: |
94
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
95
- chmod +x ./cc-test-reporter
96
- ./cc-test-reporter before-build
97
- - name: Test with RSpec
98
- run: |
99
- bundle exec rspec
100
- ./cc-test-reporter after-build --exit-code $?
92
+ - name: Run tests & publish code coverage
93
+ uses: paambaati/codeclimate-action@v2.5.7
94
+ env:
95
+ CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
96
+ with:
97
+ coverageCommand: bundle exec rspec
101
98
  - uses: actions/upload-artifact@master
102
99
  if: failure()
103
100
  with:
data/.rubocop.yml CHANGED
@@ -9,17 +9,12 @@ AllCops:
9
9
  - 'alchemy_cms.gemspec'
10
10
  - 'Rakefile'
11
11
 
12
- TargetRubyVersion: 2.3
12
+ TargetRubyVersion: 2.4
13
13
 
14
14
  # Really, rubocop?
15
15
  Bundler/OrderedGems:
16
16
  Enabled: false
17
17
 
18
- # Sometimes I believe this reads better
19
- # This also causes spacing issues on multi-line fixes
20
- Style/BracesAroundHashParameters:
21
- Enabled: false
22
-
23
18
  Style/EmptyLiteral:
24
19
  Enabled: false
25
20
 
@@ -55,13 +50,10 @@ Style/MixinUsage:
55
50
  Exclude:
56
51
  - spec/**/*
57
52
 
58
- Performance/Count:
59
- Enabled: false
60
-
61
- Layout/AlignHash:
53
+ Layout/HashAlignment:
62
54
  Enabled: false
63
55
 
64
- Layout/AlignParameters:
56
+ Layout/ParameterAlignment:
65
57
  Enabled: false
66
58
 
67
59
  Layout/ClosingParenthesisIndentation:
@@ -77,13 +69,13 @@ Layout/ElseAlignment:
77
69
  Layout/EmptyLineAfterMagicComment:
78
70
  Enabled: false
79
71
 
80
- Layout/IndentArray:
72
+ Layout/FirstArrayElementIndentation:
81
73
  Enabled: false
82
74
 
83
- Layout/IndentHash:
75
+ Layout/FirstHashElementIndentation:
84
76
  Enabled: false
85
77
 
86
- Layout/IndentHeredoc:
78
+ Layout/HeredocIndentation:
87
79
  EnforcedStyle: active_support
88
80
 
89
81
  Layout/IndentationWidth:
@@ -115,7 +107,7 @@ Layout/SpaceInsideParens:
115
107
  Layout/EndAlignment:
116
108
  Enabled: false
117
109
 
118
- Lint/HandleExceptions:
110
+ Lint/SuppressedException:
119
111
  Exclude:
120
112
  - 'config/initializers/mini_profiler.rb'
121
113
 
data/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
- ## 4.5.1 (2021-11-17)
2
-
3
- - Set stampable user_class_name without root identifier ([tvdeyen](https://github.com/tvdeyen))
4
- - Use relative path for tinymce font-face ([tvdeyen](https://github.com/tvdeyen))
5
- - Use symbols in polymorphic routes for resources ([tvdeyen](https://github.com/tvdeyen))
6
- - make the fixed element upgrader more robust ([darkswoop](https://github.com/darkswoop))
7
- - don't use existing element names when migrating from cells ([darkswoop](https://github.com/darkswoop))
8
- - enhance regexp in partial name upgrader ([darkswoop](https://github.com/darkswoop))
1
+ ## 5.0.0 (unreleased)
2
+
3
+ ## 4.6.0 (2020-06-04)
4
+
5
+ - Use apt update instead of apt-get in GH action [#1865](https://github.com/AlchemyCMS/alchemy_cms/pull/1865) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Use depth for page tree serializer root_or_leaf [#1864](https://github.com/AlchemyCMS/alchemy_cms/pull/1864) ([tvdeyen](https://github.com/tvdeyen))
7
+ - Fix sitemap wrapper height [#1861](https://github.com/AlchemyCMS/alchemy_cms/pull/1861) ([tvdeyen](https://github.com/tvdeyen))
8
+ - Do not return the root page with API responses. [#1860](https://github.com/AlchemyCMS/alchemy_cms/pull/1860) ([tvdeyen](https://github.com/tvdeyen))
9
+ - Introduce page.url_path and use it for alchemyPageSelect [#1859](https://github.com/AlchemyCMS/alchemy_cms/pull/1859) ([tvdeyen](https://github.com/tvdeyen))
10
+ - Update Urlname translation [#1857](https://github.com/AlchemyCMS/alchemy_cms/pull/1857) ([tvdeyen](https://github.com/tvdeyen))
11
+ - Show url name in Page tree [#1856](https://github.com/AlchemyCMS/alchemy_cms/pull/1856) ([tvdeyen](https://github.com/tvdeyen))
12
+ - Deprecate Page#visible attribute [#1855](https://github.com/AlchemyCMS/alchemy_cms/pull/1855) ([tvdeyen](https://github.com/tvdeyen))
13
+ - 4.6: Re-add `auto_logout_time` configuration option [#1852](https://github.com/AlchemyCMS/alchemy_cms/pull/1852) ([mamhoff](https://github.com/mamhoff))
14
+ - Backport ContentEditor to 4.6, deprecate removed methods on `Alchemy::Content` [#1847](https://github.com/AlchemyCMS/alchemy_cms/pull/1847) ([mamhoff](https://github.com/mamhoff))
15
+ - Deprecate auto_logout_time (4.6) [#1843](https://github.com/AlchemyCMS/alchemy_cms/pull/1843) ([tvdeyen](https://github.com/tvdeyen))
16
+ - Deprecate require_ssl (4.6) [#1842](https://github.com/AlchemyCMS/alchemy_cms/pull/1842) ([tvdeyen](https://github.com/tvdeyen))
17
+ - Deprecate url_nesting configuration (4.6) [#1841](https://github.com/AlchemyCMS/alchemy_cms/pull/1841) ([tvdeyen](https://github.com/tvdeyen))
18
+ - Allow page visible toggle (4.6) [#1838](https://github.com/AlchemyCMS/alchemy_cms/pull/1838) ([tvdeyen](https://github.com/tvdeyen))
9
19
 
10
20
  ## 4.5.0 (2020-03-30)
11
21
 
@@ -76,16 +76,16 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
76
76
  meta = data.meta
77
77
  results:
78
78
  data.pages.map (page) ->
79
- id: "/#{page.urlname}"
79
+ id: page.url_path
80
80
  name: page.name
81
- urlname: page.urlname
81
+ url_path: page.url_path
82
82
  page_id: page.id
83
83
  more: meta.page * meta.per_page < meta.total_count
84
84
  initSelection: ($element, callback) =>
85
85
  urlname = $element.val()
86
86
  $.get Alchemy.routes.api_pages_path,
87
87
  q:
88
- urlname_eq: urlname.replace(/^\//, '')
88
+ urlname_eq: urlname.replace(/^\/([a-z]{2}(-[A-Z]{2})?\/)?/, '')
89
89
  page: 1
90
90
  per_page: 1,
91
91
  (data) =>
@@ -93,9 +93,9 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
93
93
  if page
94
94
  @initElementSelect(page.id)
95
95
  callback
96
- id: "/#{page.urlname}"
96
+ id: page.url_path
97
97
  name: page.name
98
- urlname: page.name
98
+ url_path: page.url_path
99
99
  page_id: page.id
100
100
  formatSelection: (page) ->
101
101
  page.name
@@ -4,6 +4,6 @@
4
4
  {{ page.name }}
5
5
  </span>
6
6
  <span class="page-select--page-urlname">
7
- /{{ page.urlname }}
7
+ {{ page.url_path }}
8
8
  </span>
9
9
  </div>
@@ -49,9 +49,8 @@
49
49
  border-color: $hover-border-color;
50
50
  }
51
51
 
52
- &:active, &:active:focus {
53
- border-color: $hover-border-color;
54
- box-shadow: none;
52
+ &:active, &.active {
53
+ box-shadow: inset $button-box-shadow;
55
54
  }
56
55
 
57
56
  &:focus {
@@ -76,7 +76,7 @@ $button-text-shadow: none !default;
76
76
  $button-box-shadow: 0px 1px 1px -1px #333 !default;
77
77
  $button-focus-box-shadow: 0px 1px 1px 0px $button-focus-border-color !default;
78
78
  $button-padding: 0.55em 2em !default;
79
- $small-button-padding: 0.4em 1.25em !default;
79
+ $small-button-padding: 0.4em 0.8em !default;
80
80
  $button-margin: $form-field-margin !default;
81
81
 
82
82
  $secondary-button-bg-color: transparent !default;
@@ -108,7 +108,7 @@ $form-right-width: 65% !default;
108
108
  $sitemap-line-height: 32px !default;
109
109
  $sitemap-page-background-color: rgba($white, 0.75) !default;
110
110
  $sitemap-page-hover-color: rgba($light_yellow, 0.5) !default;
111
- $sitemap-info-background-color: rgba($linked-color, 0.5) !default;
111
+ $sitemap-info-background-color: rgba($white, 0.5) !default;
112
112
  $sitemap-highlight-color: rgba(#fffba5, 0.5) !default;
113
113
 
114
114
  $main-menu-width: 150px !default;
@@ -13,14 +13,6 @@ ul.list {
13
13
  padding: 0;
14
14
  list-style-type: none;
15
15
 
16
- &#layoutpages {
17
- margin-top: 16px;
18
-
19
- li {
20
- margin-left: 8px;
21
- }
22
- }
23
-
24
16
  li {
25
17
  list-style-type: none;
26
18
  display: block;
@@ -18,7 +18,7 @@
18
18
 
19
19
  .node_page,
20
20
  .node_url {
21
- width: 200px;
21
+ width: 250px;
22
22
  max-width: 45%;
23
23
  white-space: nowrap;
24
24
  text-overflow: ellipsis;
@@ -1,3 +1,6 @@
1
+ $sitemap-url-large-width: 250px;
2
+ $sitemap-url-xlarge-width: 350px;
3
+
1
4
  #sort_panel {
2
5
  background: $light-gray;
3
6
  padding: 47px 0 8px 0;
@@ -20,7 +23,7 @@
20
23
 
21
24
  #sitemap-wrapper {
22
25
  position: relative;
23
- min-height: 100%;
26
+ min-height: calc(100vh - 96px);
24
27
  }
25
28
 
26
29
  .sitemap_pagename_link {
@@ -28,23 +31,35 @@
28
31
  padding: 0 10px;
29
32
  margin: 2px;
30
33
  text-decoration: none;
34
+ white-space: nowrap;
35
+ text-overflow: ellipsis;
36
+ overflow: hidden;
31
37
 
32
38
  &.inactive {
33
39
  color: #656565;
34
40
  }
35
41
  }
36
42
 
37
- .redirect_url {
43
+ .sitemap_url {
44
+ display: none;
38
45
  float: right;
39
- text-align: right;
40
46
  background-color: $sitemap-info-background-color;
41
- line-height: $sitemap-line-height;
47
+ line-height: $sitemap-line-height - 2px;
42
48
  font-size: $small-font-size;
43
- padding: 0 2*$default-padding;
44
- max-width: 45%;
49
+ padding: 0 2 * $default-padding;
45
50
  white-space: nowrap;
46
51
  overflow: hidden;
47
52
  text-overflow: ellipsis;
53
+ border: 1px solid $sitemap-page-background-color;
54
+
55
+ @media screen and (min-width: $large-screen-break-point) {
56
+ display: block;
57
+ width: $sitemap-url-large-width;
58
+ }
59
+
60
+ @media screen and (min-width: 1440px) {
61
+ width: $sitemap-url-xlarge-width;
62
+ }
48
63
  }
49
64
 
50
65
  .sitemap_line_spacer {
@@ -55,7 +70,7 @@
55
70
 
56
71
  .sitemap_page {
57
72
  height: $sitemap-line-height;
58
- margin: 3*$default-margin 0;
73
+ margin: 3 * $default-margin 0;
59
74
  position: relative;
60
75
  transition: background-color $transition-duration;
61
76
 
@@ -89,13 +104,13 @@
89
104
  width: 32px;
90
105
  line-height: $sitemap-line-height;
91
106
  float: left;
92
- padding: 0 2*$default-padding;
107
+ padding: 0 2 * $default-padding;
93
108
  text-align: center;
94
109
  }
95
110
 
96
111
  .sitemap_right_tools {
97
112
  height: $sitemap-line-height;
98
- padding: 0 2*$default-padding;
113
+ padding: 0 2 * $default-padding;
99
114
  float: right;
100
115
 
101
116
  .sitemap_tool {
@@ -130,7 +145,9 @@
130
145
  &.sorting {
131
146
  padding-top: 100px;
132
147
 
133
- .page_icon { cursor: move }
148
+ .page_icon {
149
+ cursor: move;
150
+ }
134
151
  }
135
152
 
136
153
  .page_folder {
@@ -183,25 +200,44 @@
183
200
  }
184
201
 
185
202
  #sitemap_heading {
203
+ display: flex;
186
204
  padding: 0;
187
-
188
- .page_infos {
189
- margin-right: 210px;
190
- text-align: left;
191
- float: right;
192
- line-height: 28px;
193
- background: transparent;
194
- }
205
+ line-height: 28px;
195
206
 
196
207
  .page_name {
197
- line-height: 28px;
198
208
  margin-left: 43px;
199
209
  }
210
+
211
+ .page_urlname {
212
+ display: none;
213
+ margin-left: auto;
214
+ padding-left: 2 * $default-padding;
215
+ padding-right: 2 * $default-padding;
216
+
217
+ @media screen and (min-width: $large-screen-break-point) {
218
+ display: block;
219
+ width: $sitemap-url-large-width;
220
+ }
221
+
222
+ @media screen and (min-width: 1440px) {
223
+ width: $sitemap-url-xlarge-width;
224
+ }
225
+ }
226
+
227
+ .page_status {
228
+ padding-left: 2 * $default-padding;
229
+ margin-right: 214px;
230
+ margin-left: auto;
231
+
232
+ @media screen and (min-width: $large-screen-break-point) {
233
+ margin-left: initial;
234
+ }
235
+ }
200
236
  }
201
237
 
202
238
  #page_filter_result {
203
239
  display: none;
204
- margin-left: 2*$default-margin;
240
+ margin-left: 2 * $default-margin;
205
241
  }
206
242
 
207
243
  .alchemy-dialog {
@@ -213,6 +249,8 @@
213
249
  margin: 0;
214
250
  padding: 0 24px 8px 8px;
215
251
 
216
- .page_icon { cursor: default }
252
+ .page_icon {
253
+ cursor: default;
254
+ }
217
255
  }
218
256
  }
@@ -1566,18 +1566,18 @@ i.mce-i-resize {
1566
1566
 
1567
1567
  @font-face {
1568
1568
  font-family: 'tinymce';
1569
- src: url('./fonts/tinymce.woff') format('woff'),
1570
- url('./fonts/tinymce.ttf') format('truetype'),
1571
- url('./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('./fonts/tinymce-small.woff') format('woff'),
1579
- url('./fonts/tinymce-small.ttf') format('truetype'),
1580
- url('./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
  }
@@ -142,7 +142,6 @@ module Alchemy
142
142
  @attachments = Attachment.all.collect { |f|
143
143
  [f.name, download_attachment_path(id: f.id, name: f.urlname)]
144
144
  }
145
- @url_prefix = prefix_locale? ? "#{Language.current.code}/" : ""
146
145
  end
147
146
 
148
147
  def fold
@@ -13,6 +13,7 @@ module Alchemy
13
13
  else
14
14
  @pages = Page.accessible_by(current_ability, :index)
15
15
  end
16
+ @pages = @pages.where.not(parent_id: nil)
16
17
  @pages = @pages.includes(*page_includes)
17
18
  if params[:page_layout].present?
18
19
  Alchemy::Deprecation.warn <<~WARN
@@ -104,6 +105,7 @@ module Alchemy
104
105
  [
105
106
  :tags,
106
107
  {
108
+ language: :site,
107
109
  elements: [
108
110
  {
109
111
  nested_elements: [
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ class ContentEditor < SimpleDelegator
5
+ alias_method :content, :__getobj__
6
+
7
+ def to_partial_path
8
+ "alchemy/essences/#{essence_partial_name}_editor"
9
+ end
10
+
11
+ def css_classes
12
+ [
13
+ "content_editor",
14
+ essence_partial_name,
15
+ ].compact
16
+ end
17
+
18
+ def data_attributes
19
+ {
20
+ content_id: id,
21
+ content_name: name,
22
+ }
23
+ end
24
+
25
+ # Returns a string to be passed to Rails form field tags to ensure we have same params layout everywhere.
26
+ #
27
+ # === Example:
28
+ #
29
+ # <%= text_field_tag content_editor.form_field_name, content_editor.ingredient %>
30
+ #
31
+ # === Options:
32
+ #
33
+ # You can pass an Essence column_name. Default is 'ingredient'
34
+ #
35
+ # ==== Example:
36
+ #
37
+ # <%= text_field_tag content_editor.form_field_name(:link), content_editor.ingredient %>
38
+ #
39
+ def form_field_name(essence_column = "ingredient")
40
+ "contents[#{id}][#{essence_column}]"
41
+ end
42
+
43
+ def form_field_id(essence_column = "ingredient")
44
+ "contents_#{id}_#{essence_column}"
45
+ end
46
+
47
+ # Fixes Rails partial renderer calling to_model on the object
48
+ # which reveals the delegated content instead of this decorator.
49
+ def respond_to?(method_name)
50
+ return false if method_name == :to_model
51
+
52
+ super
53
+ end
54
+ end
55
+ end
@@ -9,13 +9,13 @@ module Alchemy
9
9
  #
10
10
  def preview_sizes_for_select
11
11
  options_for_select([
12
- 'auto',
13
- [Alchemy.t('240', scope: 'preview_sizes'), 240],
14
- [Alchemy.t('320', scope: 'preview_sizes'), 320],
15
- [Alchemy.t('480', scope: 'preview_sizes'), 480],
16
- [Alchemy.t('768', scope: 'preview_sizes'), 768],
17
- [Alchemy.t('1024', scope: 'preview_sizes'), 1024],
18
- [Alchemy.t('1280', scope: 'preview_sizes'), 1280]
12
+ "auto",
13
+ [Alchemy.t("240", scope: "preview_sizes"), 240],
14
+ [Alchemy.t("320", scope: "preview_sizes"), 320],
15
+ [Alchemy.t("480", scope: "preview_sizes"), 480],
16
+ [Alchemy.t("768", scope: "preview_sizes"), 768],
17
+ [Alchemy.t("1024", scope: "preview_sizes"), 1024],
18
+ [Alchemy.t("1280", scope: "preview_sizes"), 1280],
19
19
  ])
20
20
  end
21
21
 
@@ -27,30 +27,30 @@ module Alchemy
27
27
  if page.persisted? && page.definition.blank?
28
28
  [
29
29
  page_layout_missing_warning,
30
- Alchemy.t(:page_type)
31
- ].join('&nbsp;').html_safe
30
+ Alchemy.t(:page_type),
31
+ ].join("&nbsp;").html_safe
32
32
  else
33
33
  Alchemy.t(:page_type)
34
34
  end
35
35
  end
36
36
 
37
- def page_status_checkbox(page, attribute)
38
- label = page.class.human_attribute_name(attribute)
37
+ def page_status_checkbox(page, attribute, label: nil)
38
+ label_text = label || page.class.human_attribute_name(attribute)
39
39
 
40
40
  if page.attribute_fixed?(attribute)
41
41
  checkbox = check_box(:page, attribute, disabled: true)
42
- hint = content_tag(:span, class: 'hint-bubble') do
42
+ hint = content_tag(:span, class: "hint-bubble") do
43
43
  Alchemy.t(:attribute_fixed, attribute: attribute)
44
44
  end
45
- content = content_tag(:span, class: 'with-hint') do
46
- "#{checkbox}\n#{label}\n#{hint}".html_safe
45
+ content = content_tag(:span, class: "with-hint") do
46
+ "#{checkbox}\n#{label_text}\n#{hint}".html_safe
47
47
  end
48
48
  else
49
49
  checkbox = check_box(:page, attribute)
50
- content = "#{checkbox}\n#{label}".html_safe
50
+ content = "#{checkbox}\n#{label_text}".html_safe
51
51
  end
52
52
 
53
- content_tag(:label, class: 'checkbox') { content }
53
+ content_tag(:label, class: "checkbox") { content }
54
54
  end
55
55
  end
56
56
  end
@@ -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
@@ -28,7 +28,7 @@ module Alchemy
28
28
  belongs_to :element, touch: true, inverse_of: :contents
29
29
  has_one :page, through: :element
30
30
 
31
- stampable stamper_class_name: Alchemy.user_class.name
31
+ stampable stamper_class_name: Alchemy.user_class_name
32
32
 
33
33
  acts_as_list scope: [:element_id]
34
34
 
@@ -172,28 +172,6 @@ module Alchemy
172
172
  definition['validate'].present?
173
173
  end
174
174
 
175
- # Returns a string to be passed to Rails form field tags to ensure we have same params layout everywhere.
176
- #
177
- # === Example:
178
- #
179
- # <%= text_field_tag content.form_field_name, content.ingredient %>
180
- #
181
- # === Options:
182
- #
183
- # You can pass an Essence column_name. Default is 'ingredient'
184
- #
185
- # ==== Example:
186
- #
187
- # <%= text_field_tag content.form_field_name(:link), content.ingredient %>
188
- #
189
- def form_field_name(essence_column = 'ingredient')
190
- "contents[#{id}][#{essence_column}]"
191
- end
192
-
193
- def form_field_id(essence_column = 'ingredient')
194
- "contents_#{id}_#{essence_column}"
195
- end
196
-
197
175
  # Returns a string used as dom id on html elements.
198
176
  def dom_id
199
177
  return '' if essence.nil?
@@ -245,6 +223,14 @@ module Alchemy
245
223
  "has_tinymce" + (has_custom_tinymce_config? ? " #{element.name}_#{name}" : "")
246
224
  end
247
225
 
226
+ def editor
227
+ @_editor ||= ContentEditor.new(self)
228
+ end
229
+ delegate :form_field_name, to: :editor
230
+ deprecate form_field_name: "use Alchemy::ContentEditor#form_field_name instead", deprecator: Alchemy::Deprecation
231
+ delegate :form_field_id, to: :editor
232
+ deprecate form_field_id: "use Alchemy::ContentEditor#form_field_id instead", deprecator: Alchemy::Deprecation
233
+
248
234
  # Returns the default value from content definition
249
235
  #
250
236
  # If the value is a symbol it gets passed through i18n
@@ -58,7 +58,7 @@ module Alchemy
58
58
  #
59
59
  acts_as_list scope: [:page_id, :fixed, :parent_element_id]
60
60
 
61
- stampable stamper_class_name: Alchemy.user_class.name
61
+ stampable stamper_class_name: Alchemy.user_class_name
62
62
 
63
63
  has_many :contents, -> { order(:position) }, dependent: :destroy, inverse_of: :element
64
64