alchemy_cms 5.0.10 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  3. data/.github/workflows/stale.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.travis.yml +48 -0
  6. data/CHANGELOG.md +50 -40
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +2 -2
  9. data/README.md +2 -2
  10. data/alchemy_cms.gemspec +4 -4
  11. data/app/assets/images/alchemy/missing-image.svg +1 -0
  12. data/app/assets/stylesheets/alchemy/_variables.scss +1 -0
  13. data/app/assets/stylesheets/alchemy/archive.scss +23 -17
  14. data/app/assets/stylesheets/alchemy/errors.scss +1 -1
  15. data/app/assets/stylesheets/alchemy/navigation.scss +7 -10
  16. data/app/assets/stylesheets/alchemy/pagination.scss +1 -1
  17. data/app/assets/stylesheets/alchemy/search.scss +12 -2
  18. data/app/assets/stylesheets/alchemy/tags.scss +19 -31
  19. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +3 -3
  20. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +7 -7
  21. data/app/controllers/alchemy/admin/base_controller.rb +3 -9
  22. data/app/controllers/alchemy/admin/pictures_controller.rb +13 -6
  23. data/app/controllers/alchemy/admin/resources_controller.rb +3 -3
  24. data/app/controllers/alchemy/pages_controller.rb +49 -14
  25. data/app/helpers/alchemy/admin/base_helper.rb +0 -44
  26. data/app/helpers/alchemy/admin/navigation_helper.rb +2 -1
  27. data/app/helpers/alchemy/pages_helper.rb +1 -1
  28. data/app/models/alchemy/attachment/url.rb +40 -0
  29. data/app/models/alchemy/attachment.rb +21 -4
  30. data/app/models/alchemy/element.rb +1 -1
  31. data/app/models/alchemy/essence_picture.rb +3 -3
  32. data/app/models/alchemy/essence_picture_view.rb +5 -3
  33. data/app/models/alchemy/node.rb +1 -1
  34. data/app/models/alchemy/page/page_natures.rb +2 -0
  35. data/app/models/alchemy/page/url_path.rb +8 -6
  36. data/app/models/alchemy/page.rb +17 -2
  37. data/app/models/alchemy/picture/calculations.rb +55 -0
  38. data/app/models/alchemy/picture/transformations.rb +8 -52
  39. data/app/models/alchemy/picture/url.rb +28 -77
  40. data/app/models/alchemy/picture.rb +59 -3
  41. data/app/models/alchemy/picture_thumb/create.rb +39 -0
  42. data/app/models/alchemy/picture_thumb/signature.rb +23 -0
  43. data/app/models/alchemy/picture_thumb/uid.rb +22 -0
  44. data/app/models/alchemy/picture_thumb.rb +57 -0
  45. data/app/models/alchemy/picture_variant.rb +114 -0
  46. data/app/serializers/alchemy/page_tree_serializer.rb +4 -4
  47. data/app/views/alchemy/admin/attachments/show.html.erb +8 -8
  48. data/app/views/alchemy/admin/dashboard/index.html.erb +13 -16
  49. data/app/views/alchemy/admin/elements/_element_toolbar.html.erb +1 -1
  50. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  51. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  52. data/app/views/alchemy/admin/layoutpages/edit.html.erb +4 -6
  53. data/app/views/alchemy/admin/pages/_form.html.erb +4 -6
  54. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +2 -1
  55. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +14 -13
  56. data/app/views/alchemy/admin/partials/_search_form.html.erb +8 -8
  57. data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
  58. data/app/views/alchemy/admin/pictures/_form.html.erb +1 -1
  59. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -3
  60. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  61. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +1 -1
  62. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  63. data/app/views/alchemy/admin/pictures/show.html.erb +3 -3
  64. data/app/views/alchemy/admin/resources/_per_page_select.html.erb +3 -3
  65. data/app/views/alchemy/admin/resources/index.html.erb +4 -1
  66. data/app/views/alchemy/admin/tags/index.html.erb +14 -15
  67. data/app/views/alchemy/base/500.html.erb +11 -13
  68. data/app/views/alchemy/essences/_essence_file_view.html.erb +3 -3
  69. data/app/views/alchemy/essences/_essence_picture_view.html.erb +3 -3
  70. data/config/alchemy/config.yml +15 -11
  71. data/config/alchemy/modules.yml +12 -12
  72. data/config/initializers/dragonfly.rb +0 -8
  73. data/config/routes.rb +1 -1
  74. data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +22 -0
  75. data/db/migrate/20200907111332_remove_tri_state_booleans.rb +33 -0
  76. data/lib/alchemy/auth_accessors.rb +12 -5
  77. data/lib/alchemy/config.rb +1 -3
  78. data/lib/alchemy/engine.rb +6 -8
  79. data/lib/alchemy/modules.rb +11 -1
  80. data/lib/alchemy/resource.rb +3 -5
  81. data/lib/alchemy/test_support/factories/picture_factory.rb +0 -1
  82. data/lib/alchemy/test_support/factories/picture_thumb_factory.rb +12 -0
  83. data/lib/alchemy/upgrader/five_point_zero.rb +0 -32
  84. data/lib/alchemy/version.rb +1 -1
  85. data/lib/alchemy_cms.rb +0 -1
  86. data/lib/generators/alchemy/install/files/alchemy.en.yml +2 -2
  87. data/lib/generators/alchemy/install/install_generator.rb +1 -2
  88. data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +5 -5
  89. data/lib/tasks/alchemy/thumbnails.rake +37 -0
  90. data/lib/tasks/alchemy/upgrade.rake +0 -20
  91. data/package/admin.js +0 -2
  92. data/package/src/__tests__/i18n.spec.js +0 -23
  93. data/package/src/i18n.js +3 -1
  94. data/package.json +1 -1
  95. metadata +34 -23
  96. data/.github/workflows/ci.yml +0 -126
  97. data/.github/workflows/greetings.yml +0 -13
  98. data/app/controllers/concerns/alchemy/locale_redirects.rb +0 -40
  99. data/app/controllers/concerns/alchemy/page_redirects.rb +0 -68
  100. data/lib/alchemy/dragonfly/processors/crop_resize.rb +0 -35
  101. data/lib/alchemy/error_tracking/airbrake_handler.rb +0 -13
  102. data/lib/alchemy/error_tracking.rb +0 -14
  103. data/lib/alchemy/userstamp.rb +0 -12
