alchemy_cms 5.0.3 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.github/workflows/stale.yml +1 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +66 -2
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/alchemy_cms.gemspec +3 -3
- data/app/assets/images/alchemy/missing-image.svg +1 -0
- data/app/assets/javascripts/alchemy/admin.js +0 -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 +8 -0
- data/app/assets/stylesheets/alchemy/admin.scss +0 -1
- data/app/assets/stylesheets/alchemy/archive.scss +23 -17
- data/app/assets/stylesheets/alchemy/buttons.scss +26 -15
- data/app/assets/stylesheets/alchemy/elements.scss +58 -19
- data/app/assets/stylesheets/alchemy/errors.scss +1 -1
- data/app/assets/stylesheets/alchemy/frame.scss +0 -1
- data/app/assets/stylesheets/alchemy/hints.scss +2 -1
- data/app/assets/stylesheets/alchemy/navigation.scss +7 -10
- data/app/assets/stylesheets/alchemy/pagination.scss +1 -1
- data/app/assets/stylesheets/alchemy/search.scss +13 -3
- data/app/assets/stylesheets/alchemy/selects.scss +26 -20
- data/app/assets/stylesheets/alchemy/tables.scss +38 -9
- data/app/assets/stylesheets/alchemy/tags.scss +19 -31
- data/app/controllers/alchemy/admin/pages_controller.rb +58 -8
- data/app/controllers/alchemy/admin/pictures_controller.rb +13 -6
- data/app/controllers/alchemy/admin/resources_controller.rb +3 -3
- data/app/controllers/alchemy/pages_controller.rb +49 -14
- data/app/decorators/alchemy/element_editor.rb +1 -0
- data/app/helpers/alchemy/admin/base_helper.rb +0 -44
- data/app/helpers/alchemy/admin/navigation_helper.rb +2 -1
- data/app/models/alchemy/attachment.rb +20 -3
- data/app/models/alchemy/attachment/url.rb +40 -0
- data/app/models/alchemy/essence_picture.rb +3 -3
- data/app/models/alchemy/essence_picture_view.rb +5 -3
- data/app/models/alchemy/legacy_page_url.rb +1 -1
- data/app/models/alchemy/page.rb +24 -1
- data/app/models/alchemy/page/page_natures.rb +2 -0
- data/app/models/alchemy/page/url_path.rb +8 -6
- data/app/models/alchemy/picture.rb +58 -2
- data/app/models/alchemy/picture/calculations.rb +55 -0
- data/app/models/alchemy/picture/transformations.rb +5 -49
- data/app/models/alchemy/picture/url.rb +28 -77
- data/app/models/alchemy/picture_thumb.rb +57 -0
- data/app/models/alchemy/picture_thumb/create.rb +39 -0
- data/app/models/alchemy/picture_thumb/signature.rb +23 -0
- data/app/models/alchemy/picture_thumb/uid.rb +22 -0
- data/app/models/alchemy/picture_variant.rb +114 -0
- data/app/models/alchemy/site/layout.rb +30 -2
- data/app/views/alchemy/admin/attachments/show.html.erb +8 -8
- data/app/views/alchemy/admin/dashboard/index.html.erb +13 -16
- data/app/views/alchemy/admin/elements/_element_footer.html.erb +1 -1
- data/app/views/alchemy/admin/elements/publish.js.erb +1 -0
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
- data/app/views/alchemy/admin/layoutpages/edit.html.erb +4 -6
- data/app/views/alchemy/admin/pages/_create_language_form.html.erb +19 -29
- data/app/views/alchemy/admin/pages/_form.html.erb +4 -6
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +12 -2
- data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +29 -0
- data/app/views/alchemy/admin/pages/_table.html.erb +27 -0
- data/app/views/alchemy/admin/pages/_table_row.html.erb +107 -0
- data/app/views/alchemy/admin/pages/_toolbar.html.erb +77 -0
- data/app/views/alchemy/admin/pages/edit.html.erb +9 -1
- data/app/views/alchemy/admin/pages/index.html.erb +41 -74
- data/app/views/alchemy/admin/pages/list/_table.html.erb +31 -0
- data/app/views/alchemy/admin/pages/unlock.js.erb +2 -2
- data/app/views/alchemy/admin/pages/update.js.erb +19 -10
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +14 -13
- data/app/views/alchemy/admin/partials/_search_form.html.erb +8 -8
- data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_form.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -3
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/show.html.erb +3 -3
- data/app/views/alchemy/admin/resources/_filter_bar.html.erb +13 -11
- data/app/views/alchemy/admin/resources/_per_page_select.html.erb +3 -3
- data/app/views/alchemy/admin/resources/index.html.erb +4 -1
- data/app/views/alchemy/admin/tags/index.html.erb +14 -15
- data/app/views/alchemy/base/500.html.erb +11 -13
- data/app/views/alchemy/essences/_essence_file_view.html.erb +3 -3
- data/config/alchemy/config.yml +15 -11
- data/config/alchemy/modules.yml +12 -12
- data/config/locales/alchemy.en.yml +6 -4
- data/config/routes.rb +1 -1
- data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +22 -0
- data/db/migrate/20200907111332_remove_tri_state_booleans.rb +33 -0
- data/lib/alchemy.rb +66 -0
- data/lib/alchemy/admin/preview_url.rb +2 -0
- data/lib/alchemy/auth_accessors.rb +12 -5
- data/lib/alchemy/config.rb +1 -3
- data/lib/alchemy/engine.rb +7 -6
- data/lib/alchemy/modules.rb +11 -1
- data/lib/alchemy/permissions.rb +1 -0
- data/lib/alchemy/test_support/factories/picture_factory.rb +0 -1
- data/lib/alchemy/test_support/factories/picture_thumb_factory.rb +12 -0
- data/lib/alchemy/test_support/integration_helpers.rb +0 -7
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +2 -4
- data/lib/generators/alchemy/install/files/alchemy.en.yml +2 -2
- data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +5 -5
- data/lib/tasks/alchemy/thumbnails.rake +37 -0
- data/vendor/assets/javascripts/jquery_plugins/select2.js +3729 -0
- data/vendor/assets/stylesheets/alchemy_admin/select2.scss +740 -0
- metadata +41 -31
- data/.github/workflows/greetings.yml +0 -13
- data/app/controllers/concerns/alchemy/locale_redirects.rb +0 -40
- data/app/controllers/concerns/alchemy/page_redirects.rb +0 -68
- data/lib/alchemy/userstamp.rb +0 -12
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.
|
4
|
+
version: 5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
@@ -87,22 +87,22 @@ dependencies:
|
|
87
87
|
name: coffee-rails
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- - "
|
90
|
+
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '4.0'
|
93
93
|
- - "<"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '6.0'
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '4.0'
|
103
103
|
- - "<"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
105
|
+
version: '6.0'
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
107
|
name: dragonfly
|
108
108
|
requirement: !ruby/object:Gem::Requirement
|
@@ -335,26 +335,6 @@ dependencies:
|
|
335
335
|
- - "~>"
|
336
336
|
- !ruby/object:Gem::Version
|
337
337
|
version: '2.1'
|
338
|
-
- !ruby/object:Gem::Dependency
|
339
|
-
name: select2-rails
|
340
|
-
requirement: !ruby/object:Gem::Requirement
|
341
|
-
requirements:
|
342
|
-
- - ">="
|
343
|
-
- !ruby/object:Gem::Version
|
344
|
-
version: 3.5.9.1
|
345
|
-
- - "<"
|
346
|
-
- !ruby/object:Gem::Version
|
347
|
-
version: '4.0'
|
348
|
-
type: :runtime
|
349
|
-
prerelease: false
|
350
|
-
version_requirements: !ruby/object:Gem::Requirement
|
351
|
-
requirements:
|
352
|
-
- - ">="
|
353
|
-
- !ruby/object:Gem::Version
|
354
|
-
version: 3.5.9.1
|
355
|
-
- - "<"
|
356
|
-
- !ruby/object:Gem::Version
|
357
|
-
version: '4.0'
|
358
338
|
- !ruby/object:Gem::Dependency
|
359
339
|
name: simple_form
|
360
340
|
requirement: !ruby/object:Gem::Requirement
|
@@ -477,14 +457,14 @@ dependencies:
|
|
477
457
|
requirements:
|
478
458
|
- - "~>"
|
479
459
|
- !ruby/object:Gem::Version
|
480
|
-
version: '
|
460
|
+
version: '5.0'
|
481
461
|
type: :development
|
482
462
|
prerelease: false
|
483
463
|
version_requirements: !ruby/object:Gem::Requirement
|
484
464
|
requirements:
|
485
465
|
- - "~>"
|
486
466
|
- !ruby/object:Gem::Version
|
487
|
-
version: '
|
467
|
+
version: '5.0'
|
488
468
|
- !ruby/object:Gem::Dependency
|
489
469
|
name: rails-controller-testing
|
490
470
|
requirement: !ruby/object:Gem::Requirement
|
@@ -583,6 +563,20 @@ dependencies:
|
|
583
563
|
- - "~>"
|
584
564
|
- !ruby/object:Gem::Version
|
585
565
|
version: '4.0'
|
566
|
+
- !ruby/object:Gem::Dependency
|
567
|
+
name: timecop
|
568
|
+
requirement: !ruby/object:Gem::Requirement
|
569
|
+
requirements:
|
570
|
+
- - "~>"
|
571
|
+
- !ruby/object:Gem::Version
|
572
|
+
version: '0.9'
|
573
|
+
type: :development
|
574
|
+
prerelease: false
|
575
|
+
version_requirements: !ruby/object:Gem::Requirement
|
576
|
+
requirements:
|
577
|
+
- - "~>"
|
578
|
+
- !ruby/object:Gem::Version
|
579
|
+
version: '0.9'
|
586
580
|
description: Alchemy is a powerful, userfriendly and flexible Rails CMS.
|
587
581
|
email:
|
588
582
|
- hello@alchemy-cms.com
|
@@ -597,7 +591,6 @@ files:
|
|
597
591
|
- ".github/ISSUE_TEMPLATE/Feature_request.md"
|
598
592
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
599
593
|
- ".github/workflows/ci.yml"
|
600
|
-
- ".github/workflows/greetings.yml"
|
601
594
|
- ".github/workflows/stale.yml"
|
602
595
|
- ".gitignore"
|
603
596
|
- ".hound.yml"
|
@@ -620,6 +613,7 @@ files:
|
|
620
613
|
- app/assets/images/alchemy/icon-white.svg
|
621
614
|
- app/assets/images/alchemy/icon.svg
|
622
615
|
- app/assets/images/alchemy/lupe.cur
|
616
|
+
- app/assets/images/alchemy/missing-image.svg
|
623
617
|
- app/assets/javascripts/alchemy/admin.js
|
624
618
|
- app/assets/javascripts/alchemy/alchemy.autocomplete.js.coffee
|
625
619
|
- app/assets/javascripts/alchemy/alchemy.base.js.coffee
|
@@ -757,8 +751,6 @@ files:
|
|
757
751
|
- app/controllers/concerns/alchemy/admin/current_language.rb
|
758
752
|
- app/controllers/concerns/alchemy/admin/uploader_responses.rb
|
759
753
|
- app/controllers/concerns/alchemy/legacy_page_redirects.rb
|
760
|
-
- app/controllers/concerns/alchemy/locale_redirects.rb
|
761
|
-
- app/controllers/concerns/alchemy/page_redirects.rb
|
762
754
|
- app/controllers/concerns/alchemy/site_redirects.rb
|
763
755
|
- app/decorators/alchemy/content_editor.rb
|
764
756
|
- app/decorators/alchemy/element_editor.rb
|
@@ -780,6 +772,7 @@ files:
|
|
780
772
|
- app/mailers/alchemy/base_mailer.rb
|
781
773
|
- app/mailers/alchemy/messages_mailer.rb
|
782
774
|
- app/models/alchemy/attachment.rb
|
775
|
+
- app/models/alchemy/attachment/url.rb
|
783
776
|
- app/models/alchemy/base_record.rb
|
784
777
|
- app/models/alchemy/content.rb
|
785
778
|
- app/models/alchemy/content/factory.rb
|
@@ -815,9 +808,15 @@ files:
|
|
815
808
|
- app/models/alchemy/page/page_scopes.rb
|
816
809
|
- app/models/alchemy/page/url_path.rb
|
817
810
|
- app/models/alchemy/picture.rb
|
811
|
+
- app/models/alchemy/picture/calculations.rb
|
818
812
|
- app/models/alchemy/picture/preprocessor.rb
|
819
813
|
- app/models/alchemy/picture/transformations.rb
|
820
814
|
- app/models/alchemy/picture/url.rb
|
815
|
+
- app/models/alchemy/picture_thumb.rb
|
816
|
+
- app/models/alchemy/picture_thumb/create.rb
|
817
|
+
- app/models/alchemy/picture_thumb/signature.rb
|
818
|
+
- app/models/alchemy/picture_thumb/uid.rb
|
819
|
+
- app/models/alchemy/picture_variant.rb
|
821
820
|
- app/models/alchemy/site.rb
|
822
821
|
- app/models/alchemy/site/layout.rb
|
823
822
|
- app/models/alchemy/tag.rb
|
@@ -923,10 +922,14 @@ files:
|
|
923
922
|
- app/views/alchemy/admin/pages/_new_page_form.html.erb
|
924
923
|
- app/views/alchemy/admin/pages/_page.html.erb
|
925
924
|
- app/views/alchemy/admin/pages/_page_infos.html.erb
|
925
|
+
- app/views/alchemy/admin/pages/_page_layout_filter.html.erb
|
926
926
|
- app/views/alchemy/admin/pages/_page_status.html.erb
|
927
927
|
- app/views/alchemy/admin/pages/_publication_fields.html.erb
|
928
928
|
- app/views/alchemy/admin/pages/_sitemap.html.erb
|
929
|
+
- app/views/alchemy/admin/pages/_table.html.erb
|
930
|
+
- app/views/alchemy/admin/pages/_table_row.html.erb
|
929
931
|
- app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb
|
932
|
+
- app/views/alchemy/admin/pages/_toolbar.html.erb
|
930
933
|
- app/views/alchemy/admin/pages/configure.html.erb
|
931
934
|
- app/views/alchemy/admin/pages/edit.html.erb
|
932
935
|
- app/views/alchemy/admin/pages/flush.js.erb
|
@@ -934,6 +937,7 @@ files:
|
|
934
937
|
- app/views/alchemy/admin/pages/index.html.erb
|
935
938
|
- app/views/alchemy/admin/pages/info.html.erb
|
936
939
|
- app/views/alchemy/admin/pages/link.html.erb
|
940
|
+
- app/views/alchemy/admin/pages/list/_table.html.erb
|
937
941
|
- app/views/alchemy/admin/pages/locked.html.erb
|
938
942
|
- app/views/alchemy/admin/pages/new.html.erb
|
939
943
|
- app/views/alchemy/admin/pages/show.html.erb
|
@@ -1070,6 +1074,9 @@ files:
|
|
1070
1074
|
- db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb
|
1071
1075
|
- db/migrate/20200514091507_make_page_layoutpage_null_false.rb
|
1072
1076
|
- db/migrate/20200519073500_remove_visible_from_alchemy_pages.rb
|
1077
|
+
- db/migrate/20200617110713_create_alchemy_picture_thumbs.rb
|
1078
|
+
- db/migrate/20200907111332_remove_tri_state_booleans.rb
|
1079
|
+
- lib/alchemy.rb
|
1073
1080
|
- lib/alchemy/ability_helper.rb
|
1074
1081
|
- lib/alchemy/admin/locale.rb
|
1075
1082
|
- lib/alchemy/admin/preview_url.rb
|
@@ -1118,6 +1125,7 @@ files:
|
|
1118
1125
|
- lib/alchemy/test_support/factories/node_factory.rb
|
1119
1126
|
- lib/alchemy/test_support/factories/page_factory.rb
|
1120
1127
|
- lib/alchemy/test_support/factories/picture_factory.rb
|
1128
|
+
- lib/alchemy/test_support/factories/picture_thumb_factory.rb
|
1121
1129
|
- lib/alchemy/test_support/factories/site_factory.rb
|
1122
1130
|
- lib/alchemy/test_support/fixtures/image.png
|
1123
1131
|
- lib/alchemy/test_support/integration_helpers.rb
|
@@ -1128,7 +1136,6 @@ files:
|
|
1128
1136
|
- lib/alchemy/upgrader/five_point_zero.rb
|
1129
1137
|
- lib/alchemy/upgrader/tasks/element_views_updater.rb
|
1130
1138
|
- lib/alchemy/upgrader/tasks/harden_gutentag_migrations.rb
|
1131
|
-
- lib/alchemy/userstamp.rb
|
1132
1139
|
- lib/alchemy/version.rb
|
1133
1140
|
- lib/alchemy_cms.rb
|
1134
1141
|
- lib/generators/alchemy/base.rb
|
@@ -1175,6 +1182,7 @@ files:
|
|
1175
1182
|
- lib/kaminari/scoped_pagination_url_helper.rb
|
1176
1183
|
- lib/tasks/alchemy/db.rake
|
1177
1184
|
- lib/tasks/alchemy/install.rake
|
1185
|
+
- lib/tasks/alchemy/thumbnails.rake
|
1178
1186
|
- lib/tasks/alchemy/tidy.rake
|
1179
1187
|
- lib/tasks/alchemy/upgrade.rake
|
1180
1188
|
- package.json
|
@@ -1208,10 +1216,12 @@ files:
|
|
1208
1216
|
- vendor/assets/javascripts/jquery_plugins/jquery.scrollTo.min.js
|
1209
1217
|
- vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js
|
1210
1218
|
- vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js
|
1219
|
+
- vendor/assets/javascripts/jquery_plugins/select2.js
|
1211
1220
|
- vendor/assets/javascripts/keymaster.js
|
1212
1221
|
- vendor/assets/javascripts/requestAnimationFrame.js
|
1213
1222
|
- vendor/assets/javascripts/tinymce/license.txt
|
1214
1223
|
- vendor/assets/javascripts/tinymce/tinymce.min.js
|
1224
|
+
- vendor/assets/stylesheets/alchemy_admin/select2.scss
|
1215
1225
|
- vendor/assets/stylesheets/fontawesome/_animated.scss
|
1216
1226
|
- vendor/assets/stylesheets/fontawesome/_bordered-pulled.scss
|
1217
1227
|
- vendor/assets/stylesheets/fontawesome/_core.scss
|
@@ -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
|
data/lib/alchemy/userstamp.rb
DELETED
@@ -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
|