alchemy_cms 7.0.0.pre.b → 7.0.0.pre.c

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +21 -1
  3. data/.github/workflows/{ci.yml → test.yml} +1 -1
  4. data/.gitignore +0 -5
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +0 -1
  7. data/README.md +3 -3
  8. data/Rakefile +0 -19
  9. data/alchemy_cms.gemspec +2 -1
  10. data/app/assets/config/alchemy_manifest.js +1 -0
  11. data/app/assets/javascripts/alchemy/admin.js +0 -1
  12. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +1 -1
  13. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +5 -12
  14. data/app/assets/stylesheets/alchemy/base.scss +2 -2
  15. data/app/controllers/alchemy/base_controller.rb +0 -7
  16. data/{package/src → app/javascript/alchemy_admin}/node_tree.js +2 -2
  17. data/{package/src → app/javascript/alchemy_admin}/page_publication_fields.js +1 -1
  18. data/{package/src → app/javascript/alchemy_admin}/page_sorter.js +1 -1
  19. data/{package/src → app/javascript/alchemy_admin}/picture_editors.js +2 -2
  20. data/{package/src → app/javascript/alchemy_admin}/sitemap.js +4 -4
  21. data/app/javascript/alchemy_admin.js +34 -0
  22. data/app/views/alchemy/_menubar.html.erb +1 -1
  23. data/app/views/alchemy/admin/attachments/_replace_button.html.erb +1 -1
  24. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -1
  25. data/app/views/alchemy/admin/nodes/index.html.erb +4 -2
  26. data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +1 -1
  27. data/app/views/alchemy/admin/pages/edit.html.erb +3 -4
  28. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  29. data/app/views/alchemy/admin/pages/update.js.erb +2 -2
  30. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -1
  31. data/app/views/alchemy/admin/styleguide/index.html.erb +1 -1
  32. data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
  33. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  34. data/app/views/alchemy/base/redirect.js.erb +1 -1
  35. data/app/views/layouts/alchemy/admin.html.erb +4 -8
  36. data/bin/importmap +4 -0
  37. data/bin/setup +0 -9
  38. data/bin/start +1 -1
  39. data/config/brakeman.ignore +0 -46
  40. data/config/importmap.rb +8 -0
  41. data/lib/alchemy/engine.rb +14 -0
  42. data/lib/alchemy/upgrader/seven_point_zero.rb +13 -23
  43. data/lib/alchemy/upgrader.rb +0 -11
  44. data/lib/alchemy/version.rb +1 -1
  45. data/lib/alchemy.rb +5 -0
  46. data/lib/alchemy_cms.rb +2 -1
  47. data/lib/generators/alchemy/install/files/application.html.erb +2 -2
  48. data/lib/generators/alchemy/install/install_generator.rb +0 -24
  49. data/lib/tasks/alchemy/upgrade.rake +6 -12
  50. data/package.json +6 -26
  51. metadata +44 -27
  52. data/package/admin.js +0 -34
  53. data/package/dist/admin.js +0 -16
  54. data/package/dist/admin.js.map +0 -7
  55. data/package/src/__tests__/i18n.spec.js +0 -93
  56. data/package/src/utils/__tests__/ajax.spec.js +0 -168
  57. data/package/src/utils/__tests__/events.spec.js +0 -38
  58. /data/{package/src → app/javascript/alchemy_admin}/datepicker.js +0 -0
  59. /data/{package/src → app/javascript/alchemy_admin}/file_editors.js +0 -0
  60. /data/{package/src → app/javascript/alchemy_admin}/i18n.js +0 -0
  61. /data/{package/src → app/javascript/alchemy_admin}/image_cropper.js +0 -0
  62. /data/{package/src → app/javascript/alchemy_admin}/image_loader.js +0 -0
  63. /data/{package/src → app/javascript/alchemy_admin}/ingredient_anchor_link.js +0 -0
  64. /data/{package/src → app/javascript/alchemy_admin}/tinymce.js +0 -0
  65. /data/{package/src → app/javascript/alchemy_admin}/translations.js +0 -0
  66. /data/{package/src → app/javascript/alchemy_admin}/utils/ajax.js +0 -0
  67. /data/{package/src → app/javascript/alchemy_admin}/utils/events.js +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1294701d36b22b1003c708713292d905295b3a91b9caabae888c7e75555dd84c