@@ -1,126 +0,0 @@
1
- name: CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- RSpec:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- rails:
12
- - '5.2'
13
- - '6.0'
14
- ruby:
15
- - '2.6.x'
16
- - '2.7.x'
17
- database:
18
- - mysql
19
- - postgresql
20
- env:
21
- DB: ${{ matrix.database }}
22
- DB_USER: alchemy_user
23
- DB_PASSWORD: password
24
- DB_HOST: '127.0.0.1'
25
- RAILS_ENV: test
26
- RAILS_VERSION: ${{ matrix.rails }}
27
- services:
28
- postgres:
29
- image: postgres:11
30
- env:
31
- POSTGRES_USER: alchemy_user
32
- POSTGRES_PASSWORD: password
33
- POSTGRES_DB: alchemy_cms_dummy_test
34
- ports: ['5432:5432']
35
- options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
36
- mysql:
37
- image: mysql:latest
38
- ports: ['3306:3306']
39
- env:
40
- MYSQL_USER: alchemy_user
41
- MYSQL_PASSWORD: password
42
- MYSQL_DATABASE: alchemy_cms_dummy_test
43
- MYSQL_ROOT_PASSWORD: password
44
- options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
45
- steps:
46
- - uses: actions/checkout@v2.3.4
47
- - name: Set up Ruby
48
- uses: actions/setup-ruby@v1.1.2
49
- with:
50
- ruby-version: ${{ matrix.ruby }}
51
- - name: Restore apt cache
52
- id: apt-cache
53
- uses: actions/cache@v2.1.3
54
- with:
55
- path: /home/runner/apt/cache
56
- key: ${{ runner.os }}-apt-${{ matrix.database }}
57
- restore-keys: |
58
- ${{ runner.os }}-apt-
59
- - name: Install Postgres headers
60
- if: matrix.database == 'postgresql'
61
- run: |
62
- mkdir -p /home/runner/apt/cache
63
- sudo apt update -qq
64
- sudo apt install -qq --fix-missing libpq-dev -o dir::cache::archives="/home/runner/apt/cache"
65
- sudo chown -R runner /home/runner/apt/cache
66
- - name: Install MySQL headers
67
- if: matrix.database == 'mysql'
68
- run: |
69
- mkdir -p /home/runner/apt/cache
70
- sudo apt update -qq
71
- sudo apt install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache"
72
- sudo chown -R runner /home/runner/apt/cache
73
- - name: Install bundler
74
- run: |
75
- gem install bundler
76
- - name: Restore Ruby Gems cache
77
- id: cache
78
- uses: actions/cache@v2.1.3
79
- with:
80
- path: vendor/bundle
81
- key: ${{ runner.os }}-bundle-${{ matrix.ruby }}-${{ matrix.rails }}-${{ matrix.database }}-${{ hashFiles('**/Gemfile') }}
82
- restore-keys: |
83
- ${{ runner.os }}-bundle-
84
- - name: Install bundle
85
- timeout-minutes: 10
86
- run: |
87
- bundle install --jobs 4 --retry 3 --path vendor/bundle
88
- - name: Restore node modules cache
89
- id: yarn-cache
90
- uses: actions/cache@v2.1.3
91
- with:
92
- path: spec/dummy/node_modules
93
- key: ${{ runner.os }}-yarn-dummy-${{ hashFiles('./package.json') }}
94
- restore-keys: |
95
- ${{ runner.os }}-yarn-dummy-
96
- - name: Prepare database
97
- run: |
98
- bundle exec rake alchemy:spec:prepare
99
- - name: Run tests & publish code coverage
100
- uses: paambaati/codeclimate-action@v2.7.5
101
- env:
102
- CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
103
- with:
104
- coverageCommand: bundle exec rspec
105
- - uses: actions/upload-artifact@main
106
- if: failure()
107
- with:
108
- name: Screenshots
109
- path: spec/dummy/tmp/screenshots
110
- Jest:
111
- runs-on: ubuntu-latest
112
- env:
113
- NODE_ENV: test
114
- steps:
115
- - uses: actions/checkout@v2.3.4
116
- - name: Restore node modules cache
117
- uses: actions/cache@v2.1.3
118
- with:
119
- path: node_modules
120
- key: ${{ runner.os }}-yarn-${{ hashFiles('./package.json') }}
121
- restore-keys: |
122
- ${{ runner.os }}-yarn-
123
- - name: Install yarn
124
- run: yarn install
125
- - name: Run jest
126
- run: yarn jest
@@ -1,13 +0,0 @@
1
- name: Greetings
2
-
3
- on: [pull_request, issues]
4
-
5
- jobs:
6
- greeting:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/first-interaction@v1
10
- with:
11
- repo-token: ${{ secrets.GITHUB_TOKEN }}
12
- issue-message: 'Hey. Thanks for reporting this issue and welcome to AlchemyCMS. The maintainer have been notified. Please be patient while waiting for an answer. Open Source is done by volunteers, so give them some time to react. Meanwhile please think about sending a PR that fixes this issue. It is way more likely that it will be accepted than this bug fixed for you. Remember OpenSource is done by all of us. Again, thanks for reporting.'
13
- pr-message: 'Hey. Thanks for sending this PR. It is very much appreciated. Please be patient and give the maintainers some time to review your work. Meanwhile make sure that the PR meets our [contributing guidelines](https://github.com/AlchemyCMS/alchemy_cms/blob/master/CONTRIBUTING.md). This mostly means [great commit messages](https://chris.beams.io/posts/git-commit/) and adding tests. Thanks again for your contribution. Your help makes Alchemy better.'
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- # Handles locale redirects
5
- #
6
- # If the current URL has a locale prefix, but should not have one it redirects
7
- # to url without locale prefix.
8
- #
9
- # Situations we don't want a locale prefix:
10
- #
11
- # 1. If only one language is published
12
- # 2. If the requested locale is the current default locale
13
- #
14
- module LocaleRedirects
15
- extend ActiveSupport::Concern
16
-
17
- included do
18
- before_action :enforce_no_locale,
19
- if: :locale_prefix_not_allowed?,
20
- only: [:index, :show]
21
- end
22
-
23
- private
24
-
25
- # Redirects to requested action without locale prefixed
26
- def enforce_no_locale
27
- redirect_permanently_to additional_params.merge(locale: nil)
28
- end
29
-
30
- # Is the requested locale allowed?
31
- #
32
- # If Alchemy is not in multi language mode or the requested locale is the default locale,
33
- # then we want to redirect to a non prefixed url.
34
- #
35
- def locale_prefix_not_allowed?
36
- params[:locale].present? && !multi_language? ||
37
- params[:locale].presence == ::I18n.default_locale.to_s
38
- end
39
- end
40
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- # Handles page redirect urls
5
- #
6
- # Lots of reasons exist to redirect to another URL than the requested one.
7
- # These module holds the logic behind these needs.
8
- #
9
- module PageRedirects
10
- extend ActiveSupport::Concern
11
-
12
- private
13
-
14
- # Returns an URL to redirect the request to.
15
- #
16
- # == Lookup:
17
- #
18
- # 1. If the page is not published and we have a published child,
19
- # we return the url top that page. (Configurable through +redirect_to_public_child+).
20
- # 2. If the page layout of the page found has a controller and action configured,
21
- # we return the url to that route. (Configure controller and action in `page_layouts.yml`).
22
- # 3. If the current page URL has no locale prefixed, but we should have one,
23
- # we return the prefixed URL.
24
- # 4. If no redirection is needed returns nil.
25
- #
26
- # @return String
27
- # @return NilClass
28
- #
29
- def redirect_url
30
- @_redirect_url ||= public_child_redirect_url || locale_prefixed_url || nil
31
- end
32
-
33
- def locale_prefixed_url
34
- return unless locale_prefix_missing?
35
-
36
- page_redirect_url(locale: Language.current.code)
37
- end
38
-
39
- def public_child_redirect_url
40
- return if @page.public?
41
-
42
- if configuration(:redirect_to_public_child)
43
- @page = @page.descendants.published.not_restricted.first
44
- @page ? page_redirect_url : page_not_found!
45
- else
46
- page_not_found!
47
- end
48
- end
49
-
50
- # Page url with or without locale while keeping all additional params
51
- def page_redirect_url(options = {})
52
- options = {
53
- locale: prefix_locale? ? @page.language_code : nil,
54
- urlname: @page.urlname,
55
- }.merge(options)
56
-
57
- alchemy.show_page_path additional_params.merge(options)
58
- end
59
-
60
- def default_locale?
61
- Language.current.code.to_sym == ::I18n.default_locale.to_sym
62
- end
63
-
64
- def locale_prefix_missing?
65
- multi_language? && params[:locale].blank? && !default_locale?
66
- end
67
- end
68
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dragonfly/image_magick/commands"
4
-
5
- module Alchemy
6
- module Dragonfly
7
- module Processors
8
- class CropResize
9
- include ::Dragonfly::ParamValidators
10
-
11
- IS_CROP_ARGUMENT = ->(args_string) {
12
- args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::CROP_GEOMETRY)
13
- }
14
-
15
- IS_RESIZE_ARGUMENT = ->(args_string) {
16
- args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::RESIZE_GEOMETRY)
17
- }
18
-
19
- def call(content, crop_argument, resize_argument)
20
- validate!(crop_argument, &IS_CROP_ARGUMENT)
21
- validate!(resize_argument, &IS_RESIZE_ARGUMENT)
22
- ::Dragonfly::ImageMagick::Commands.convert(
23
- content,
24
- "-crop #{crop_argument} -resize #{resize_argument}"
25
- )
26
- end
27
-
28
- def update_url(attrs, _args = "", opts = {})
29
- format = opts["format"]
30
- attrs.ext = format if format
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- module ErrorTracking
5
- class AirbrakeHandler < BaseHandler
6
- def self.call(exception)
7
- return if ["development", "test"].include?(Rails.env)
8
-
9
- notify_airbrake(exception)
10
- end
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- module ErrorTracking
5
- class BaseHandler
6
- def self.call(exception)
7
- # implement your own notification method
8
- end
9
- end
10
-
11
- mattr_accessor :notification_handler
12
- @@notification_handler = BaseHandler
13
- end
14
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Adds the model stamper ability to the provided user class
4
- #
5
- # It only adds it, if the user model is a active_record model.
6
- #
7
- if Alchemy.user_class < ActiveRecord::Base
8
- Alchemy.user_class.class_eval do
9
- model_stamper
10
- stampable stamper_class_name: Alchemy.user_class.name
11
- end
12
- end