alchemy_cms 5.1.0.beta1 → 5.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +1 -4
- data/app/assets/javascripts/alchemy/alchemy.preview.js.coffee +0 -3
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +29 -4
- data/app/assets/stylesheets/alchemy/_variables.scss +2 -0
- data/app/assets/stylesheets/alchemy/selects.scss +4 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +10 -1
- data/app/views/alchemy/admin/pages/edit.html.erb +9 -1
- data/config/locales/alchemy.en.yml +2 -0
- data/lib/alchemy.rb +66 -0
- data/lib/alchemy/admin/preview_url.rb +2 -0
- data/lib/alchemy/engine.rb +0 -4
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +2 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e12f510dae37d181a93e110634f158c8f3fac7231c489579d61118528c1174a
|
4
|
+
data.tar.gz: 467204837b948c660077c45e0dab282d23fff3c79a1fea854658d05098a3b8b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3037cd0a408e63b6edde1c58bc398ec4d377d6a9452caf0e6d8b418b438eb8e7176ca8336f5987089caf355c90e68fbca04ab7df3ac67fca76654efcf00d2cab
|
7
|
+
data.tar.gz: d5a363910f6e4bfb221094c15f33c550dc3650c5eae35a375ea187e92bdac102e31c155168f336c1fa8f11a22235ff1558cc5433ad34fadc79cf59d28e0d883e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
### Features
|
4
4
|
|
5
|
+
- Allow multiple preview sources [#1959](https://github.com/AlchemyCMS/alchemy_cms/pull/1959) ([tvdeyen](https://github.com/tvdeyen))
|
6
|
+
- Add Publish Targets [#1957](https://github.com/AlchemyCMS/alchemy_cms/pull/1957) ([tvdeyen](https://github.com/tvdeyen))
|
5
7
|
- Persist rendered picture variants [#1882](https://github.com/AlchemyCMS/alchemy_cms/pull/1882) ([tvdeyen](https://github.com/tvdeyen))
|
6
8
|
- Store current pictures size in session [#1927](https://github.com/AlchemyCMS/alchemy_cms/pull/1927) ([tvdeyen](https://github.com/tvdeyen))
|
7
9
|
- Add support for custom mount points in Page::UrlPath [#1921](https://github.com/AlchemyCMS/alchemy_cms/pull/1921) ([tvdeyen](https://github.com/tvdeyen))
|
@@ -36,6 +38,7 @@
|
|
36
38
|
|
37
39
|
### Misc
|
38
40
|
|
41
|
+
- [ruby - main] Upgrade rubocop to version 1.1.0 [#1958](https://github.com/AlchemyCMS/alchemy_cms/pull/1958) ([depfu](https://github.com/apps/depfu))
|
39
42
|
- Remove greetings action [#1956](https://github.com/AlchemyCMS/alchemy_cms/pull/1956) ([tvdeyen](https://github.com/tvdeyen))
|
40
43
|
- [ruby] Upgrade rubocop to version 1.0.0 [#1952](https://github.com/AlchemyCMS/alchemy_cms/pull/1952) ([depfu](https://github.com/apps/depfu))
|
41
44
|
- [ruby] Upgrade rubocop to version 0.93.1 [#1948](https://github.com/AlchemyCMS/alchemy_cms/pull/1948) ([depfu](https://github.com/apps/depfu))
|
data/Gemfile
CHANGED
@@ -38,10 +38,7 @@ Alchemy.ElementEditors =
|
|
38
38
|
@onSaveElement(e, data)
|
39
39
|
# Listen to postMessage messages from the preview frame
|
40
40
|
window.addEventListener 'message', (e) =>
|
41
|
-
|
42
|
-
@onMessage(e.data)
|
43
|
-
else
|
44
|
-
console.warn 'Unsafe message origin!', e.origin
|
41
|
+
@onMessage(e.data)
|
45
42
|
true
|
46
43
|
return
|
47
44
|
|
@@ -22,9 +22,6 @@ Alchemy.initAlchemyPreviewMode = ->
|
|
22
22
|
|
23
23
|
init: ->
|
24
24
|
window.addEventListener "message", (event) =>
|
25
|
-
if event.origin != window.location.origin
|
26
|
-
console.warn 'Unsafe message origin!', event.origin
|
27
|
-
return
|
28
25
|
switch event.data.message
|
29
26
|
when "Alchemy.blurElements" then @blurElements()
|
30
27
|
when "Alchemy.focusElement" then @focusElement(event.data)
|
@@ -4,8 +4,10 @@ Alchemy.PreviewWindow =
|
|
4
4
|
MIN_WIDTH: 240
|
5
5
|
HEIGHT: 75 # Top menu height
|
6
6
|
|
7
|
-
init: (
|
8
|
-
|
7
|
+
init: (previewUrl) ->
|
8
|
+
@select = document.querySelector('#preview_url')
|
9
|
+
@previewUrl = @_getCurrentPreviewUrl() || previewUrl[1]
|
10
|
+
$iframe = $("<iframe name=\"alchemy_preview_window\" src=\"#{@previewUrl}\" id=\"alchemy_preview_window\" frameborder=\"0\"/>")
|
9
11
|
$reload = $('#reload_preview_button')
|
10
12
|
@_showSpinner()
|
11
13
|
$iframe.load =>
|
@@ -13,6 +15,10 @@ Alchemy.PreviewWindow =
|
|
13
15
|
$('body').append($iframe)
|
14
16
|
@currentWindow = $iframe
|
15
17
|
@_bindReloadButton()
|
18
|
+
if @select
|
19
|
+
@select.value = @previewUrl
|
20
|
+
@_bindSelect()
|
21
|
+
return
|
16
22
|
|
17
23
|
resize: (width) ->
|
18
24
|
width = @MIN_WIDTH if width < @MIN_WIDTH
|
@@ -29,12 +35,12 @@ Alchemy.PreviewWindow =
|
|
29
35
|
@_hideSpinner()
|
30
36
|
if callback
|
31
37
|
callback.call(e, $iframe)
|
32
|
-
$iframe.attr
|
38
|
+
$iframe.attr('src', @previewUrl)
|
33
39
|
true
|
34
40
|
|
35
41
|
postMessage: (data) ->
|
36
42
|
frameWindow = @currentWindow[0].contentWindow
|
37
|
-
frameWindow.postMessage(data,
|
43
|
+
frameWindow.postMessage(data, "*")
|
38
44
|
|
39
45
|
_showSpinner: ->
|
40
46
|
@reload = $('#reload_preview_button')
|
@@ -53,5 +59,24 @@ Alchemy.PreviewWindow =
|
|
53
59
|
e.preventDefault()
|
54
60
|
@refresh()
|
55
61
|
|
62
|
+
_getCurrentPreviewUrl: ->
|
63
|
+
if @select
|
64
|
+
option = Array.from(@select.options).find (o) =>
|
65
|
+
o.text == window.localStorage.getItem("alchemyPreview")
|
66
|
+
if option
|
67
|
+
option.value
|
68
|
+
else
|
69
|
+
null
|
70
|
+
else
|
71
|
+
null
|
72
|
+
|
73
|
+
_bindSelect: ->
|
74
|
+
$(@select).change (e) =>
|
75
|
+
@previewUrl = e.target.value
|
76
|
+
option = e.target.querySelector("option[value='#{@previewUrl}']")
|
77
|
+
window.localStorage.setItem("alchemyPreview", option.text)
|
78
|
+
@refresh()
|
79
|
+
return
|
80
|
+
|
56
81
|
Alchemy.reloadPreview = ->
|
57
82
|
Alchemy.PreviewWindow.refresh()
|
@@ -159,6 +159,8 @@ $datepicker_day_color: $text-color !default;
|
|
159
159
|
|
160
160
|
$select-hover-bg-color: $dark-blue !default;
|
161
161
|
$select-hover-text-color: $white !default;
|
162
|
+
$medium-select-box-width: 90px;
|
163
|
+
$large-select-box-width: 120px;
|
162
164
|
|
163
165
|
$thumbnail-background-color: opacify($default-border-color, 1) !default;
|
164
166
|
$medium-screen-break-point: 700px;
|
@@ -1,5 +1,3 @@
|
|
1
|
-
$medium-select-box-width: 90px;
|
2
|
-
|
3
1
|
select {
|
4
2
|
@include button-defaults(
|
5
3
|
$background-color: $form-field-background-color,
|
@@ -76,6 +74,10 @@ select {
|
|
76
74
|
width: $medium-select-box-width;
|
77
75
|
}
|
78
76
|
|
77
|
+
&.large {
|
78
|
+
width: $large-select-box-width;
|
79
|
+
}
|
80
|
+
|
79
81
|
&.select2-container-active {
|
80
82
|
|
81
83
|
.select2-choice, .select2-choices {
|
@@ -85,7 +85,12 @@ module Alchemy
|
|
85
85
|
elsif page_needs_lock?
|
86
86
|
@page.lock_to!(current_alchemy_user)
|
87
87
|
end
|
88
|
-
@
|
88
|
+
@preview_urls = Alchemy.preview_sources.map do |klass|
|
89
|
+
[
|
90
|
+
klass.model_name.human,
|
91
|
+
klass.new(routes: Alchemy::Engine.routes).url_for(@page),
|
92
|
+
]
|
93
|
+
end
|
89
94
|
@layoutpage = @page.layoutpage?
|
90
95
|
end
|
91
96
|
|
@@ -178,6 +183,10 @@ module Alchemy
|
|
178
183
|
def publish
|
179
184
|
# fetching page via before filter
|
180
185
|
@page.publish!
|
186
|
+
|
187
|
+
# Send publish notification to all registered publish targets
|
188
|
+
Alchemy.publish_targets.each { |p| p.perform_later(@page) }
|
189
|
+
|
181
190
|
flash[:notice] = Alchemy.t(:page_published, name: @page.name)
|
182
191
|
redirect_back(fallback_location: admin_pages_path)
|
183
192
|
end
|
@@ -88,6 +88,14 @@
|
|
88
88
|
class: 'alchemy_selectbox medium' %>
|
89
89
|
</div>
|
90
90
|
<div class="toolbar_spacer"></div>
|
91
|
+
<% if @preview_urls.many? %>
|
92
|
+
<div class="select_with_label">
|
93
|
+
<label><%= Alchemy.t(:preview_url) %></label>
|
94
|
+
<%= select_tag 'preview_url',
|
95
|
+
options_for_select(@preview_urls),
|
96
|
+
class: 'alchemy_selectbox large' %>
|
97
|
+
</div>
|
98
|
+
<% end %>
|
91
99
|
<div class="button_with_label">
|
92
100
|
<%= link_to render_icon(:redo), nil, {
|
93
101
|
title: Alchemy.t('Reload Preview'),
|
@@ -190,7 +198,7 @@
|
|
190
198
|
}
|
191
199
|
});
|
192
200
|
|
193
|
-
Alchemy.PreviewWindow.init(
|
201
|
+
Alchemy.PreviewWindow.init(<%== @preview_urls.first %>);
|
194
202
|
|
195
203
|
$('#preview_size').bind('open.selectBoxIt', function (e) {
|
196
204
|
$('#top_menu').css('z-index', 5000);
|
@@ -521,6 +521,7 @@ en:
|
|
521
521
|
'768': '768px (iPad - Portrait)'
|
522
522
|
'1024': '1024px (iPad - Landscape)'
|
523
523
|
'1280': '1280px (Desktop)'
|
524
|
+
preview_url: Preview
|
524
525
|
recently_uploaded_only: 'Recently uploaded only'
|
525
526
|
"regular method": "Regular method"
|
526
527
|
remove: "Remove"
|
@@ -690,6 +691,7 @@ en:
|
|
690
691
|
alchemy/message:
|
691
692
|
one: Message
|
692
693
|
other: Messages
|
694
|
+
alchemy/admin/preview_url: Internal
|
693
695
|
attributes:
|
694
696
|
alchemy/message:
|
695
697
|
salutation: 'Salutation'
|
data/lib/alchemy.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "alchemy/admin/preview_url"
|
4
|
+
|
5
|
+
module Alchemy
|
6
|
+
YAML_WHITELIST_CLASSES = %w(Symbol Date Regexp)
|
7
|
+
|
8
|
+
# Define page preview sources
|
9
|
+
#
|
10
|
+
# A preview source is a Ruby class returning an URL
|
11
|
+
# that is used as source for the preview frame in the
|
12
|
+
# admin UI.
|
13
|
+
#
|
14
|
+
# == Example
|
15
|
+
#
|
16
|
+
# # lib/acme/preview_source.rb
|
17
|
+
# class Acme::PreviewSource < Alchemy::Admin::PreviewUrl
|
18
|
+
# def url_for(page)
|
19
|
+
# if page.site.name == "Next"
|
20
|
+
# "https://user:#{ENV['PREVIEW_HTTP_PASS']}@next.acme.com"
|
21
|
+
# else
|
22
|
+
# "https://www.acme.com"
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# # config/initializers/alchemy.rb
|
28
|
+
# require "acme/preview_source"
|
29
|
+
# Alchemy.preview_sources << Acme::PreviewSource
|
30
|
+
#
|
31
|
+
# # config/locales/de.yml
|
32
|
+
# de:
|
33
|
+
# activemodel:
|
34
|
+
# models:
|
35
|
+
# acme/preview_source: Acme Vorschau
|
36
|
+
#
|
37
|
+
def self.preview_sources
|
38
|
+
@_preview_sources ||= begin
|
39
|
+
Set.new << Alchemy::Admin::PreviewUrl
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Define page publish targets
|
44
|
+
#
|
45
|
+
# A publish target is a ActiveJob that gets performed
|
46
|
+
# whenever a user clicks the publish page button.
|
47
|
+
#
|
48
|
+
# Use this to trigger deployment hooks of external
|
49
|
+
# services in an asychronous way.
|
50
|
+
#
|
51
|
+
# == Example
|
52
|
+
#
|
53
|
+
# # app/jobs/publish_job.rb
|
54
|
+
# class PublishJob < ApplicationJob
|
55
|
+
# def perform(page)
|
56
|
+
# RestClient.post(ENV['BUILD_HOOK_URL'])
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# # config/initializers/alchemy.rb
|
61
|
+
# Alchemy.publish_targets << PublishJob
|
62
|
+
#
|
63
|
+
def self.publish_targets
|
64
|
+
@_publish_targets ||= Set.new
|
65
|
+
end
|
66
|
+
end
|
data/lib/alchemy/engine.rb
CHANGED
@@ -9,10 +9,6 @@ module Alchemy
|
|
9
9
|
Alchemy::LOOKUP_CONTEXT = ActionView::LookupContext.new(Rails.root.join("app", "views", "alchemy"))
|
10
10
|
end
|
11
11
|
|
12
|
-
initializer "alchemy.admin.preview_url" do
|
13
|
-
Alchemy::Admin::PREVIEW_URL = Alchemy::Admin::PreviewUrl.new(routes: Alchemy::Engine.routes)
|
14
|
-
end
|
15
|
-
|
16
12
|
initializer "alchemy.dependency_tracker" do
|
17
13
|
[:erb, :slim, :haml].each do |handler|
|
18
14
|
ActionView::DependencyTracker.register_tracker(handler, CacheDigests::TemplateTracker)
|
data/lib/alchemy/version.rb
CHANGED
data/lib/alchemy_cms.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.0.
|
4
|
+
version: 5.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2020-
|
16
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: active_model_serializers
|
@@ -1077,6 +1077,7 @@ files:
|
|
1077
1077
|
- db/migrate/20200519073500_remove_visible_from_alchemy_pages.rb
|
1078
1078
|
- db/migrate/20200617110713_create_alchemy_picture_thumbs.rb
|
1079
1079
|
- db/migrate/20200907111332_remove_tri_state_booleans.rb
|
1080
|
+
- lib/alchemy.rb
|
1080
1081
|
- lib/alchemy/ability_helper.rb
|
1081
1082
|
- lib/alchemy/admin/locale.rb
|
1082
1083
|
- lib/alchemy/admin/preview_url.rb
|