alchemy_cms 5.0.0.beta1 → 5.0.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: a47529eb07ef956c81fe417efd5570b37a0d56e689ee3079c9bc623b91b8bc28
4
- data.tar.gz: 9bb8aa6ca4eab610212690d3630c223269d3d6cb28224e33a9a4838fb4869c81
3
+ metadata.gz: 89a4ae7079c8ca7f64ae3b28d1acf1b648090d98fc4b9beff5061f81c73e1044
4
+ data.tar.gz: bb1169db4e23c9621745888be3963319b3746e156028d711a22870a4f51330e4
5
5
  SHA512:
6
- metadata.gz: df610fff48f0e7a30c0f348b20c452a8ade6226a9ce6457b497d76e3cdc7269d43cfe24da082687773de1c9a692df0116475b87469e9538899bc142e7d49397e
7
- data.tar.gz: 89281dc3a6bccd9d537adc2662143e61f023f38205a3474a1d4f6a63b40dea7374df95f7f40614aee771f14de7bec44f92afb68dfcffafb1df1028f416bb0c79
6
+ metadata.gz: c60d6b0ddcbe43763ff32fcad72144f572f6f8c91bbd1ac9bd0edbd41fd88723a29ef299f5ae51f5edd366e9f8ad7de5054a19768cfe92f27bb61f36d5c04bc2
7
+ data.tar.gz: f2f612afa9ae01c12d56b61c674ff311f89951acbeb0d327e3b15465761380a5344c65160dd121a6b88b6ab2ca6841d26a7eb75b92cfea65cba9bfb956fd81a1
@@ -227,7 +227,7 @@ Style/StringLiteralsInInterpolation:
227
227
  EnforcedStyle: double_quotes
228
228
 
229
229
  Style/TrailingCommaInArguments:
230
- EnforcedStyleForMultiline: comma
230
+ Enabled: false
231
231
 
232
232
  Style/TrailingCommaInArrayLiteral:
233
233
  EnforcedStyleForMultiline: comma
@@ -1,5 +1,10 @@
1
1
  ## 5.0.0 (unreleased)
2
2
 
