alchemy_cms 5.0.6 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) 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 -23
  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/controllers/alchemy/admin/pictures_controller.rb +13 -6
  20. data/app/controllers/alchemy/admin/resources_controller.rb +3 -3
  21. data/app/controllers/alchemy/pages_controller.rb +49 -14
  22. data/app/helpers/alchemy/admin/base_helper.rb +0 -44
  23. data/app/helpers/alchemy/admin/navigation_helper.rb +2 -1
  24. data/app/helpers/alchemy/pages_helper.rb +1 -1
  25. data/app/models/alchemy/attachment/url.rb +40 -0
  26. data/app/models/alchemy/attachment.rb +20 -3
  27. data/app/models/alchemy/essence_picture.rb +3 -3
  28. data/app/models/alchemy/essence_picture_view.rb +5 -3
  29. data/app/models/alchemy/page/page_natures.rb +2 -0
  30. data/app/models/alchemy/page/url_path.rb +8 -6
  31. data/app/models/alchemy/page.rb +16 -1
  32. data/app/models/alchemy/picture/calculations.rb +55 -0
  33. data/app/models/alchemy/picture/transformations.rb +5 -49
  34. data/app/models/alchemy/picture/url.rb +28 -77
  35. data/app/models/alchemy/picture.rb +58 -2
  36. data/app/models/alchemy/picture_thumb/create.rb +39 -0
  37. data/app/models/alchemy/picture_thumb/signature.rb +23 -0
  38. data/app/models/alchemy/picture_thumb/uid.rb +22 -0
  39. data/app/models/alchemy/picture_thumb.rb +57 -0
  40. data/app/models/alchemy/picture_variant.rb +114 -0
  41. data/app/serializers/alchemy/page_tree_serializer.rb +4 -4
  42. data/app/views/alchemy/admin/attachments/show.html.erb +8 -8
  43. data/app/views/alchemy/admin/dashboard/index.html.erb +13 -16
  44. data/app/views/alchemy/admin/elements/_element_toolbar.html.erb +1 -1
  45. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  46. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  47. data/app/views/alchemy/admin/layoutpages/edit.html.erb +4 -6
  48. data/app/views/alchemy/admin/pages/_form.html.erb +4 -6
  49. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +2 -1
  50. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +14 -13
  51. data/app/views/alchemy/admin/partials/_search_form.html.erb +8 -8
  52. data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
  53. data/app/views/alchemy/admin/pictures/_form.html.erb +1 -1
  54. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -3
  55. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  56. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +1 -1
  57. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  58. data/app/views/alchemy/admin/pictures/show.html.erb +3 -3
  59. data/app/views/alchemy/admin/resources/_per_page_select.html.erb +3 -3
  60. data/app/views/alchemy/admin/resources/index.html.erb +4 -1
  61. data/app/views/alchemy/admin/tags/index.html.erb +14 -15
  62. data/app/views/alchemy/base/500.html.erb +11 -13
  63. data/app/views/alchemy/essences/_essence_file_view.html.erb +3 -3
  64. data/app/views/alchemy/essences/_essence_picture_view.html.erb +3 -3
  65. data/config/alchemy/config.yml +15 -11
  66. data/config/alchemy/modules.yml +12 -12
  67. data/config/routes.rb +1 -1
  68. data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +22 -0
  69. data/db/migrate/20200907111332_remove_tri_state_booleans.rb +33 -0
  70. data/lib/alchemy/auth_accessors.rb +12 -5
  71. data/lib/alchemy/config.rb +1 -3
  72. data/lib/alchemy/engine.rb +7 -2
  73. data/lib/alchemy/modules.rb +11 -1
  74. data/lib/alchemy/resource.rb +3 -5
  75. data/lib/alchemy/test_support/factories/picture_factory.rb +0 -1
  76. data/lib/alchemy/test_support/factories/picture_thumb_factory.rb +12 -0
  77. data/lib/alchemy/upgrader/five_point_zero.rb +0 -31
  78. data/lib/alchemy/version.rb +1 -1
  79. data/lib/generators/alchemy/install/files/alchemy.en.yml +2 -2
  80. data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +5 -5
  81. data/lib/tasks/alchemy/thumbnails.rake +37 -0
  82. data/lib/tasks/alchemy/upgrade.rake +0 -20
  83. data/package/admin.js +0 -2
  84. data/package/src/__tests__/i18n.spec.js +0 -23
  85. data/package/src/i18n.js +3 -1
  86. data/package.json +1 -1
  87. metadata +26 -24
  88. data/.github/workflows/ci.yml +0 -126
  89. data/.github/workflows/greetings.yml +0 -13
  90. data/app/controllers/concerns/alchemy/locale_redirects.rb +0 -40
  91. data/app/controllers/concerns/alchemy/page_redirects.rb +0 -68
  92. data/lib/alchemy/userstamp.rb +0 -12
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :alchemy do
4
+ namespace :generate do
5
+ desc "Generates all thumbnails for Alchemy Pictures and EssencePictures."
6
+ task thumbnails: [
7
+ "alchemy_dragonfly_s3:generate:picture_thumbnails",
8
+ "alchemy_dragonfly_s3:generate:essence_picture_thumbnails",
9
+ ]
10
+
11
+ desc "Generates thumbnails for Alchemy Pictures."
12
+ task picture_thumbnails: :environment do
13
+ puts "Regenerate #{Alchemy::Picture.count} picture thumbnails."
14
+ puts "Please wait..."
15
+
16
+ Alchemy::Picture.find_each do |picture|
17
+ puts Alchemy::PictureThumb.generate_thumbs!(picture)
18
+ end
19
+
20
+ puts "Done!"
21
+ end
22
+
23
+ desc "Generates thumbnails for Alchemy EssencePictures."
24
+ task essence_picture_thumbnails: :environment do
25
+ essence_pictures = Alchemy::EssencePicture.joins(:content, :ingredient_association)
26
+ puts "Regenerate #{essence_pictures.count} essence picture thumbnails."
27
+ puts "Please wait..."
28
+
29
+ essence_pictures.find_each do |essence_picture|
30
+ puts essence_picture.picture_url
31
+ puts essence_picture.thumbnail_url
32
+ end
33
+
34
+ puts "Done!"
35
+ end
36
+ end
37
+ end
@@ -42,9 +42,6 @@ namespace :alchemy do
42
42
  "alchemy:upgrade:5.0:install_gutentag_migrations",
