alchemy_cms 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  3. data/.github/workflows/ci.yml +126 -0
  4. data/.github/workflows/stale.yml +1 -1
  5. data/.gitignore +1 -0
  6. data/CHANGELOG.md +66 -2
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +2 -2
  9. data/README.md +2 -2
  10. data/alchemy_cms.gemspec +3 -3
  11. data/app/assets/images/alchemy/missing-image.svg +1 -0
  12. data/app/assets/javascripts/alchemy/admin.js +0 -1
  13. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +1 -4
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js.coffee +0 -3
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +29 -4
  16. data/app/assets/stylesheets/alchemy/_variables.scss +8 -0
  17. data/app/assets/stylesheets/alchemy/admin.scss +0 -1
  18. data/app/assets/stylesheets/alchemy/archive.scss +23 -17
  19. data/app/assets/stylesheets/alchemy/buttons.scss +26 -15
  20. data/app/assets/stylesheets/alchemy/elements.scss +58 -19
  21. data/app/assets/stylesheets/alchemy/errors.scss +1 -1
  22. data/app/assets/stylesheets/alchemy/frame.scss +0 -1
  23. data/app/assets/stylesheets/alchemy/hints.scss +2 -1
  24. data/app/assets/stylesheets/alchemy/navigation.scss +7 -10
  25. data/app/assets/stylesheets/alchemy/pagination.scss +1 -1
  26. data/app/assets/stylesheets/alchemy/search.scss +13 -3
  27. data/app/assets/stylesheets/alchemy/selects.scss +26 -20
  28. data/app/assets/stylesheets/alchemy/tables.scss +38 -9
  29. data/app/assets/stylesheets/alchemy/tags.scss +19 -31
  30. data/app/controllers/alchemy/admin/pages_controller.rb +58 -8
  31. data/app/controllers/alchemy/admin/pictures_controller.rb +13 -6
  32. data/app/controllers/alchemy/admin/resources_controller.rb +3 -3
  33. data/app/controllers/alchemy/pages_controller.rb +49 -14
  34. data/app/decorators/alchemy/element_editor.rb +1 -0
  35. data/app/helpers/alchemy/admin/base_helper.rb +0 -44
  36. data/app/helpers/alchemy/admin/navigation_helper.rb +2 -1
  37. data/app/models/alchemy/attachment.rb +20 -3
  38. data/app/models/alchemy/attachment/url.rb +40 -0
  39. data/app/models/alchemy/essence_picture.rb +3 -3
  40. data/app/models/alchemy/essence_picture_view.rb +5 -3
  41. data/app/models/alchemy/legacy_page_url.rb +1 -1
  42. data/app/models/alchemy/page.rb +24 -1
  43. data/app/models/alchemy/page/page_natures.rb +2 -0
  44. data/app/models/alchemy/page/url_path.rb +8 -6
  45. data/app/models/alchemy/picture.rb +58 -2
  46. data/app/models/alchemy/picture/calculations.rb +55 -0
  47. data/app/models/alchemy/picture/transformations.rb +5 -49
  48. data/app/models/alchemy/picture/url.rb +28 -77
  49. data/app/models/alchemy/picture_thumb.rb +57 -0
  50. data/app/models/alchemy/picture_thumb/create.rb +39 -0
  51. data/app/models/alchemy/picture_thumb/signature.rb +23 -0
  52. data/app/models/alchemy/picture_thumb/uid.rb +22 -0
  53. data/app/models/alchemy/picture_variant.rb +114 -0
  54. data/app/models/alchemy/site/layout.rb +30 -2
  55. data/app/serializers/alchemy/page_tree_serializer.rb +4 -4
  56. data/app/views/alchemy/admin/attachments/show.html.erb +8 -8
  57. data/app/views/alchemy/admin/dashboard/index.html.erb +13 -16
  58. data/app/views/alchemy/admin/elements/_element_footer.html.erb +1 -1
  59. data/app/views/alchemy/admin/elements/publish.js.erb +1 -0
  60. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  61. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  62. data/app/views/alchemy/admin/layoutpages/edit.html.erb +4 -6
  63. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +19 -29
  64. data/app/views/alchemy/admin/pages/_form.html.erb +4 -6
  65. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +12 -2
  66. data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +29 -0
  67. data/app/views/alchemy/admin/pages/_table.html.erb +27 -0
  68. data/app/views/alchemy/admin/pages/_table_row.html.erb +107 -0
  69. data/app/views/alchemy/admin/pages/_toolbar.html.erb +77 -0
  70. data/app/views/alchemy/admin/pages/edit.html.erb +9 -1
  71. data/app/views/alchemy/admin/pages/index.html.erb +41 -74
  72. data/app/views/alchemy/admin/pages/list/_table.html.erb +31 -0
  73. data/app/views/alchemy/admin/pages/unlock.js.erb +2 -2
  74. data/app/views/alchemy/admin/pages/update.js.erb +19 -10
  75. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +14 -13
  76. data/app/views/alchemy/admin/partials/_search_form.html.erb +8 -8
  77. data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
  78. data/app/views/alchemy/admin/pictures/_form.html.erb +1 -1
  79. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -3
  80. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  81. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +1 -1
  82. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  83. data/app/views/alchemy/admin/pictures/show.html.erb +3 -3
  84. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +13 -11
  85. data/app/views/alchemy/admin/resources/_per_page_select.html.erb +3 -3
  86. data/app/views/alchemy/admin/resources/index.html.erb +4 -1
  87. data/app/views/alchemy/admin/tags/index.html.erb +14 -15
  88. data/app/views/alchemy/base/500.html.erb +11 -13
  89. data/app/views/alchemy/essences/_essence_file_view.html.erb +3 -3
  90. data/config/alchemy/config.yml +15 -11
  91. data/config/alchemy/modules.yml +12 -12
  92. data/config/locales/alchemy.en.yml +6 -4
  93. data/config/routes.rb +1 -1
  94. data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +22 -0
  95. data/db/migrate/20200907111332_remove_tri_state_booleans.rb +33 -0
  96. data/lib/alchemy.rb +66 -0
  97. data/lib/alchemy/admin/preview_url.rb +2 -0
  98. data/lib/alchemy/auth_accessors.rb +12 -5
  99. data/lib/alchemy/config.rb +1 -3
  100. data/lib/alchemy/engine.rb +7 -6
  101. data/lib/alchemy/modules.rb +11 -1
  102. data/lib/alchemy/permissions.rb +1 -0
  103. data/lib/alchemy/test_support/factories/picture_factory.rb +0 -1
  104. data/lib/alchemy/test_support/factories/picture_thumb_factory.rb +12 -0
  105. data/lib/alchemy/test_support/integration_helpers.rb +0 -7
  106. data/lib/alchemy/version.rb +1 -1
  107. data/lib/alchemy_cms.rb +2 -4
  108. data/lib/generators/alchemy/install/files/alchemy.en.yml +2 -2
  109. data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +5 -5
  110. data/lib/tasks/alchemy/thumbnails.rake +37 -0
  111. data/vendor/assets/javascripts/jquery_plugins/select2.js +3729 -0
  112. data/vendor/assets/stylesheets/alchemy_admin/select2.scss +740 -0
  113. metadata +46 -37
  114. data/.github/workflows/greetings.yml +0 -13
  115. data/.travis.yml +0 -48
  116. data/app/controllers/concerns/alchemy/locale_redirects.rb +0 -40
  117. data/app/controllers/concerns/alchemy/page_redirects.rb +0 -68
  118. data/lib/alchemy/userstamp.rb +0 -12
