alchemy_cms 7.1.10 → 7.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b6e517fac0fc0ca7046a00d674d1d11c77bcbaf29a7000ea19a2d124c48fe20
4
- data.tar.gz: 3632b9ff0f939eab1222461620ab417a4dac1aed75e56886ae048085d59769ef
3
+ metadata.gz: 9ce428fb87f5c03ed9aed32da8a1beb525923b719ab3709d88f8793ffd2758f7
4
+ data.tar.gz: e9137ff30538494afe47eccfc7222df05dd46f1f26d7b9f94fdf10a7c1a4ed80
5
5
  SHA512:
6
- metadata.gz: 377a11eb888da3c77610a5a2f69d5beabca2dfa18a948d1040c2237355a33ab5e83735bf4768bdcae3af804b02c4982fa62542587f4e925f60283efd39cee804
7
- data.tar.gz: df98f064d45904b6ef2dcb3cb47e39c8e0fc9487f531e843a8428de6b2387ec2375805814abbb3485c476cdc49a32958cdf104b9b2343b7be707b8a834758566
6
+ metadata.gz: 7c4e7d23419bb5f1fb8f2f1eb1625891e7094a80d4b7a4743ff80efe8179f6a27f500b586fa5ef5cb85658b6ed420906feca11359ff95dddbd15df67cce9f548
7
+ data.tar.gz: 60f81b08733f649563e13ebe23ed594858d872fe250f92bd84d94a73b2fd2b3dc6e0b56cb25559a9d2ba9c84728ee8fec53c61f026fb510d018e4720917cda30
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.1.12 (2024-09-04)
4
+
5
+ - [7.1-stable] Render Datetime ingredient in local time zone [#3018](https://github.com/AlchemyCMS/alchemy_cms/pull/3018) ([tvdeyen](https://github.com/tvdeyen))
6
+ - [7.1-stable] Allow to set input_type on Datetime ingredient editor [#3015](https://github.com/AlchemyCMS/alchemy_cms/pull/3015) ([tvdeyen](https://github.com/tvdeyen))
7
+
8
+ ## 7.1.11 (2024-08-10)
9
+
10
+ - [7.1-stable] fix PictureEditor defaultCropSize [#2991](https://github.com/AlchemyCMS/alchemy_cms/pull/2991) ([alchemycms-bot](https://github.com/alchemycms-bot))
11
+ - [7.1-stable] Fix combining search filters and pagination [#2981](https://github.com/AlchemyCMS/alchemy_cms/pull/2981) ([alchemycms-bot](https://github.com/alchemycms-bot))
12
+ - [7.1-stable] Clear current language when switching sites [#2973](https://github.com/AlchemyCMS/alchemy_cms/pull/2973) ([alchemycms-bot](https://github.com/alchemycms-bot))
13
+ - [7.1-stable] Remove call to missing content_positions task [#2962](https://github.com/AlchemyCMS/alchemy_cms/pull/2962) ([alchemycms-bot](https://github.com/alchemycms-bot))
14
+ - [7.1-stable] Fix re-render of layoutpages form if validation fails [#2953](https://github.com/AlchemyCMS/alchemy_cms/pull/2953) ([alchemycms-bot](https://github.com/alchemycms-bot))
15
+
3
16
  ## 7.1.10 (2024-06-27)
4
17
 
5
18
  - [7.1-stable] Prevent Javascript error if the page will be unlocked [#2945](https://github.com/AlchemyCMS/alchemy_cms/pull/2945) ([alchemycms-bot](https://github.com/alchemycms-bot))
@@ -11,10 +11,11 @@ module Alchemy
11
11
  end
12
12
 
13
13
  def call
14
+ datetime = ingredient.value.in_time_zone(Rails.application.config.time_zone)
14
15
  if date_format == "rfc822"
15
- ingredient.value.to_s(:rfc822)
16
+ datetime.to_fs(:rfc822)
16
17
  else
17
- ::I18n.l(ingredient.value, format: date_format)
18
+ ::I18n.l(datetime, format: date_format)
18
19
  end.html_safe
19
20
  end
20
21
  end
@@ -17,6 +17,25 @@ module Alchemy
17
17
  def edit
18
18
  @page = Page.find(params[:id])
19
19
  end
20
+
21
+ def update
22
+ @page = Page.find(params[:id])
23
+ if @page.update(page_params)
24
+ @notice = Alchemy.t("Page saved", name: @page.name)
25
+ render "alchemy/admin/pages/update"
26
+ else
27
+ render :edit, status: :unprocessable_entity
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def page_params
34
+ params.require(:page).permit(
35
+ :name,
36
+ :tag_list
37
+ )
38
+ end
20
39
  end
21
40
  end
22
41
  end
@@ -6,11 +6,21 @@ module Alchemy
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
+ # This needs to happen before BaseController#current_alchemy_site sets the session value.
10
+ prepend_before_action :clear_current_language_from_session, if: :switching_site?, only: :index
9
11
  before_action :load_current_language
10
12
  end
11
13
 
12
14
  private
13
15
 
16
+ def switching_site?
17
+ params[:site_id].present? && (params[:site_id] != session[:alchemy_site_id]&.to_s)
18
+ end
19
+
20
+ def clear_current_language_from_session
21
+ session.delete(:alchemy_language_id)
22
+ end
23
+
14
24
  def load_current_language
15
25
  @current_language = if session[:alchemy_language_id].present?
16
26
  set_alchemy_language(session[:alchemy_language_id])
@@ -7,7 +7,7 @@ const UPDATE_DELAY = 125
7
7
  const IMAGE_PLACEHOLDER = '<i class="icon ri-image-line ri-fw"></i>'
8
8
  const THUMBNAIL_SIZE = "160x120"
9
9
 
10
- class PictureEditor {
10
+ export class PictureEditor {
11
11
  constructor(container) {
12
12
  this.container = container
13
13
  this.cropFromField = container.querySelector("[data-crop-from]")
@@ -131,10 +131,10 @@ class PictureEditor {
131
131
  if (!this.imageCropperEnabled) return []
132
132
 
133
133
  const mask = this.targetSize.split("x").map((n) => parseInt(n))
134
- const zoom = max([
134
+ const zoom = max(
135
135
  mask[0] / this.imageFileWidth,
136
136
  mask[1] / this.imageFileHeight
137
- ])
137
+ )
138
138
 
139
139
  return [Math.round(mask[0] / zoom), Math.round(mask[1] / zoom)]
140
140
  }
@@ -5,7 +5,7 @@ module Alchemy
5
5
  # A datetime value
6
6
  #
7
7
  class Datetime < Alchemy::Ingredient
8
- allow_settings %i[date_format]
8
+ allow_settings %i[date_format input_type]
9
9
 
10
10
  def value
11
11
  ActiveRecord::Type::DateTime.new.cast(self[:value])
@@ -1,4 +1,4 @@
1
- <%= alchemy_form_for [:admin, @page], class: 'edit_page' do |f| %>
1
+ <%= alchemy_form_for [:admin, @page], url: alchemy.admin_layoutpage_path(@page), class: 'edit_page' do |f| %>
2
2
  <%= f.input :name, autofocus: true %>
3
3
  <div class="input string">
4
4
  <%= f.label :tag_list %>
@@ -1,6 +1,6 @@
1
1
  <%= form_tag url_for, method: :get, class: 'per-page-select-form' do |f| %>
2
2
  <% search_filter_params.reject { |k, _| k == 'page' || k == 'per_page' }.each do |key, value| %>
3
- <% if value.is_a? ActionController::Parameters %>
3
+ <% if value.respond_to?(:keys) %>
4
4
  <% value.each do |k, v| %>
5
5
  <%= hidden_field_tag "#{key}[#{k}]", v, id: nil %>
6
6
  <% end %>
@@ -7,7 +7,8 @@
7
7
  datetime_editor, :value, {
8
8
  name: datetime_editor.form_field_name,
9
9
  id: datetime_editor.form_field_id,
10
- value: datetime_editor.value
10
+ value: datetime_editor.value,
11
+ type: datetime_editor.settings[:input_type]
11
12
  }
12
13
  ) %>
13
14
  <% end %>
data/config/routes.rb CHANGED
@@ -50,7 +50,7 @@ Alchemy::Engine.routes.draw do
50
50
  end
51
51
  end
52
52
 
53
- resources :layoutpages, only: [:index, :edit]
53
+ resources :layoutpages, only: [:index, :edit, :update]
54
54
 
55
55
  resources :pictures, except: [:new] do
56
56
  collection do
@@ -96,7 +96,7 @@ module Alchemy
96
96
  can :leave, :alchemy_admin
97
97
  can [:info, :help], :alchemy_admin_dashboard
98
98
  can :manage, :alchemy_admin_clipboard
99
- can :edit, :alchemy_admin_layoutpages
99
+ can :update, :alchemy_admin_layoutpages
100
100
  can :tree, :alchemy_admin_pages
101
101
 
102
102
  # Resources
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples_for "a controller that loads current language" do |args|
4
+ context "when session has current language id key" do
5
+ let!(:site_1) { create(:alchemy_site) }
6
+ let!(:site_1_default_language) { create :alchemy_language, site: site_1, default: true }
7
+ let!(:another_site_1_language) { create :alchemy_language, site: site_1, code: :de }
8
+ let(:site_2) { create :alchemy_site, host: "another.host", languages: [build(:alchemy_language, code: :en), build(:alchemy_language, code: :de)] }
9
+
10
+ context "on index action" do
11
+ context "when switching the current site" do
12
+ before do
13
+ session[:alchemy_site_id] = site_1.id
14
+ session[:alchemy_language_id] = another_site_1_language.id
15
+ end
16
+
17
+ it "sets @current_language to the new site default language" do
18
+ get :index, params: {site_id: site_2.id}
19
+ expect(assigns(:current_language)).to eq site_2.default_language
20
+ end
21
+ end
22
+
23
+ context "when no language to set" do
24
+ it "shows flash warning with redirect" do
25
+ Alchemy::Language.destroy_all
26
+ get :index, params: {site_id: site_1.id}
27
+ expect(flash[:warning]).to eq Alchemy.t("Please create a language first.")
28
+ expect(response).to redirect_to admin_languages_path
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "7.1.10"
4
+ VERSION = "7.1.12"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -7,7 +7,6 @@ namespace :alchemy do
7
7
  desc "Tidy up Alchemy database."
8
8
  task :up do
9
9
  Rake::Task["alchemy:tidy:element_positions"].invoke
10
- Rake::Task["alchemy:tidy:content_positions"].invoke
11
10
  Rake::Task["alchemy:tidy:remove_orphaned_records"].invoke
12
11
  Rake::Task["alchemy:tidy:remove_trashed_elements"].invoke
13
12
  Rake::Task["alchemy:tidy:remove_duplicate_legacy_urls"].invoke
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: 7.1.10
4
+ version: 7.1.12
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: 2024-06-27 00:00:00.000000000 Z
16
+ date: 2024-09-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionmailer
@@ -1304,6 +1304,7 @@ files:
1304
1304
  - lib/alchemy/test_support.rb
1305
1305
  - lib/alchemy/test_support/capybara_helpers.rb
1306
1306
  - lib/alchemy/test_support/config_stubbing.rb
1307
+ - lib/alchemy/test_support/current_language_shared_examples.rb
1307
1308
  - lib/alchemy/test_support/factories/attachment_factory.rb
1308
1309
  - lib/alchemy/test_support/factories/dummy_user_factory.rb
1309
1310
  - lib/alchemy/test_support/factories/element_factory.rb
@@ -1442,7 +1443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1442
1443
  version: '0'
1443
1444
  requirements:
1444
1445
  - ImageMagick (libmagick), v6.6 or greater.
1445
- rubygems_version: 3.5.11
1446
+ rubygems_version: 3.5.16
1446
1447
  signing_key:
1447
1448
  specification_version: 4
1448
1449
  summary: A powerful, userfriendly and flexible CMS for Rails