4
- data.tar.gz: 9119c835cd11c74c996466747ddf5c1ad4ba1da42bfe82a52847507a88371513
3
+ metadata.gz: 3d9b2124fdbd7438389b1120a0df30d6ce57a1f353a9ccdae2c59f634b7a60de
4
+ data.tar.gz: ae2985754c1cb922c8ab9c8b3e510ed13d5139c3b96102346b36710a18f2db5e
5
5
  SHA512:
6
- metadata.gz: f16b17350ebda052f7115a01ecf91274ccbb82bd0c3040701eae28d0cb793f87a62b54302e5caac4861536c0f0edb9f33bf242d6c6fa3d97388c17622aa40d52
7
- data.tar.gz: 2466351d5448f8b2b304e8c7d3338443cbbae3b2df6ba5bdcf25545e3b496fd6de49ad29e6900cc5f70a22ac6585ba10e08414fe21bb734e20096ef0206c6515
6
+ metadata.gz: 8a8965055910fe95085ec5c3ed24ca588d8ab6978463ab4445d762dc1cdcb440f7f6830eb13c09e63d8cbac8fef106f0423ee7689d3bc8f0194fd9e9d474c14a
7
+ data.tar.gz: f570c09d5423ef778c099c5467e7d0d21d0aab5e027581ad1644f3a3c261633a415b50a47605eed83c702d50d3962a16c6e37d8e2f63a319d2b4f43fbe6421a3
@@ -3,7 +3,7 @@ name: Lint
3
3
  on: [pull_request]
4
4
 
5
5
  jobs:
6
- Lint:
6
+ Standard:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
9
  - name: Checkout code
@@ -15,3 +15,23 @@ jobs:
15
15
  bundler-cache: true
16
16
  - name: Lint Ruby files
17
17
  run: bundle exec standardrb
18
+ Prettier:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v3
23
+ - name: Setup Node
24
+ uses: actions/setup-node@v3
25
+ with:
26
+ node-version: "18"
27
+ - name: Restore node_modules cache
28
+ uses: actions/cache@v3
29
+ with:
30
+ path: node_modules
31
+ key: ${{ runner.os }}-node-modules-${{ hashFiles('package.json') }}
32
+ restore-keys: |
33
+ ${{ runner.os }}-node-modules
34
+ - name: Install dependencies
35
+ run: yarn install
36
+ - name: Lint code
37
+ run: yarn lint
@@ -1,4 +1,4 @@
1
- name: CI
1
+ name: Test
2
2
 
3
3
  on: [push, pull_request]
4
4
 
data/.gitignore CHANGED
@@ -9,15 +9,10 @@ pkg
9
9
  tmp
10
10
  log
11
11
  .sass-cache
