alchemy_cms 7.0.0.pre.b → 7.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) 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 +7 -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 -2
  12. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +0 -21
  13. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +1 -1
  14. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +5 -12
  15. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +1 -6
  16. data/app/assets/stylesheets/alchemy/base.scss +2 -2
  17. data/app/controllers/alchemy/api/pages_controller.rb +0 -2
  18. data/app/controllers/alchemy/base_controller.rb +0 -7
  19. data/{package/src → app/javascript/alchemy_admin}/node_tree.js +2 -2
  20. data/{package/src → app/javascript/alchemy_admin}/page_publication_fields.js +1 -1
  21. data/{package/src → app/javascript/alchemy_admin}/page_sorter.js +1 -1
  22. data/{package/src → app/javascript/alchemy_admin}/picture_editors.js +2 -2
  23. data/{package/src → app/javascript/alchemy_admin}/sitemap.js +4 -4
  24. data/app/javascript/alchemy_admin.js +34 -0
  25. data/app/models/alchemy/element.rb +5 -4
  26. data/app/views/alchemy/_menubar.html.erb +1 -1
  27. data/app/views/alchemy/admin/attachments/_replace_button.html.erb +1 -1
  28. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -1
  29. data/app/views/alchemy/admin/nodes/index.html.erb +4 -2
  30. data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +1 -1
  31. data/app/views/alchemy/admin/pages/edit.html.erb +3 -4
  32. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  33. data/app/views/alchemy/admin/pages/update.js.erb +2 -2
  34. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -1
  35. data/app/views/alchemy/admin/styleguide/index.html.erb +1 -1
  36. data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
  37. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  38. data/app/views/alchemy/base/redirect.js.erb +1 -1
  39. data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +0 -1
  40. data/app/views/alchemy/ingredients/shared/_picture_tools.html.erb +0 -1
  41. data/app/views/layouts/alchemy/admin.html.erb +4 -8
  42. data/bin/importmap +4 -0
  43. data/bin/setup +0 -9
  44. data/bin/start +1 -1
  45. data/config/brakeman.ignore +0 -46
  46. data/config/importmap.rb +8 -0
  47. data/lib/alchemy/engine.rb +14 -0
  48. data/lib/alchemy/permissions.rb +4 -4
  49. data/lib/alchemy/upgrader/seven_point_zero.rb +13 -23
  50. data/lib/alchemy/upgrader.rb +0 -11
  51. data/lib/alchemy/version.rb +1 -1
  52. data/lib/alchemy.rb +5 -0
  53. data/lib/alchemy_cms.rb +2 -1
  54. data/lib/generators/alchemy/install/files/application.html.erb +2 -2
  55. data/lib/generators/alchemy/install/install_generator.rb +0 -24
  56. data/lib/tasks/alchemy/upgrade.rake +6 -12
  57. data/package.json +6 -26
  58. metadata +44 -29
  59. data/app/assets/javascripts/alchemy/alchemy.browser.js.coffee +0 -22
  60. data/app/assets/javascripts/alchemy/alchemy.html5.js +0 -22
  61. data/package/admin.js +0 -34
  62. data/package/dist/admin.js +0 -16
  63. data/package/dist/admin.js.map +0 -7
  64. data/package/src/__tests__/i18n.spec.js +0 -93
  65. data/package/src/utils/__tests__/ajax.spec.js +0 -168
  66. data/package/src/utils/__tests__/events.spec.js +0 -38
  67. /data/{package/src → app/javascript/alchemy_admin}/datepicker.js +0 -0
  68. /data/{package/src → app/javascript/alchemy_admin}/file_editors.js +0 -0
  69. /data/{package/src → app/javascript/alchemy_admin}/i18n.js +0 -0
  70. /data/{package/src → app/javascript/alchemy_admin}/image_cropper.js +0 -0
  71. /data/{package/src → app/javascript/alchemy_admin}/image_loader.js +0 -0
  72. /data/{package/src → app/javascript/alchemy_admin}/ingredient_anchor_link.js +0 -0
  73. /data/{package/src → app/javascript/alchemy_admin}/tinymce.js +0 -0
  74. /data/{package/src → app/javascript/alchemy_admin}/translations.js +0 -0
  75. /data/{package/src → app/javascript/alchemy_admin}/utils/ajax.js +0 -0
  76. /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: cf26638792221ec3a204abb8ca19d221b16f6548d6d4a4d0cb01434962c90814