@@ -1,15 +1,16 @@
1
- $medium-select-box-width: 90px;
1
+ @import "alchemy_admin/select2";
2
2
 
3
3
  select {
4
4
  @include button-defaults(
5
5
  $background-color: $form-field-background-color,
6
6
  $hover-color: $form-field-background-color,
7
7
  $hover-border-color: darken($default-border-color, 10%),
8
- $padding: 0 2*$default-padding,
8
+ $padding: 0 2 * $default-padding,
9
9
  $border: 1px solid $default-border-color,
10
10
  $box-shadow: none,
11
11
  $color: $text-color,
12
- $margin: 0);
12
+ $margin: 0
13
+ );
13
14
  height: $form-field-height;
14
15
  padding: 0.4em 0.6em;
15
16
  max-width: 100%;
@@ -34,7 +35,8 @@ select {
34
35
  $border: 1px solid $default-border-color,
35
36
  $box-shadow: none,
36
37
  $color: $text-color,
37
- $margin: 0);
38
+ $margin: 0
39
+ );
38
40
  background-image: none;
39
41
  display: block;
40
42
  font-weight: normal;
@@ -76,15 +78,18 @@ select {
76
78
  width: $medium-select-box-width;
77
79
  }
78
80
 
79
- &.select2-container-active {
81
+ &.large {
82
+ width: $large-select-box-width;
83
+ }
80
84
 
81
- .select2-choice, .select2-choices {
85
+ &.select2-container-active {
86
+ .select2-choice,
87
+ .select2-choices {
82
88
  @include default-focus-style($box-shadow: 0 0 0 1px $focus-color);
83
89
  }
84
90
  }
85
91
 
86
92
  &.select2-container-disabled {
87
-
88
93
  &:hover {
89
94
  + .with-hint > .hint-bubble {
90
95
  @include hint-hover-style;
@@ -96,7 +101,8 @@ select {
96
101
  top: 0;
97
102
  }
98
103
 
99
- .select2-choice, .select2-choice:hover {
104
+ .select2-choice,
105
+ .select2-choice:hover {
100
106
  background-image: none;
101
107
  background-color: $light-gray;
102
108
  box-shadow: none;
@@ -106,7 +112,9 @@ select {
106
112
  .select2-arrow {
107
113
  border-color: $border-inset-color;
108
114
 
109
- b { color: $border-inset-color; }
115
+ b {
116
+ color: $border-inset-color;
117
+ }
110
118
  }
111
119
  }
112
120
  }
@@ -140,7 +148,6 @@ select {
140
148
  margin-top: 0 !important;
141
149
 
142
150
  &.select2-container-active {
143
-
144
151
  .select2-choices {
145
152
  @include default-focus-style($box-shadow: 0 0 0 1px $focus-color);
146
153
  }
@@ -212,7 +219,8 @@ select {
212
219
  }
213
220
  }
214
221
 
215
- .select2-no-results, .select2-searching {
222
+ .select2-no-results,
223
+ .select2-searching {
216
224
  padding: 8px;
217
225
  margin: 0;
218
226
  }
@@ -233,41 +241,39 @@ select {
233
241
 
234
242
  .select2-more-results,
235
243
  .select2-ajax-error {
236
- padding: 2*$default-padding;
244
+ padding: 2 * $default-padding;
237
245
  margin-bottom: 0;
238
246
  }
239
247
  }
240
248
 
241
- .window_form, #filter_bar {
242
-
249
+ .window_form,
250
+ #filter_bar {
243
251
  .select2-container {
244
252
  width: 100%;
245
253
  }
246
254
  }
247
255
 
248
256
  .select_with_label {
249
- margin: 0 3*$default-margin;
257
+ margin: 0 3 * $default-margin;
250
258
  display: inline-block;
251
259
  vertical-align: middle;
252
260
 
253
261
  label {
254
262
  display: inline-block;
255
263
  vertical-align: middle;
256
- margin-right: 2*$default-margin;
264
+ margin-right: 2 * $default-margin;
257
265
  }
258
266
  }
259
267
 
260
268
  // overriding important of select2 default style for retina screens
261
269
  @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
262
- only screen and (min-resolution: 2dppx) {
263
-
270
+ only screen and (min-resolution: 2dppx) {
264
271
  #alchemy {
265
-
266
272
  .select2-search input,
267
273
  .select2-search-choice-close,
268
274
  .select2-container .select2-choice abbr,
269
275
  .select2-container .select2-choice .select2-arrow b {
270
- background-image: none !important;
276
+ background-image: none !important;
271
277
  }
272
278
  }
273
279
  }
@@ -6,7 +6,8 @@ table {
6
6
  width: 100%;
7
7
 
8
8
  &.list .tools {
9
- button, a {
9
+ button,
10
+ a {
10
11
  display: inline-block;
11
12
  width: 18px;
12
13
  height: 18px;
@@ -22,8 +23,9 @@ table {
22
23
  }
23
24
  }
24
25
 
25
- .list td, .list th {
26
- padding: 2*$default-padding;
26
+ .list td,
27
+ .list th {
28
+ padding: 2 * $default-padding;
27
29
  vertical-align: top;
28
30
  line-height: 18px;
29
31
  border-right: 1px solid $medium-gray;
@@ -93,9 +95,10 @@ td.heading {
93
95
  background-color: $table-row-hover-color;
94
96
  }
95
97
 
96
- td, th {
97
-
98
- &.center, &.boolean {
98
+ td,
99
+ th {
100
+ &.center,
101
+ &.boolean {
99
102
  text-align: center;
100
103
  }
101
104
 
@@ -105,7 +108,6 @@ td, th {
105
108
  }
106
109
 
107
110
  td {
108
-
109
111
  &.file_name {
110
112
  word-break: break-all;
111
113
  }
@@ -118,7 +120,8 @@ td {
118
120
  width: 80px;
119
121
  }
120
122
 
121
- &.date, &.datetime {
123
+ &.date,
124
+ &.datetime {
122
125
  width: 150px;
123
126
  }
124
127
 
@@ -137,9 +140,35 @@ td {
137
140
  &.rights {
138
141
  width: 60px;
139
142
  }
143
+
144
+ &.page_layout {
145
+ width: 160px;
146
+ }
147
+
148
+ &.status {
149
+ width: 80px;
150
+
151
+ .page_status {
152
+ margin: 0 $default-margin;
153
+ }
154
+ }
155
+
156
+ &.tags {
157
+ width: 180px;
158
+
159
+ .tag {
160
+ margin: 0;
161
+ padding: 0 2 + $default-padding;
162
+
163
+ &:before {
164
+ padding-right: $default-padding;
165
+ }
166
+ }
167
+ }
140
168
  }
141
169
 
142
- th.count, td.count {
170
+ th.count,
171
+ td.count {
143
172
  width: 120px;
144
173
  text-align: right;
145
174
  padding-right: 16px;
@@ -1,26 +1,10 @@
1
1
  .tag-list {
2
+ display: flex;
3
+ flex-direction: column;
2
4
  height: 100%;
3
- padding-bottom: 138px;
4
-
5
- &.filtered {
6
- padding-bottom: 178px;
7
- }
8
-
9
- &.with_filter_bar {
10
- padding-bottom: 218px;
11
-
12
- &.filtered {
13
- padding-bottom: 256px;
14
- }
15
- }
16
5
 
17
6
  .js_filter_field_box {
18
- position: absolute;
19
- right: auto;
20
- top: auto;
21
- width: 200px;
22
- z-index: 1100;
23
- transition: background-color $transition-duration;
7
+ margin: 0;
24
8
 
25
9
  input {
26
10
  background-color: transparentize($white, 0.25);
@@ -29,23 +13,22 @@
29
13
  background-color: $white;
30
14
  }
31
15
  }
32
-
33
- label { display: none }
34
16
  }
35
17
 
36
18
  ul {
37
19
  list-style-type: none;
38
20
  padding: 0;
39
- margin: 44px 0 4px 0;
21
+ margin: 0;
40
22
  height: 100%;
41
- width: 200px;
42
23
  overflow-x: hidden;
43
24
  overflow-y: auto;
44
25
 
45
26
  li {
46
27
  display: block;
47
28
 
48
- &:first-child { margin-top: 0 }
29
+ &:first-child {
30
+ margin-top: 0;
31
+ }
49
32
 
50
33
  a {
51
34
  @include tag-base;
@@ -53,13 +36,14 @@
53
36
  display: block;
54
37
  }
55
38
 
56
- &:hover { background-color: $very-light-blue }
39
+ &:hover {
40
+ background-color: $very-light-blue;
41
+ }
57
42
 
58
43
  &.active {
59
-
60
44
  a {
61
45
  background-color: $dark-gray;
62
- color: $light-gray
46
+ color: $light-gray;
63
47
  }
64
48
  }
65
49
  }
@@ -69,7 +53,7 @@
69
53
  .tag {
70
54
  @include tag-base(
71
55
  $margin: $default-margin/2 0,
72
- $padding: $default-padding 2*$default-padding $default-padding
56
+ $padding: $default-padding 2 * $default-padding $default-padding
73
57
  );
74
58
  pointer-events: none;
75
59
  font-size: $small-font-size;
@@ -124,7 +108,9 @@
124
108
  position: relative;
125
109
  border-radius: $default-border-radius;
126
110
 
127
- &.odd { background-color: #eaf3f9 }
111
+ &.odd {
112
+ background-color: #eaf3f9;
113
+ }
128
114
 
129
115
  input {
130
116
  position: absolute;
@@ -141,14 +127,16 @@
141
127
  }
142
128
  }
143
129
 
144
- .tag_list, .autocomplete_tag_list {
130
+ .tag_list,
131
+ .autocomplete_tag_list {
145
132
  .select2-container.select2-container-multi {
146
133
  .select2-search-choice {
147
134
  padding: 0;
148
135
 
149
136
  div {
150
137
  @include tag-base(
151
- $padding: $default-padding 6*$default-padding $default-padding 3*$default-padding,
138
+ $padding: $default-padding 6 * $default-padding $default-padding 3 *
139
+ $default-padding,
152
140
  $margin: 0
153
141
  );
154
142
  }
@@ -2,12 +2,12 @@
2
2
 
3
3
  module Alchemy
4
4
  module Admin
5
- class PagesController < Alchemy::Admin::BaseController
5
+ class PagesController < ResourcesController
6
6
  include OnPageLayout::CallbacksRunner
7
7
 
8
8
  helper "alchemy/pages"
9
9
 
10
- before_action :load_page, except: [:index, :flush, :new, :order, :create, :copy_language_tree, :link, :sort]
10
+ before_action :load_resource, except: [:index, :flush, :new, :order, :create, :copy_language_tree, :link, :sort]
11
11
 
12
12
  authorize_resource class: Alchemy::Page, except: [:index, :tree]
13
13
 
@@ -27,11 +27,33 @@ module Alchemy
27
27
  if: :run_on_page_layout_callbacks?,
28
28
  only: [:show]
29
29
 
30
+ before_action :load_languages_and_layouts,
31
+ unless: -> { @page_root },
32
+ only: [:index]
33
+
34
+ before_action :set_view, only: [:index]
35
+
30
36
  def index
31
- if !@page_root
32
- @language = @current_language
33
- @languages_with_page_tree = Language.on_current_site.with_root_page
34
- @page_layouts = PageLayout.layouts_for_select(@language.id)
37
+ @query = @current_language.pages.contentpages.ransack(search_filter_params[:q])
38
+
39
+ if @view == "list"
40
+ @query.sorts = default_sort_order if @query.sorts.empty?
41
+ items = @query.result
42
+
43
+ if search_filter_params[:tagged_with].present?
44
+ items = items.tagged_with(search_filter_params[:tagged_with])
45
+ end
46
+
47
+ if search_filter_params[:filter].present?
48
+ items = items.public_send(sanitized_filter_params)
49
+ end
50
+
51
+ if search_filter_params[:page_layout].present?
52
+ items = items.where(page_layout: search_filter_params[:page_layout])
53
+ end
54
+
55
+ items = items.page(params[:page] || 1).per(items_per_page)
56
+ @pages = items
35
57
  end
36
58
  end
37
59
 
@@ -85,7 +107,12 @@ module Alchemy
85
107
  elsif page_needs_lock?
86
108
  @page.lock_to!(current_alchemy_user)
87
109
  end
88
- @preview_url = Alchemy::Admin::PREVIEW_URL.url_for(@page)
110
+ @preview_urls = Alchemy.preview_sources.map do |klass|
111
+ [
112
+ klass.model_name.human,
113
+ klass.new(routes: Alchemy::Engine.routes).url_for(@page),
114
+ ]
115
+ end
89
116
  @layoutpage = @page.layoutpage?
90
117
  end
91
118
 
@@ -178,6 +205,10 @@ module Alchemy
178
205
  def publish
179
206
  # fetching page via before filter
180
207
  @page.publish!
208
+
209
+ # Send publish notification to all registered publish targets
210
+ Alchemy.publish_targets.each { |p| p.perform_later(@page) }
211
+
181
212
  flash[:notice] = Alchemy.t(:page_published, name: @page.name)
182
213
  redirect_back(fallback_location: admin_pages_path)
183
214
  end
@@ -220,6 +251,19 @@ module Alchemy
220
251
 
221
252
  private
222
253
 
254
+ def resource_handler
255
+ @_resource_handler ||= Alchemy::Resource.new(controller_path, alchemy_module, Alchemy::Page)
256
+ end
257
+
258
+ def common_search_filter_includes
259
+ super.push(:page_layout, :view)
260
+ end
261
+
262
+ def set_view
263
+ @view = params[:view] || session[:alchemy_pages_view] || "tree"
264
+ session[:alchemy_pages_view] = @view
265
+ end
266
+
223
267
  def copy_of_language_root
224
268
  Page.copy(
225
269
  language_root_to_copy_from,
@@ -301,7 +345,7 @@ module Alchemy
301
345
  { my_urlname: default_urlname, children_path: default_urlname }
302
346
  end
303
347
 
304
- def load_page
348
+ def load_resource
305
349
  @page = Page.find(params[:id])
306
350
  end
307
351
 
@@ -364,6 +408,12 @@ module Alchemy
364
408
  user: current_alchemy_user,
365
409
  full: params[:full] == "true")
366
410
  end
411
+
412
+ def load_languages_and_layouts
413
+ @language = @current_language
414
+ @languages_with_page_tree = Language.on_current_site.with_root_page
415
+ @page_layouts = PageLayout.layouts_for_select(@language.id)
416
+ end
367
417
  end
368
418
  end
369
419
  end