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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b10d39bfe40bc834b734a824c9fbce68e1acf178b5cbd3ecbf6613dd4ac33261
4
- data.tar.gz: 909f0164f71e95ed26c0b7a194b3464fc8c5974f8b28161eb3da4cb8e6c0c473
3
+ metadata.gz: 9e12f510dae37d181a93e110634f158c8f3fac7231c489579d61118528c1174a
4
+ data.tar.gz: 467204837b948c660077c45e0dab282d23fff3c79a1fea854658d05098a3b8b7
5
5
  SHA512:
6
- metadata.gz: 58367dca12c34272d159b8346bddddd729df2d2670b9e159d617ab1958c40937f58a6deb557a2cec1951bfaa4bb4b29cb34071eb08df14583b4cfdf58985619e
7
- data.tar.gz: f1f861bfbc18c988597189e5dd87db0e905a70d6d78ad8bde8f2f70bba012f564fa9cfe8febf6d53834eddfde425e231ea9549b12b1bf177a8ae337f21609661
6
+ metadata.gz: 3037cd0a408e63b6edde1c58bc398ec4d377d6a9452caf0e6d8b418b438eb8e7176ca8336f5987089caf355c90e68fbca04ab7df3ac67fca76654efcf00d2cab
7
+ data.tar.gz: d5a363910f6e4bfb221094c15f33c550dc3650c5eae35a375ea187e92bdac102e31c155168f336c1fa8f11a22235ff1558cc5433ad34fadc79cf59d28e0d883e
@@ -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
@@ -22,7 +22,7 @@ group :development, :test do
22
22
  gem "yard"
23
23
  gem "redcarpet"
24
24
  gem "pry-byebug"
25
- gem "rubocop", "~> 1.0.0", require: false
25
+ gem "rubocop", "~> 1.1.0", require: false
26
26
  gem "listen"
27
27
  gem "localeapp", "~> 3.0", require: false
28
28
  gem "dotenv", "~> 2.2"
@@ -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
- if e.origin == window.location.origin
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: (url) ->
8
- $iframe = $("<iframe name=\"alchemy_preview_window\" src=\"#{url}\" id=\"alchemy_preview_window\" frameborder=\"0\"/>")
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 'src', $iframe.attr('src')
38
+ $iframe.attr('src', @previewUrl)
33
39
  true
34
40
 
35
41
  postMessage: (data) ->
36
42
  frameWindow = @currentWindow[0].contentWindow
37
- frameWindow.postMessage(data, window.location.origin)
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
- @preview_url = Alchemy::Admin::PREVIEW_URL.url_for(@page)
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('<%= @preview_url %>');
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'
@@ -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
@@ -31,6 +31,8 @@ module Alchemy
31
31
  # password: <%= ENV["BASIC_AUTH_PASSWORD"] %>
32
32
  #
33
33
  class PreviewUrl
34
+ extend ActiveModel::Translation
35
+
34
36
  class MissingProtocolError < StandardError; end
35
37
 
36
38
  def initialize(routes:)
@@ -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)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.1.0.beta1"
4
+ VERSION = "5.1.0.beta2"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Instantiate the global Alchemy namespace
3
- module Alchemy
4
- YAML_WHITELIST_CLASSES = %w(Symbol Date Regexp)
5
- end
4
+ require "alchemy"
6
5
 
7
6
  # Require globally used external libraries
8
7
  require "acts_as_list"
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.beta1
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-10-30 00:00:00.000000000 Z
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