4
+ data.tar.gz: b7ad6adcb58b64e1355fd47d70d7622de73f2fc4016db83b06ffb2631c4fc837
5
5
  SHA512:
6
- metadata.gz: f16b17350ebda052f7115a01ecf91274ccbb82bd0c3040701eae28d0cb793f87a62b54302e5caac4861536c0f0edb9f33bf242d6c6fa3d97388c17622aa40d52
7
- data.tar.gz: 2466351d5448f8b2b304e8c7d3338443cbbae3b2df6ba5bdcf25545e3b496fd6de49ad29e6900cc5f70a22ac6585ba10e08414fe21bb734e20096ef0206c6515
6
+ metadata.gz: ca9665f36097d622e848dc13a5eda0cdc9061e0ac07a319fca261ecfd8572a6c47d9d0ece22672012935e4a83c66768bdd86509ffe05e61e647806a98ed133a4
7
+ data.tar.gz: 85740399b154064e2070e87779abc09c2c44e08bb0b0bb119b12962bc038bd6375ca4d962951b32b3369ac535bf4f83aa714d5605ddbfbaf3e8faf46cb42e8fd
@@ -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,13 @@
2
2
 
3
3
  ## 7.0.0 (unreleased)
4
4
 
5
+ - Allow to create element with warning in definition [#2507](https://github.com/AlchemyCMS/alchemy_cms/pull/2507) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Remove unused javascript [#2506](https://github.com/AlchemyCMS/alchemy_cms/pull/2506) ([sascha-karnatz](https://github.com/sascha-karnatz))
7
+ - Allow authors to link to all pages again [#2504](https://github.com/AlchemyCMS/alchemy_cms/pull/2504) ([tvdeyen](https://github.com/tvdeyen))
8
+ - Lint JS code with Prettier [#2503](https://github.com/AlchemyCMS/alchemy_cms/pull/2503) ([tvdeyen](https://github.com/tvdeyen))
9
+ - Use absolute imports in modules [#2502](https://github.com/AlchemyCMS/alchemy_cms/pull/2502) ([tvdeyen](https://github.com/tvdeyen))
10
+ - Replace turbolinks with turbo [#2499](https://github.com/AlchemyCMS/alchemy_cms/pull/2499) ([sascha-karnatz](https://github.com/sascha-karnatz))
11
+ - Use Importmaps for admin JS [#2498](https://github.com/AlchemyCMS/alchemy_cms/pull/2498) ([tvdeyen](https://github.com/tvdeyen))
5
12
  - Fix TinyMCE loading behavior after page change [#2494](https://github.com/AlchemyCMS/alchemy_cms/pull/2494) ([sascha-karnatz](https://github.com/sascha-karnatz))
6
13
  - [js] Update esbuild → 0.18.4 (unknown) [#2492](https://github.com/AlchemyCMS/alchemy_cms/pull/2492) ([depfu](https://github.com/apps/depfu))
7
14
  - 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
@@ -17,7 +16,6 @@
17
16
  //= require alchemy/templates
18
17
  //= require alchemy/alchemy.base
19
18
  //= require alchemy/alchemy.autocomplete
20
- //= require alchemy/alchemy.browser
21
19
  //= require alchemy/alchemy.buttons
22
20
  //= require alchemy/alchemy.dialog
23
21
  //= require alchemy/alchemy.char_counter
@@ -50,25 +50,4 @@ $.extend Alchemy,
50
50
  dropdownAutoWidth: true
51
51
  return
52
52
 
53
- getUrlParam: (name) ->
54
- results = new RegExp("[\\?&]" + name + "=([^&#]*)").exec(window.location.href)
55
- results[1] or 0 if results
56
- return
57
-
58
- isiPhone: navigator.userAgent.match(/iPhone/i) isnt null
59
- isiPad: navigator.userAgent.match(/iPad/i) isnt null
60
- isiPod: navigator.userAgent.match(/iPod/i) isnt null
61
- isiOS: navigator.userAgent.match(/iPad|iPhone|iPod/i) isnt null
62
- isFirefox: navigator.userAgent.match(/Firefox/i) isnt null
63
- isChrome: navigator.userAgent.match(/Chrome/i) isnt null
64
- isSafari: navigator.userAgent.match(/Safari/i) isnt null
65
- isIE: navigator.userAgent.match(/MSIE/i) isnt null
66
-
67
- Alchemy.getBrowserVersion = (browser) ->
68
- (if Alchemy["is" + browser] then parseInt(navigator.userAgent.match(new RegExp(browser + ".[0-9]+", "i"))[0].replace(new RegExp(browser + "."), ""), 10) else null)
69
- return
70
53
 
71
- Alchemy.ChromeVersion = Alchemy.getBrowserVersion("Chrome")
72
- Alchemy.FirefoxVersion = Alchemy.getBrowserVersion("Firefox")
73
- Alchemy.SafariVersion = Alchemy.getBrowserVersion("Safari")
74
- Alchemy.IEVersion = Alchemy.getBrowserVersion("MSIE")
@@ -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
@@ -59,17 +59,12 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
59
59
  initPageSelect: ->
60
60
  pageTemplate = HandlebarsTemplates.page
61
61
  element_anchor_placeholder = @$element_anchor.attr('placeholder')
62
- if @link_object.dataset.languageId
63
- api_url = "#{Alchemy.routes.api_pages_path}?language_id=#{@link_object.dataset.languageId}"
64
- else
65
- api_url = Alchemy.routes.api_pages_path
66
-
67
62
  @$internal_link.select2
68
63
  placeholder: Alchemy.t('Search page')
69
64
  allowClear: true
70
65
  minimumInputLength: 3
71
66
  ajax:
72
- url: api_url
67
+ url: Alchemy.routes.api_pages_path
73
68
  datatype: 'json'
74
69
  quietMillis: 300
75
70
  data: (term, page) ->
@@ -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
  }
@@ -8,9 +8,7 @@ module Alchemy
8
8
  # Returns all pages as json object
9
9
  #
10
10
  def index
11
- language = Alchemy::Language.find_by(id: params[:language_id]) || Alchemy::Language.current
12
11
  @pages = Alchemy::Page.accessible_by(current_ability, :index)
13
- @pages = @pages.where(language: language)
14
12
  @pages = @pages.includes(*page_includes)
15
13
  @pages = @pages.ransack(params[:q]).result
16
14
 
@@ -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
+ })
@@ -35,13 +35,14 @@ module Alchemy
35
35
  FORBIDDEN_DEFINITION_ATTRIBUTES = [
36
36
  "amount",
37
37
  "autogenerate",
38
- "nestable_elements",
38
+ "compact",
39
+ "deprecated",
39
40
  "hint",
40
41
  "ingredients",
41
- "taggable",
42
- "compact",
43
42
  "message",
44
- "deprecated"
43
+ "nestable_elements",
44
+ "taggable",
45
+ "warning"
45
46
  ].freeze
46
47
 
47
48
  # All Elements that share the same page version and parent element and are fixed or not are considered a list.
@@ -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);
@@ -5,7 +5,6 @@
5
5
  onclick: 'new Alchemy.LinkDialog(this).open(); return false;',
6
6
  class: "icon_button#{ingredient_editor.linked? ? ' linked' : ''} link-ingredient",
7
7
  "data-parent-selector": "[data-ingredient-id='#{ingredient_editor.id}']",
8
- "data-language-id": ingredient_editor.page&.language_id,
9
8
  title: Alchemy.t(:place_link),
10
9
  id: "edit_link_#{ingredient_editor.id}"
11
10
  ) %>
@@ -34,7 +34,6 @@
34
34
  class: picture_editor.linked? ? "linked" : nil,
35
35
  title: Alchemy.t(:link_image),
36
36
  "data-parent-selector": "[data-ingredient-id='#{picture_editor.id}']",
37
- "data-language-id": picture_editor.page&.language_id,
38
37
  id: "edit_link_#{picture_editor.id}"
39
38
  } do %>
40
39
  <span class="disabled" tabindex="-1"><%= render_icon(:link) %></span>
@@ -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"