3
+ - Language Factory: Create default language in host app's locale [#1884](https://github.com/AlchemyCMS/alchemy_cms/pull/1884) ([mamhoff](https://github.com/mamhoff))
4
+ - Respect filter and tagging params in picture archive size buttons [#1880](https://github.com/AlchemyCMS/alchemy_cms/pull/1880) ([tvdeyen](https://github.com/tvdeyen))
5
+ - Extract picture thumbnail sizes in a constant [#1879](https://github.com/AlchemyCMS/alchemy_cms/pull/1879) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Configurable Image Preprocessor [#1878](https://github.com/AlchemyCMS/alchemy_cms/pull/1878) ([tvdeyen](https://github.com/tvdeyen))
7
+ - Configure edit page preview per site [#1877](https://github.com/AlchemyCMS/alchemy_cms/pull/1877) ([tvdeyen](https://github.com/tvdeyen))
3
8
  - Fix Page tree sorting after root page removal [#1876](https://github.com/AlchemyCMS/alchemy_cms/pull/1876) ([tvdeyen](https://github.com/tvdeyen))
4
9
  - 5.0 Upgrader fixes [#1874](https://github.com/AlchemyCMS/alchemy_cms/pull/1874) ([tvdeyen](https://github.com/tvdeyen))
5
10
  - Remove url_nesting config [#1872](https://github.com/AlchemyCMS/alchemy_cms/pull/1872) ([tvdeyen](https://github.com/tvdeyen))
@@ -45,7 +45,7 @@ Gem::Specification.new do |gem|
45
45
 
46
46
  gem.add_development_dependency 'capybara', ['~> 3.0']
47
47
  gem.add_development_dependency 'capybara-screenshot', ['~> 1.0']
48
- gem.add_development_dependency 'factory_bot_rails', ['~> 5.0']
48
+ gem.add_development_dependency 'factory_bot_rails', ['~> 6.0']
49
49
  gem.add_development_dependency 'puma', ['~> 4.0']
50
50
  gem.add_development_dependency 'rails-controller-testing', ['~> 1.0']
51
51
  gem.add_development_dependency 'rspec-activemodel-mocks', ['~> 1.0']
@@ -4,12 +4,10 @@ module Alchemy
4
4
  module Admin
5
5
  module PicturesHelper
6
6
  def preview_size(size)
7
- case size
8
- when "small" then "80x60"
9
- when "large" then "240x180"
10
- else
11
- "160x120"
12
- end
7
+ Alchemy::Picture::THUMBNAIL_SIZES.fetch(
8
+ size,
9
+ Alchemy::Picture::THUMBNAIL_SIZES[:medium]
10
+ )
13
11
  end
14
12
  end
15
13
  end
@@ -22,6 +22,12 @@
22
22
 
23
23
  module Alchemy
24
24
  class Picture < BaseRecord
25
+ THUMBNAIL_SIZES = {
26
+ small: "80x60",
27
+ medium: "160x120",
28
+ large: "240x180",
29
+ }.with_indifferent_access.freeze
30
+
25
31
  CONVERTIBLE_FILE_FORMATS = %w(gif jpg jpeg png).freeze
26
32
 
27
33
  include Alchemy::NameConversions
@@ -50,12 +56,25 @@ module Alchemy
50
56
  raise PictureInUseError, Alchemy.t(:cannot_delete_picture_notice) % { name: name }
51
57
  end
52
58
 
59
+ # Image preprocessing class
60
+ def self.preprocessor_class
61
+ @_preprocessor_class ||= Preprocessor
62
+ end
63
+
64
+ # Set a image preprocessing class
65
+ #
66
+ # # config/initializers/alchemy.rb
67
+ # Alchemy::Picture.preprocessor_class = My::ImagePreprocessor
68
+ #
69
+ def self.preprocessor_class=(klass)
70
+ @_preprocessor_class = klass
71
+ end
72
+
53
73
  # Enables Dragonfly image processing
54
74
  dragonfly_accessor :image_file, app: :alchemy_pictures do
55
75
  # Preprocess after uploading the picture
56
- after_assign do |p|
57
- resize = Config.get(:preprocess_image_resize)
58
- p.thumb!(resize) if resize.present?
76
+ after_assign do |image|
77
+ self.class.preprocessor_class.new(image).call
59
78
  end
60
79
  end
61
80
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ class Picture < BaseRecord
5
+ class Preprocessor
6
+ def initialize(image_file)
7
+ @image_file = image_file
8
+ end
9
+
10
+ # Preprocess images after upload
11
+ #
12
+ # Define preprocessing options in the Alchemy::Config
13
+ #
14
+ # preprocess_image_resize [String] - Downsizing example: '1000x1000>'
15
+ #
16
+ def call
17
+ max_image_size = Alchemy::Config.get(:preprocess_image_resize)
18
+ image_file.thumb!(max_image_size) if max_image_size.present?
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :image_file
24
+ end
25
+ end
26
+ end
@@ -14,7 +14,12 @@
14
14
  <div class="button_with_label">
15
15
  <%= link_to(
16
16
  render_icon('search-minus'),
17
- alchemy.admin_pictures_path(size: "small", q: search_filter_params[:q]),
17
+ alchemy.admin_pictures_path(
18
+ size: "small",
19
+ q: search_filter_params[:q],
20
+ filter: search_filter_params[:filter],
21
+ tagged_with: search_filter_params[:tagged_with]
22
+ ),
18
23
  title: Alchemy.t(:small_thumbnails),
19
24
  class: "icon_button"
20
25
  ) %>
@@ -22,7 +27,12 @@
22
27
  <div class="button_with_label">
23
28
  <%= link_to(
24
29
  render_icon('search'),
25
- alchemy.admin_pictures_path(size: "medium", q: search_filter_params[:q]),
30
+ alchemy.admin_pictures_path(
31
+ size: "medium",
32
+ q: search_filter_params[:q],
33
+ filter: search_filter_params[:filter],
34
+ tagged_with: search_filter_params[:tagged_with]
35
+ ),
26
36
  title: Alchemy.t(:medium_thumbnails),
27
37
  class: "icon_button"
28
38
  ) %>
@@ -30,7 +40,12 @@
30
40
  <div class="button_with_label">
31
41
  <%= link_to(
32
42
  render_icon('search-plus'),
33
- alchemy.admin_pictures_path(size: "large", q: search_filter_params[:q]),
43
+ alchemy.admin_pictures_path(
44
+ size: "large",
45
+ q: search_filter_params[:q],
46
+ filter: search_filter_params[:filter],
47
+ tagged_with: search_filter_params[:tagged_with]
48
+ ),
34
49
  title: Alchemy.t(:big_thumbnails),
35
50
  class: "icon_button"
36
51
  ) %>
@@ -55,6 +55,16 @@ items_per_page: 15
55
55
  # auth:
56
56
  # username: <%= ENV["BASIC_AUTH_USERNAME"] %>
57
57
  # password: <%= ENV["BASIC_AUTH_PASSWORD"] %>
58
+ #
59
+ # Preview config per site is supported as well.
60
+ #
61
+ # preview:
62
+ # My site name:
63
+ # host: https://www.my-static-site.com
64
+ # auth:
65
+ # username: <%= ENV["BASIC_AUTH_USERNAME"] %>
66
+ # password: <%= ENV["BASIC_AUTH_PASSWORD"] %>
67
+ #
58
68
 
59
69
  # === Picture rendering settings
60
70
  #
@@ -19,19 +19,31 @@ module Alchemy
19
19
  # username: <%= ENV["BASIC_AUTH_USERNAME"] %>
20
20
  # password: <%= ENV["BASIC_AUTH_PASSWORD"] %>
21
21
  #
22
+ # Preview config per site is supported as well.
23
+ #
24
+ # == Example config/alchemy/config.yml
25
+ #
26
+ # preview:
27
+ # My site name:
28
+ # host: https://www.my-static-site.com
29
+ # auth:
30
+ # username: <%= ENV["BASIC_AUTH_USERNAME"] %>
31
+ # password: <%= ENV["BASIC_AUTH_PASSWORD"] %>
32
+ #
22
33
  class PreviewUrl
23
34
  class MissingProtocolError < StandardError; end
24
35
 
25
36
  def initialize(routes:)
26
37
  @routes = routes.url_helpers
27
- @preview_config = Alchemy::Config.get(:preview)
28
38
  end
29
39
 
30
40
  def url_for(page)
31
- if preview_config
41
+ @preview_config = preview_config_for(page)
42
+
43
+ if @preview_config && uri
32
44
  uri_class.build(
33
45
  host: uri.host,
34
- path: "/#{page.urlname}",
46
+ path: page.url_path,
35
47
  userinfo: userinfo,
36
48
  ).to_s
37
49
  else
@@ -41,10 +53,19 @@ module Alchemy
41
53
 
42
54
  private
43
55
 
44
- attr_reader :preview_config, :routes
56
+ attr_reader :routes
57
+
58
+ def preview_config_for(page)
59
+ preview_config = Alchemy::Config.get(:preview)
60
+ return unless preview_config
61
+
62
+ preview_config[page.site.name] || preview_config
63
+ end
45
64
 
46
65
  def uri
47
- URI(preview_config["host"])
66
+ return unless @preview_config["host"]
67
+
68
+ URI(@preview_config["host"])
48
69
  end
49
70
 
50
71
  def uri_class
@@ -56,7 +77,7 @@ module Alchemy
56
77
  end
57
78
 
58
79
  def userinfo
59
- auth = preview_config["auth"]
80
+ auth = @preview_config["auth"]
60
81
  auth ? "#{auth["username"]}:#{auth["password"]}" : nil
61
82
  end
62
83
  end
@@ -5,8 +5,8 @@ require "alchemy/test_support/factories/site_factory"
5
5
 
6
6
  FactoryBot.define do
7
7
  factory :alchemy_language, class: "Alchemy::Language" do
8
- name { "Deutsch" }
9
- code { "de" }
8
+ name { "Your Language" }
9
+ code { ::I18n.available_locales.first.to_s }
10
10
  default { true }
11
11
  frontpage_name { "Intro" }
12
12
  page_layout { Alchemy::Config.get(:default_language)["page_layout"] }
@@ -25,7 +25,12 @@ FactoryBot.define do
25
25
  trait :english do
26
26
  name { "English" }
27
27
  code { "en" }
28
- frontpage_name { "Intro" }
28
+ default { false }
29
+ end
30
+
31
+ trait :german do
32
+ name { "Deutsch" }
33
+ code { "de" }
29
34
  default { false }
30
35
  end
31
36
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.0.0.beta1"
4
+ VERSION = "5.0.0.beta2"
5
5
 
6
6
  def self.version
7
7
  VERSION
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.0.0.beta1
4
+ version: 5.0.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-06-11 00:00:00.000000000 Z
16
+ date: 2020-06-25 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -463,14 +463,14 @@ dependencies:
463
463
  requirements:
464
464
  - - "~>"
465
465
  - !ruby/object:Gem::Version
466
- version: '5.0'
466
+ version: '6.0'
467
467
  type: :development
468
468
  prerelease: false
469
469
  version_requirements: !ruby/object:Gem::Requirement
470
470
  requirements:
471
471
  - - "~>"
472
472
  - !ruby/object:Gem::Version
473
- version: '5.0'
473
+ version: '6.0'
474
474
  - !ruby/object:Gem::Dependency
475
475
  name: puma
476
476
  requirement: !ruby/object:Gem::Requirement
@@ -815,6 +815,7 @@ files:
815
815
  - app/models/alchemy/page/page_scopes.rb
816
816
  - app/models/alchemy/page/url_path.rb
817
817
  - app/models/alchemy/picture.rb
818
+ - app/models/alchemy/picture/preprocessor.rb
818
819
  - app/models/alchemy/picture/transformations.rb
819
820
  - app/models/alchemy/picture/url.rb
820
821
  - app/models/alchemy/site.rb