43
43
  "alchemy:upgrade:5.0:remove_layout_roots",
44
44
  "alchemy:upgrade:5.0:remove_root_page",
45
- "alchemy:upgrade:5.0:run_webpacker_installer",
46
- "alchemy:upgrade:5.0:add_npm_package",
47
- "alchemy:upgrade:5.0:copy_alchemy_entry_point",
48
45
  ]
49
46
 
50
47
  desc "Install Gutentag migrations"
@@ -61,23 +58,6 @@ namespace :alchemy do
61
58
  task remove_root_page: [:environment] do
62
59
  Alchemy::Upgrader::FivePointZero.remove_root_page
63
60
  end
64
-
65
- desc "Run webpacker installer"
66
- task run_webpacker_installer: [:environment] do
67
- Alchemy::Upgrader::FivePointZero.run_webpacker_installer
68
- end
69
-
70
- desc "Add NPM package"
71
- task add_npm_package: [:environment] do
72
- puts "adding npm_package..."
73
- Alchemy::Upgrader::FivePointZero.add_npm_package
74
- end
75
-
76
- desc "Copy alchemy entry point"
77
- task copy_alchemy_entry_point: [:environment] do
78
- puts "copying alchemy entry point"
79
- Alchemy::Upgrader::FivePointZero.copy_alchemy_entry_point
80
- end
81
61
  end