12
- spec/dummy/app/assets/builds/*.js*
13
- spec/dummy/app/javascript/
14
12
  spec/dummy/config/alchemy/config.yml
15
13
  spec/dummy/db/*.sqlite3*
16
- spec/dummy/package.json
17
14
  spec/dummy/postcss.config.js
18
15
  spec/dummy/public/assets/
19
- spec/dummy/public/packs/
20
- spec/dummy/public/packs-test/
21
16
  spec/dummy/uploads/
22
17
  .rvmrc
23
18
  /coverage/
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 7.0.0 (unreleased)
4
4
 
5
+ - Lint JS code with Prettier [#2503](https://github.com/AlchemyCMS/alchemy_cms/pull/2503) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Use absolute imports in modules [#2502](https://github.com/AlchemyCMS/alchemy_cms/pull/2502) ([tvdeyen](https://github.com/tvdeyen))
7
+ - Replace turbolinks with turbo [#2499](https://github.com/AlchemyCMS/alchemy_cms/pull/2499) ([sascha-karnatz](https://github.com/sascha-karnatz))
8
+ - Use Importmaps for admin JS [#2498](https://github.com/AlchemyCMS/alchemy_cms/pull/2498) ([tvdeyen](https://github.com/tvdeyen))
5
9
  - Fix TinyMCE loading behavior after page change [#2494](https://github.com/AlchemyCMS/alchemy_cms/pull/2494) ([sascha-karnatz](https://github.com/sascha-karnatz))
6
10
  - [js] Update esbuild → 0.18.4 (unknown) [#2492](https://github.com/AlchemyCMS/alchemy_cms/pull/2492) ([depfu](https://github.com/apps/depfu))
7
11
  - Add ransackable attributes to tags [#2487](https://github.com/AlchemyCMS/alchemy_cms/pull/2487) ([tvdeyen](https://github.com/tvdeyen))
data/Gemfile CHANGED
@@ -20,7 +20,6 @@ group :development, :test do
20
20
  # in our case the culprit is `handlebars-assets`. The changes between 2.7.0 and 2.8.0 are
21
21
  # minimal, but breaking.
22
22
  gem "execjs", "= 2.8.1"
23
- gem "jsbundling-rails", "~> 1.1"
24
23
  gem "rubocop", require: false
25
24
  gem "standard", "~> 1.25", require: false
26
25
 
data/README.md CHANGED
@@ -340,7 +340,7 @@ $ bin/start
340
340
 
341
341
  ### Bump version
342
342
 
343
- Bump the version number in both `lib/alchemy/version.rb` and `./package.json`. Make sure both are exactly the same and follow [SemVer format](https://semver.org/#semantic-versioning-specification-semver).
343
+ Bump the version number in `lib/alchemy/version.rb`.
344
344
 
345
345
  ### Update the changelog
346
346
 
@@ -357,11 +357,11 @@ $ git commit -am "Bump version to vX.Y.Z"
357
357
 
358
358
  ### Release a new version
359
359
 
360
- This task will publish both the ruby gem and the npm package.
360
+ This task will publish the ruby gem.
361
361
  It also tags the latest commit.
362
362
 
363
363
  ```bash
364
- $ bundle exec rake alchemy:release
364
+ $ bundle exec rake release
365
365
  ```
366
366
 
367
367
  ## ❓Getting Help
data/Rakefile CHANGED
@@ -41,17 +41,12 @@ namespace :alchemy do
41
41
  task :prepare do
42
42
  system(
43
43
  <<~BASH
44
- yarn install && \
45
- yarn link && \
46
44
  cd spec/dummy && \
47
45
  export RAILS_ENV=test && \
48
46
  bin/rake db:create && \
49
47
  bin/rake db:environment:set && \
50
48
  bin/rake db:migrate:reset && \
51
- bin/rails javascript:install:esbuild && \
52
49
  bin/rails g alchemy:install --skip --skip-demo-files --auto-accept --skip-db-create && \
53
- yarn link @alchemy_cms/admin && \
54
- bin/rails javascript:build && \
55
50
  cd -
56
51
  BASH
57
52
  ) || fail
@@ -81,18 +76,4 @@ namespace :alchemy do
81
76
  File.delete(backup)
82
77
  end
83
78
  end
84
-
85
- desc "Release a new Ruby gem and npm package in one command"
86
- task :release do
87
- require "json"
88
- require_relative "lib/alchemy/version"
89
- package = File.read("package.json")
90
- unless JSON.parse(package)["version"] == Alchemy.version
91
- abort "Ruby gem and npm package versions are out of sync! Please fix."
92
- end
93
- # Release the Ruby gem with bundler
94
- Rake::Task["release"].invoke
95
- # Publish npm package via CLI
96
- system "npm publish"
97
- end
98
79
  end
data/alchemy_cms.gemspec CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |gem|
41
41
  gem.add_runtime_dependency "dragonfly_svg", ["~> 0.0.4"]
42
42
  gem.add_runtime_dependency "gutentag", ["~> 2.2", ">= 2.2.1"]
43
43
  gem.add_runtime_dependency "handlebars_assets", ["~> 0.23"]
44
+ gem.add_runtime_dependency "importmap-rails", ["~> 1.2", ">= 1.2.1"]
44
45
  gem.add_runtime_dependency "jquery-rails", ["~> 4.0", ">= 4.0.4"]
45
46
  gem.add_runtime_dependency "jquery-ui-rails", ["~> 6.0"]
46
47
  gem.add_runtime_dependency "kaminari", ["~> 1.1"]
@@ -51,7 +52,7 @@ Gem::Specification.new do |gem|
51
52
  gem.add_runtime_dependency "sassc-rails", ["~> 2.1"]
52
53
  gem.add_runtime_dependency "simple_form", [">= 4.0", "< 6"]
53
54
  gem.add_runtime_dependency "sprockets", [">= 3.0", "< 5"]
54
- gem.add_runtime_dependency "turbolinks", [">= 2.5"]
55
+ gem.add_runtime_dependency "turbo-rails", [">= 1.4"]
55
56
  gem.add_runtime_dependency "view_component", ["~> 3.0"]
56
57
 
57
58
  gem.add_development_dependency "capybara", ["~> 3.0"]
@@ -13,3 +13,4 @@
13
13
  //= link_tree ../images/alchemy/
14
14
  //= link_tree ../../../vendor/assets/fonts/
15
15
  //= link_tree ../../../vendor/assets/images/
16
+ //= link_tree ../../javascript .js
@@ -2,7 +2,6 @@
2
2
  // ------------------------------
3
3
  //= require jquery2
4
4
  //= require jquery_ujs
5
- //= require turbolinks
6
5
  //= require jquery-ui/effects/effect-fade
7
6
  //= require jquery-ui/widgets/draggable
8
7
  //= require jquery-ui/widgets/sortable
@@ -40,7 +40,7 @@ $.extend Alchemy,
40
40
  $form.submit()
41
41
  else if $(element).is("a")
42
42
  callback = ->
43
- Turbolinks.visit(element.pathname)
43
+ Turbo.visit(element.pathname)
44
44
  if Alchemy.isPageDirty()
45
45
  Alchemy.openConfirmDialog Alchemy.t('page_dirty_notice'),
46
46
  title: Alchemy.t('warning')
@@ -1,6 +1,6 @@
1
1
  # Initialize all onload scripts at once.
2
2
  #
3
- # Called at jQuery ready event and Turbolinks page change event.
3
+ # Called at jQuery ready event and Turbo page change event.
4
4
  #
5
5
  Alchemy.Initializer = ->
6
6
 
@@ -26,13 +26,13 @@ Alchemy.Initializer = ->
26
26
  $('select#change_locale').on 'change', (e) ->
27
27
  url = window.location.pathname
28
28
  delimiter = if url.match(/\?/) then '&' else '?'
29
- Turbolinks.visit "#{url}#{delimiter}admin_locale=#{$(this).val()}"
29
+ Turbo.visit "#{url}#{delimiter}admin_locale=#{$(this).val()}"
30
30
 
31
31
  # Site select handler
32
32
  $('select#change_site').on 'change', (e) ->
33
33
  url = window.location.pathname
34
34
  delimiter = if url.match(/\?/) then '&' else '?'
35
- Turbolinks.visit "#{url}#{delimiter}site_id=#{$(this).val()}"
35
+ Turbo.visit "#{url}#{delimiter}site_id=#{$(this).val()}"
36
36
 
37
37
  # Submit forms of selects with `data-autosubmit="true"`
38
38
  $('select[data-auto-submit="true"]').on 'change', (e) ->
@@ -46,18 +46,11 @@ Alchemy.Initializer = ->
46
46
  tagName = (event.target || event.srcElement).tagName
47
47
  key.isPressed('esc') || !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA')
48
48
 
49
- # Enabling the Turbolinks Progress Bar for v2.5
50
- Turbolinks.enableProgressBar() if Turbolinks.enableProgressBar
51
-
52
- # Turbolinks DOM Ready.
53
- # Handle both v2.5(page:change), and v.5.0 (turbolinks:load)
54
- $(document).on 'page:change turbolinks:load', ->
49
+ $(document).on 'turbo:load', ->
55
50
  Alchemy.Initializer()
56
51
  return
57
52
 
58
- # Turbolinks before parsing a new page
59
- # Handle both v2.5(page:receive), and v.5.0 (turbolinks:request-end)
60
- $(document).on 'page:receive turbolinks:request-end', ->
53
+ $(document).on 'turbo:before-fetch-request', ->
61
54
  # Ensure that all tinymce editors get removed before parsing a new page
62
55
  Alchemy.Tinymce.removeFrom $('.has_tinymce')
63
56
  return
@@ -3,8 +3,8 @@ html {
3
3
  height: 100%;
4
4
  font-size: $base-font-size;
5
5
 
6
- &.turbolinks-progress-bar::before,
7
- .turbolinks-progress-bar {
6
+ &.turbo-progress-bar::before,
7
+ .turbo-progress-bar {
8
8
  background-color: $blue !important;
9
9
  z-index: 400001;
10
10
  }
@@ -9,13 +9,6 @@ module Alchemy
9
9
  include Alchemy::ControllerActions
10
10
  include Alchemy::Modules
11
11
 
12
- # Include Turbolinks explicitly in case Alchemy is embedded into a
13
- # larger application that doesn't work with Turbolinks. The app
14
- # can then set config.turbolinks.auto_include = false so that
15
- # Turbolinks is not included in the app controllers.
16
- include Turbolinks::Controller
17
- ::ActionDispatch::Assertions.include ::Turbolinks::Assertions
18
-
19
12
  protect_from_forgery
20
13
 
21
14
  before_action :mailer_set_url_options
@@ -1,6 +1,6 @@
1
1
  import Sortable from "sortablejs"
2
- import { patch } from "./utils/ajax"
3
- import { on } from "./utils/events"
2
+ import { patch } from "alchemy_admin/utils/ajax"
3
+ import { on } from "alchemy_admin/utils/events"
4
4
 
5
5
  function displayNodeFolders() {
6
6
  document.querySelectorAll("li.menu-item").forEach((el) => {
@@ -9,7 +9,7 @@ export default function () {
9
9
  )
10
10
  const public_field = dialog.querySelector("#page_public")
11
11
 
12
- if(!public_field) return
12
+ if (!public_field) return
13
13
 
14
14
  public_field.addEventListener("click", function (evt) {
15
15
  const checkbox = evt.target
@@ -1,5 +1,5 @@
1
1
  import Sortable from "sortablejs"
2
- import { patch } from "./utils/ajax"
2
+ import { patch } from "alchemy_admin/utils/ajax"
3
3
 
4
4
  function onFinishDragging(evt) {
5
5
  const pageId = evt.item.dataset.pageId
@@ -1,7 +1,7 @@
1
1
  import debounce from "lodash-es/debounce"
2
2
  import max from "lodash-es/max"
3
- import { get } from "./utils/ajax"
4
- import ImageLoader from "./image_loader"
3
+ import { get } from "alchemy_admin/utils/ajax"
4
+ import ImageLoader from "alchemy_admin/image_loader"
5
5
 
6
6
  const UPDATE_DELAY = 125
7
7
  const IMAGE_PLACEHOLDER = '<i class="icon far fa-image fa-fw"></i>'
@@ -1,8 +1,8 @@
1
1
  // The admin sitemap Alchemy class
2
- import PageSorter from "./page_sorter"
3
- import { on } from "./utils/events"
4
- import { get, patch } from "./utils/ajax"
5
- import { createSortables, displayPageFolders } from "./page_sorter"
2
+ import PageSorter from "alchemy_admin/page_sorter"
3
+ import { on } from "alchemy_admin/utils/events"
4
+ import { get, patch } from "alchemy_admin/utils/ajax"
5
+ import { createSortables, displayPageFolders } from "alchemy_admin/page_sorter"
6
6
 
7
7
  export default class Sitemap {
8
8
  // Storing some objects.
@@ -0,0 +1,34 @@
1
+ import "@hotwired/turbo-rails"
2
+
3
+ import translate from "alchemy_admin/i18n"
4
+ import translationData from "alchemy_admin/translations"
5
+ import fileEditors from "alchemy_admin/file_editors"
6
+ import IngredientAnchorLink from "alchemy_admin/ingredient_anchor_link"
7
+ import pictureEditors from "alchemy_admin/picture_editors"
8
+ import ImageLoader from "alchemy_admin/image_loader"
9
+ import ImageCropper from "alchemy_admin/image_cropper"
10
+ import Datepicker from "alchemy_admin/datepicker"
11
+ import Sitemap from "alchemy_admin/sitemap"
12
+ import Tinymce from "alchemy_admin/tinymce"
13
+ import PagePublicationFields from "alchemy_admin/page_publication_fields"
14
+
15
+ // Global Alchemy object
16
+ if (typeof window.Alchemy === "undefined") {
17
+ window.Alchemy = {}
18
+ }
19
+
20
+ // Enhance the global Alchemy object with imported features
21
+ Object.assign(Alchemy, {
22
+ // Global utility method for translating a given string
23
+ t: translate,
24
+ translations: Object.assign(Alchemy.translations || {}, translationData),
25
+ fileEditors,
26
+ pictureEditors,
27
+ ImageLoader: ImageLoader.init,
28
+ ImageCropper,
29
+ IngredientAnchorLink,
30
+ Datepicker,
31
+ Sitemap,
32
+ Tinymce,
33
+ PagePublicationFields
34
+ })
@@ -1,5 +1,5 @@
1
1
  <% if !@preview_mode && @page && can?(:edit_content, @page) %>
2
- <div id="alchemy_menubar" style="display: none" data-turbolinks="false">
2
+ <div id="alchemy_menubar" style="display: none" data-turbo="false">
3
3
  <ul>
4
4
  <li><%= link_to Alchemy.t(:to_alchemy), alchemy.admin_dashboard_url %></li>
5
5
  <li><%= link_to Alchemy.t(:edit_page), alchemy.edit_admin_page_url(@page) %></li>
@@ -17,7 +17,7 @@
17
17
  selector: '#replace_<%= dom_id(object) %>',
18
18
  file_types: '<%= file_types.join("|") %>',
19
19
  complete: function() {
20
- Turbolinks.visit('<%= redirect_url.html_safe %>');
20
+ Turbo.visit('<%= redirect_url.html_safe %>');
21
21
  }
22
22
  };
23
23
  Alchemy.Uploader(options);
@@ -1 +1 @@
1
- Turbolinks.visit('<%= @url %>');
1
+ Turbo.visit('<%= @url %>');
@@ -42,6 +42,8 @@
42
42
  <% end %>
43
43
  </div>
44
44
 
45
- <script>
46
- Alchemy.NodeTree()
45
+ <script type="module">
46
+ import NodeTree from "alchemy_admin/node_tree"
47
+
48
+ NodeTree()
47
49
  </script>
@@ -23,7 +23,7 @@
23
23
  $("#page_layout").on("change", function(e) {
24
24
  var url = "<%= alchemy.admin_pages_path(search_filter_params.except(:page_layout, :page).merge(view: "list")) %>";
25
25
  delimiter = url.match(/\?/) ? "&" : "?";
26
- Turbolinks.visit(url + delimiter + "page_layout=" + encodeURIComponent($(this).val()));
26
+ Turbo.visit(url + delimiter + "page_layout=" + encodeURIComponent($(this).val()));
27
27
  });
28
28
  });
29
29
  </script>
@@ -81,7 +81,7 @@
81
81
  host: @page.site.host == "*" ? request.host : @page.site.host,
82
82
  ),
83
83
  title: Alchemy.t("Visit page"),
84
- data: { turbolinks: false },
84
+ data: { turbo: false },
85
85
  target: "_blank",
86
86
  class: 'icon_button' do %>
87
87
  <%= render_icon('external-link-alt') %>
@@ -140,12 +140,11 @@
140
140
  <% content_for :javascripts do %>
141
141
 
142
142
  <% content_for :javascript_includes do %>
143
- <meta name="turbolinks-cache-control" content="no-cache">
143
+ <meta name="turbo-cache-control" content="no-cache">
144
144
  <% end %>
145
145
 
146
146
  <script type="text/javascript" charset="utf-8">
147
-
148
- $(function() {
147
+ $(document).one('turbo:load', function() {
149
148
  $('#unlock_page_form, #publish_page_form').on('submit', function(event) {
150
149
  var not_dirty = Alchemy.checkPageDirtyness(this);
151
150
  if (!not_dirty) Alchemy.pleaseWaitOverlay(false);
@@ -1,5 +1,5 @@
1
1
  <% content_for :javascript_includes do %>
2
- <meta name="turbolinks-cache-control" content="no-cache">
2
+ <meta name="turbo-cache-control" content="no-cache">
3
3
  <% end %>
4
4
 
5
5
  <% content_for :toolbar do %>
@@ -31,11 +31,11 @@
31
31
  Alchemy.growl("<%= j @notice %>");
32
32
  Alchemy.closeCurrentDialog();
33
33
  } else {
34
- document.addEventListener('turbolinks:load', function () {
34
+ document.addEventListener('turbo:load', function () {
35
35
  Alchemy.growl("<%= j @notice %>");
36
36
  }, { once: true })
37
37
  Alchemy.closeCurrentDialog(function() {
38
- Turbolinks.visit(location.toString(), { action: "replace" });
38
+ Turbo.visit(location.toString(), { action: "replace" });
39
39
  });
40
40
  }
41
41
 
@@ -19,7 +19,7 @@
19
19
  if ($this.data('remote') === true) {
20
20
  $.get(path, params.toString(), null, 'script');
21
21
  } else {
22
- Turbolinks.visit(path + '?' + params.toString());
22
+ Turbo.visit(path + '?' + params.toString());
23
23
  }
24
24
  return false;
25
25
  });
@@ -3,7 +3,7 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :javascript_includes do %>
6
- <meta name="turbolinks-cache-control" content="no-cache">
6
+ <meta name="turbo-cache-control" content="no-cache">
7
7
  <% end %>
8
8
 
9
9
  <% content_for(:toolbar) do %>
@@ -27,7 +27,7 @@
27
27
  <% if local_assigns[:in_dialog] %>
28
28
  $.get(url, null, null, 'script');
29
29
  <% else %>
30
- Turbolinks.visit(url);
30
+ Turbo.visit(url);
31
31
  <% end %>
32
32
  }
33
33
  };
@@ -1,3 +1,3 @@
1
1
  Alchemy.closeCurrentDialog(function() {
2
- Turbolinks.visit('<%= Alchemy.login_path %>');
2
+ Turbo.visit('<%= Alchemy.login_path %>');
3
3
  });
@@ -1,7 +1,7 @@
1
1
  (function() {
2
2
  var dialog = Alchemy.currentDialog();
3
3
  var callback = function() {
4
- Turbolinks.visit('<%= url_for(@redirect_url) %>');
4
+ Turbo.visit('<%= url_for(@redirect_url) %>');
5
5
  };
6
6
  if (dialog) {
7
7
  Alchemy.closeCurrentDialog(callback);
@@ -7,8 +7,8 @@
7
7
  <link rel="shortcut icon" href="<%= asset_path('alchemy/favicon.ico') %>">
8
8
  <%= csrf_meta_tag %>
9
9
  <meta name="robots" content="noindex">
10
- <%= stylesheet_link_tag('alchemy/admin/all', media: 'screen', 'data-turbolinks-track' => true) %>
11
- <%= stylesheet_link_tag('alchemy/print', media: 'print', 'data-turbolinks-track' => true) %>
10
+ <%= stylesheet_link_tag('alchemy/admin/all', media: 'screen', 'data-turbo-track' => true) %>
11
+ <%= stylesheet_link_tag('alchemy/print', media: 'print', 'data-turbo-track' => true) %>
12
12
  <%= yield :stylesheets %>
13
13
  <script>
14
14
  // Global Alchemy JavaScript object.
@@ -33,12 +33,8 @@
33
33
  };
34
34
  </script>
35
35
  <%= render 'alchemy/admin/partials/routes' %>
36
- <%= javascript_include_tag('alchemy/admin/all', 'data-turbolinks-track' => true) %>
37
- <% if respond_to?(:javascript_pack_tag) %>
38
- <%= javascript_pack_tag('alchemy/admin', 'data-turbolinks-track' => true) %>
39
- <% else %>
40
- <%= javascript_include_tag('alchemy_admin', 'data-turbolinks-track' => true) %>
41
- <% end %>
36
+ <%= javascript_include_tag('alchemy/admin/all', 'data-turbo-track' => true) %>
37
+ <%= javascript_importmap_tags("alchemy_admin", importmap: Alchemy.importmap) %>
42
38
  <%= yield :javascript_includes %>
43
39
  </head>
44
40
  <%= content_tag :body, id: 'alchemy', class: alchemy_body_class do %>
data/bin/importmap ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../spec/dummy/config/application"
4
+ require "importmap/commands"
data/bin/setup CHANGED
@@ -12,23 +12,14 @@ def system!(*args)
12
12
  end
13
13
 
14
14
  FileUtils.chdir GEM_ROOT do
15
- puts "\n== Linking Admin JS package =="
16
- system! "yarn link"
17
- puts "== Installing dependencies =="
18
- system! "yarn install"
19
15
  system! "gem install bundler --conservative"
20
16
  system("bundle check") || system!("bundle install")
21
17
  end
22
18
 
23
19
  FileUtils.chdir APP_ROOT do
24
20
  puts "\n== Installing Alchemy into dummy app =="
25
- system!("bin/rails javascript:install:esbuild")
26
21
  system!("bin/rails g alchemy:install --skip --skip-demo-files --auto-accept")
27
22
 
28
- puts "\n== Link Alchemy admin package =="
29
- system! "yarn link @alchemy_cms/admin"
30
- system! "yarn install"
31
-
32
23
  puts "\n== Removing old logs and tempfiles =="
33
24
  system! "bin/rails log:clear tmp:clear"
34
25
  end
data/bin/start CHANGED
@@ -13,5 +13,5 @@ end
13
13
 
14
14
  FileUtils.chdir APP_ROOT do
15
15
  puts "\n== Starting dummy app =="
16
- system! "bin/dev"
16
+ system! "bin/rails server"
17
17
  end
@@ -80,29 +80,6 @@
80
80
  ],
81
81
  "note": ""
82
82
  },
83
- {
84
- "warning_type": "Command Injection",
85
- "warning_code": 14,
86
- "fingerprint": "6addfcb9d23d2d6f699f2f3542169744ff749dc4d0a97f8ac783ab92593e1d84",
87
- "check_name": "Execute",
88
- "message": "Possible command injection",
89
- "file": "lib/alchemy/upgrader.rb",
90
- "line": 33,
91
- "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
92
- "code": "`yarn add @alchemy_cms/admin@~#{Alchemy.version}`",
93
- "render_path": null,
94
- "location": {
95
- "type": "method",
96
- "class": "Alchemy::Upgrader",
97
- "method": "update_npm_package"
98
- },
99
- "user_input": "Alchemy.version",
100
- "confidence": "Medium",
101
- "cwe_id": [
102
- 77
103
- ],
104
- "note": "The alchemy version is safe"
105
- },
106
83
  {
107
84
  "warning_type": "Cross-Site Scripting",
108
85
  "warning_code": 4,
@@ -227,29 +204,6 @@
227
204
  ],
228
205
  "note": ""
229
206
  },
230
- {
231
- "warning_type": "Command Injection",
232
- "warning_code": 14,
233
- "fingerprint": "98ca8e77026312eaa7eec15ce26bfe45aa8dd0fcd38e4cff104cb9dffbde1733",
234
- "check_name": "Execute",
235
- "message": "Possible command injection",
236
- "file": "lib/alchemy/upgrader.rb",
237
- "line": 31,
238
- "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
239
- "code": "`bin/importmap pin @alchemy_cms/admin@~#{Alchemy.version}`",
240
- "render_path": null,
241
- "location": {
242
- "type": "method",
243
- "class": "Alchemy::Upgrader",
244
- "method": "update_npm_package"
245
- },
246
- "user_input": "Alchemy.version",
247
- "confidence": "Medium",
248
- "cwe_id": [
249
- 77
250
- ],
251
- "note": ""
252
- },
253
207
  {
254
208
  "warning_type": "File Access",
255
209
  "warning_code": 16,
@@ -0,0 +1,8 @@
1
+ pin "flatpickr", to: "https://ga.jspm.io/npm:flatpickr@4.6.13/dist/esm/index.js", preload: true
2
+ pin "lodash-es/debounce", to: "https://ga.jspm.io/npm:lodash-es@4.17.21/debounce.js", preload: true
3
+ pin "lodash-es/max", to: "https://ga.jspm.io/npm:lodash-es@4.17.21/max.js", preload: true
4
+ pin "sortablejs", to: "https://ga.jspm.io/npm:sortablejs@1.15.0/modular/sortable.esm.js", preload: true
5
+ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
6
+
7
+ pin "alchemy_admin", to: "alchemy_admin.js", preload: true
8
+ pin_all_from File.expand_path("../app/javascript/alchemy_admin", __dir__), under: "alchemy_admin"