82
62
  end
83
63
  end
data/package/admin.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import translate from "./src/i18n"
2
- import translationData from "./src/translations"
3
2
  import NodeTree from "./src/node_tree"
4
3
 
5
4
  // Global Alchemy object
@@ -11,6 +10,5 @@ if (typeof window.Alchemy === "undefined") {
11
10
  Object.assign(Alchemy, {
12
11
  // Global utility method for translating a given string
13
12
  t: translate,
14
- translations: Object.assign(Alchemy.translations || {}, translationData),
15
13
  NodeTree
16
14
  })
@@ -15,20 +15,12 @@ describe("translate", () => {
15
15
  })
16
16
 
17
17
  describe("if translation is present", () => {
18
- beforeEach(() => {
19
- Alchemy.translations = { en: { help: "Help" } }
20
- })
21
-
22
18
  it("Returns translated string", () => {
23
19
  expect(translate("help")).toEqual("Help")
24
20
  })
25
21
 
26
22
  describe("if key includes a period", () => {
27
23
  describe("that is translated", () => {
28
- beforeEach(() => {
29
- Alchemy.translations = { en: { formats: { date: "Y-m-d" } } }
30
- })
31
-
32
24
  it("splits into group", () => {
33
25
  expect(translate("formats.date")).toEqual("Y-m-d")
34
26
  })
@@ -48,10 +40,6 @@ describe("translate", () => {
48
40
  })
49
41
 
50
42
  describe("if replacement is given", () => {
51
- beforeEach(() => {
52
- Alchemy.translations = { en: { allowed_chars: "of %{number} chars" } }
53
- })
54
-
55
43
  it("replaces it", () => {
56
44
  expect(translate("allowed_chars", 5)).toEqual("of 5 chars")
57
45
  })
@@ -79,15 +67,4 @@ describe("translate", () => {
79
67
  spy.mockRestore()
80
68
  })
81
69
  })
82
-
83
- describe("if Alchemy.translations is not set", () => {
84
- it("Returns passed string and logs a warning", () => {
85
- const spy = jest.spyOn(console, "warn").mockImplementation(() => {})
86
- expect(translate("help")).toEqual("help")
87
- expect(spy.mock.calls).toEqual([
88
- ["Translations for locale kl not found!"]
89
- ])
90
- spy.mockRestore()
91
- })
92
- })
93
70
  })
data/package/src/i18n.js CHANGED
@@ -1,3 +1,5 @@
1
+ import translationData from "./translations"
2
+
1
3
  const KEY_SEPARATOR = /\./
2
4
 
3
5
  function currentLocale() {
@@ -9,7 +11,7 @@ function currentLocale() {
9
11
 
10
12
  function getTranslations() {
11
13
  const locale = currentLocale()
12
- const translations = Alchemy.translations && Alchemy.translations[locale]
14
+ const translations = translationData[locale]
13
15
 
14
16
  if (translations) {
15
17
  return translations
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "5.0.6",
3
+ "version": "0.2.0",
4
4
  "description": "AlchemyCMS",
5
5
  "browser": "package/admin.js",
6
6
  "files": [
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.6
4
+ version: 5.1.0.beta1
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: 2021-09-17 00:00:00.000000000 Z
16
+ date: 2020-10-30 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -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: '5.0'
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: '5.0'
105
+ version: '6.0'
106
106
  - !ruby/object:Gem::Dependency
107
107
  name: dragonfly
108
108
  requirement: !ruby/object:Gem::Requirement
@@ -113,9 +113,6 @@ dependencies:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: 1.0.7
116
- - - "<"
117
- - !ruby/object:Gem::Version
118
- version: 1.4.0
119
116
  type: :runtime
120
117
  prerelease: false
121
118
  version_requirements: !ruby/object:Gem::Requirement
@@ -126,9 +123,6 @@ dependencies:
126
123
  - - ">="
127
124
  - !ruby/object:Gem::Version
128
125
  version: 1.0.7
129
- - - "<"
130
- - !ruby/object:Gem::Version
131
- version: 1.4.0
132
126
  - !ruby/object:Gem::Dependency
133
127
  name: dragonfly_svg
134
128
  requirement: !ruby/object:Gem::Requirement
@@ -483,14 +477,14 @@ dependencies:
483
477
  requirements:
484
478
  - - "~>"
485
479
  - !ruby/object:Gem::Version
486
- version: '4.0'
480
+ version: '5.0'
487
481
  type: :development
488
482
  prerelease: false
489
483
  version_requirements: !ruby/object:Gem::Requirement
490
484
  requirements:
491
485
  - - "~>"
492
486
  - !ruby/object:Gem::Version
493
- version: '4.0'
487
+ version: '5.0'
494
488
  - !ruby/object:Gem::Dependency
495
489
  name: rails-controller-testing
496
490
  requirement: !ruby/object:Gem::Requirement
@@ -602,14 +596,13 @@ files:
602
596
  - ".github/ISSUE_TEMPLATE/Bug_report.md"
603
597
  - ".github/ISSUE_TEMPLATE/Feature_request.md"
604
598
  - ".github/PULL_REQUEST_TEMPLATE.md"
605
- - ".github/workflows/ci.yml"
606
- - ".github/workflows/greetings.yml"
607
599
  - ".github/workflows/stale.yml"
608
600
  - ".gitignore"
609
601
  - ".hound.yml"
610
602
  - ".localeapp/config.rb"
611
603
  - ".prettierrc"
612
604
  - ".rubocop.yml"
605
+ - ".travis.yml"
613
606
  - ".yardopts"
614
607
  - CHANGELOG.md
615
608
  - CODE_OF_CONDUCT.md
@@ -626,6 +619,7 @@ files:
626
619
  - app/assets/images/alchemy/icon-white.svg
627
620
  - app/assets/images/alchemy/icon.svg
628
621
  - app/assets/images/alchemy/lupe.cur
622
+ - app/assets/images/alchemy/missing-image.svg
629
623
  - app/assets/javascripts/alchemy/admin.js
630
624
  - app/assets/javascripts/alchemy/alchemy.autocomplete.js.coffee
631
625
  - app/assets/javascripts/alchemy/alchemy.base.js.coffee
@@ -763,8 +757,6 @@ files:
763
757
  - app/controllers/concerns/alchemy/admin/current_language.rb
764
758
  - app/controllers/concerns/alchemy/admin/uploader_responses.rb
765
759
  - app/controllers/concerns/alchemy/legacy_page_redirects.rb
766
- - app/controllers/concerns/alchemy/locale_redirects.rb
767
- - app/controllers/concerns/alchemy/page_redirects.rb
768
760
  - app/controllers/concerns/alchemy/site_redirects.rb
769
761
  - app/decorators/alchemy/content_editor.rb
770
762
  - app/decorators/alchemy/element_editor.rb
@@ -786,6 +778,7 @@ files:
786
778
  - app/mailers/alchemy/base_mailer.rb
787
779
  - app/mailers/alchemy/messages_mailer.rb
788
780
  - app/models/alchemy/attachment.rb
781
+ - app/models/alchemy/attachment/url.rb
789
782
  - app/models/alchemy/base_record.rb
790
783
  - app/models/alchemy/content.rb
791
784
  - app/models/alchemy/content/factory.rb
@@ -821,9 +814,15 @@ files:
821
814
  - app/models/alchemy/page/page_scopes.rb
822
815
  - app/models/alchemy/page/url_path.rb
823
816
  - app/models/alchemy/picture.rb
817
+ - app/models/alchemy/picture/calculations.rb
824
818
  - app/models/alchemy/picture/preprocessor.rb
825
819
  - app/models/alchemy/picture/transformations.rb
826
820
  - app/models/alchemy/picture/url.rb
821
+ - app/models/alchemy/picture_thumb.rb
822
+ - app/models/alchemy/picture_thumb/create.rb
823
+ - app/models/alchemy/picture_thumb/signature.rb
824
+ - app/models/alchemy/picture_thumb/uid.rb
825
+ - app/models/alchemy/picture_variant.rb
827
826
  - app/models/alchemy/site.rb
828
827
  - app/models/alchemy/site/layout.rb
829
828
  - app/models/alchemy/tag.rb
@@ -1076,6 +1075,8 @@ files:
1076
1075
  - db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb
1077
1076
  - db/migrate/20200514091507_make_page_layoutpage_null_false.rb
1078
1077
  - db/migrate/20200519073500_remove_visible_from_alchemy_pages.rb
1078
+ - db/migrate/20200617110713_create_alchemy_picture_thumbs.rb
1079
+ - db/migrate/20200907111332_remove_tri_state_booleans.rb
1079
1080
  - lib/alchemy/ability_helper.rb
1080
1081
  - lib/alchemy/admin/locale.rb
1081
1082
  - lib/alchemy/admin/preview_url.rb
@@ -1124,6 +1125,7 @@ files:
1124
1125
  - lib/alchemy/test_support/factories/node_factory.rb
1125
1126
  - lib/alchemy/test_support/factories/page_factory.rb
1126
1127
  - lib/alchemy/test_support/factories/picture_factory.rb
1128
+ - lib/alchemy/test_support/factories/picture_thumb_factory.rb
1127
1129
  - lib/alchemy/test_support/factories/site_factory.rb
1128
1130
  - lib/alchemy/test_support/fixtures/image.png
1129
1131
  - lib/alchemy/test_support/integration_helpers.rb
@@ -1134,7 +1136,6 @@ files:
1134
1136
  - lib/alchemy/upgrader/five_point_zero.rb
1135
1137
  - lib/alchemy/upgrader/tasks/element_views_updater.rb
1136
1138
  - lib/alchemy/upgrader/tasks/harden_gutentag_migrations.rb
1137
- - lib/alchemy/userstamp.rb
1138
1139
  - lib/alchemy/version.rb
1139
1140
  - lib/alchemy_cms.rb
1140
1141
  - lib/generators/alchemy/base.rb
@@ -1181,6 +1182,7 @@ files:
1181
1182
  - lib/kaminari/scoped_pagination_url_helper.rb
1182
1183
  - lib/tasks/alchemy/db.rake
1183
1184
  - lib/tasks/alchemy/install.rake
1185
+ - lib/tasks/alchemy/thumbnails.rake
1184
1186
  - lib/tasks/alchemy/tidy.rake
1185
1187
  - lib/tasks/alchemy/upgrade.rake
1186
1188
  - package.json
@@ -1264,17 +1266,17 @@ require_paths:
1264
1266
  - lib
1265
1267
  required_ruby_version: !ruby/object:Gem::Requirement
1266
1268
  requirements:
1267
- - - "~>"
1269
+ - - ">="
1268
1270
  - !ruby/object:Gem::Version
1269
- version: '2.3'
1271
+ version: 2.3.0
1270
1272
  required_rubygems_version: !ruby/object:Gem::Requirement
1271
1273
  requirements:
1272
- - - ">="
1274
+ - - ">"
1273
1275
  - !ruby/object:Gem::Version
1274
- version: '0'
1276
+ version: 1.3.1
1275
1277
  requirements:
1276
1278
  - ImageMagick (libmagick), v6.6 or greater.
1277
- rubygems_version: 3.2.26
1279
+ rubygems_version: 3.0.3
1278
1280
  signing_key:
1279
1281
  specification_version: 4
1280
1282
  summary: A powerful, userfriendly and flexible CMS for Rails
@@ -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,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