Skip to content

Commit

Permalink
Merge pull request #3041 from AlchemyCMS/remove-7x-deprecations
Browse files Browse the repository at this point in the history
Remove 7.x deprecations
  • Loading branch information
tvdeyen authored Sep 19, 2024
2 parents 3a146ed + fbe82b4 commit 26a409b
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 528 deletions.
73 changes: 0 additions & 73 deletions app/helpers/alchemy/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,6 @@ def sites_for_select
end
end

# Returns a javascript driven live filter for lists.
#
# The items must have a html +name+ attribute that holds the filterable value.
#
# == Example
#
# Given a list of items:
#
# <%= js_filter_field('#products .product') %>
#
# <ul id="products">
# <li class="product" name="kat litter">Kat Litter</li>
# <li class="product" name="milk">Milk</li>
# </ul>
#
# @param [String] items
# A jquery compatible selector string that represents the items to filter
# @param [Hash] options
# HTML options passed to the input field
#
# @option options [String] :class ('js_filter_field')
# The css class of the <input> tag
# @option options [String or Hash] :data ({'alchemy-list-filter' => items})
# A HTML data attribute that holds the jQuery selector that represents the list to be filtered
# @deprecated render Alchemy::Admin::ListFilter.new(items) instead
def js_filter_field(items, _options = {})
render Alchemy::Admin::ListFilter.new(items)
end
deprecate js_filter_field: "render Alchemy::Admin::ListFilter.new(items) instead", deprecator: Alchemy::Deprecation

# Returns a link that opens a modal confirmation to delete window.
#
# === Example:
Expand Down Expand Up @@ -220,49 +190,6 @@ def render_alchemy_title
"Alchemy CMS - #{title}"
end

# Renders a toolbar button for the Alchemy toolbar
#
# == Example
#
# <%= toolbar_button(
# icon: :plus,
# label: 'Create',
# url: new_resource_path,
# title: 'Create Resource',
# hotkey: 'alt+n',
# dialog_options: {
# title: 'Create Resource',
# size: "430x400"
# },
# if_permitted_to: [:create, resource_model]
# ) %>
#
# @option options [String] :icon
# Icon class. See +app/assets/stylesheets/alchemy/icons.css.sccs+ for available icons, or make your own.
# @option options [String] :label
# Text for button label.
# @option options [String] :url
# Url for link.
# @option options [String] :title
# Text for title tag.
# @option options [String] :hotkey
# Keyboard shortcut for this button. I.E +alt-n+
# @option options [Boolean] :dialog (true)
# Open the link in a modal dialog.
# @option options [Hash] :dialog_options
# Overlay options. See link_to_dialog helper.
# @option options [Array] :if_permitted_to ([:action, :controller])
# Check permission for button. Exactly how you defined the permission in your +authorization_rules.rb+. Defaults to controller and action from button url.
# @option options [Boolean] :skip_permission_check (false)
# Skip the permission check. NOT RECOMMENDED!
# @option options [Boolean] :loading_indicator (true)
# Shows the please wait dialog while loading. Only for buttons not opening an dialog.
# @deprecated render Alchemy::Admin::ToolbarButton.new instead
def toolbar_button(options = {})
render Alchemy::Admin::ToolbarButton.new(**options)
end
deprecate toolbar_button: "render Alchemy::Admin::ToolbarButton.new instead", deprecator: Alchemy::Deprecation

# Renders a textfield ready to display a datepicker
#
# A Javascript observer converts this into a fancy Datepicker.
Expand Down
30 changes: 0 additions & 30 deletions app/helpers/alchemy/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

module Alchemy
module BaseHelper
# An alias for truncate.
# Left here for downwards compatibilty.
# @deprecated
def shorten(text, length)
text.truncate(length: length)
end
deprecate :shorten, deprecator: Alchemy::Deprecation

# Logs a message in the Rails logger (warn level)
# and optionally displays an error message to the user.
def warning(message, text = nil)
Expand Down Expand Up @@ -45,27 +37,5 @@ def render_icon(icon_name, options = {})
def render_message(type = :info, msg = nil, &)
render Alchemy::Admin::Message.new(msg || capture(&), type: type)
end

# Checks if the given argument is a String or a Page object.
# If a String is given, it tries to find the page via page_layout
# Logs a warning if no page is given.
# @deprecated
def page_or_find(page)
unless Current.language
warning("No default language set up")
return nil
end

if page.is_a?(String)
page = Current.language.pages.find_by(page_layout: page)
end
if page.blank?
warning("No Page found for #{page.inspect}")
nil
else
page
end
end
deprecate :page_or_find, deprecator: Alchemy::Deprecation
end
end
14 changes: 0 additions & 14 deletions app/helpers/alchemy/elements_block_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,8 @@ def ingredient_by_role(role)
# A lambda used for formatting the element's tags (see Alchemy::ElementsHelper::element_tags_attributes). Set to +false+ to not include tags in the wrapper element.
#
def element_view_for(element, options = {})
if options[:id].nil?
Alchemy::Deprecation.warn <<~WARN
Relying on an implicit DOM id in `element_view_for` is deprecated. Please provide an explicit `id` if you actually want to render an `id` attribute on the #{element.name} element wrapper tag.
WARN
end

if options[:class].nil?
Alchemy::Deprecation.warn <<~WARN
Relying on an implicit CSS class in `element_view_for` is deprecated. Please provide an explicit `class` for the #{element.name} element wrapper tag.
WARN
end

options = {
tag: :div,
id: (!!options[:id]) ? options[:id] : element.dom_id,
class: element.name,
tags_formatter: ->(tags) { tags.join(" ") }
}.merge(options)

Expand Down
18 changes: 0 additions & 18 deletions app/models/alchemy/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,6 @@ def new(attributes = {})
super(element_definition.merge(element_attributes).except(*FORBIDDEN_DEFINITION_ATTRIBUTES))
end

# The class responsible for the +dom_id+ of elements.
# Defaults to +Alchemy::Element::DomId+.
# @deprecated
def dom_id_class
if caller.none? { |l| l =~ Regexp.new("alchemy/element/presenters.rb:87:in `dom_id'") }
Alchemy::Deprecation.warn("dom_id_class is deprecated and will be removed from Alchemy 8.0. Please pass an id to the element_view_for helper instead.")
end
@_dom_id_class || DomId
end

# Register a custom +DomId+ class responsible for the +dom_id+ of elements.
# Defaults to +Alchemy::Element::DomId+.
# @deprecated
def dom_id_class=(klass)
@_dom_id_class = klass
end
deprecate :dom_id_class=, deprecator: Alchemy::Deprecation

# This methods does a copy of source and all its ingredients.
#
# == Options
Expand Down
31 changes: 0 additions & 31 deletions app/models/alchemy/element/dom_id.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/models/alchemy/element/presenters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ def display_name_with_preview_text(maxlength = 30)
"#{display_name}: #{preview_text(maxlength)}"
end

# Returns a dom id used for elements html id tag.
# @deprecated
def dom_id
if caller.none? { |l| l =~ Regexp.new("alchemy/elements_block_helper.rb:117:in `element_view_for'") }
Alchemy::Deprecation.warn("dom_id is deprecated and will be removed from Alchemy 8.0. Please pass an id to the element_view_for helper instead.")
end
self.class.dom_id_class.new(self).call
end

# The ingredient that's used for element's preview text.
#
# It tries to find one of element's ingredients that is defined +as_element_title+.
Expand Down
14 changes: 0 additions & 14 deletions app/models/alchemy/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,6 @@ def on_current_site
on_site(Current.site)
end

# Store the current language in the current thread.
# @deprecated Use {Alchemy::Current#language=} instead.
def current=(language)
Current.language = language
end
deprecate "current=": :"Alchemy::Current.language=", deprecator: Alchemy::Deprecation

# Current language from current thread or default.
# @deprecated Use {Alchemy::Current#language} instead.
def current
Current.language
end
deprecate current: :"Alchemy::Current.language", deprecator: Alchemy::Deprecation

# The root page of the current language.
def current_root_page
Current.language&.pages&.language_roots&.first
Expand Down
14 changes: 0 additions & 14 deletions app/models/alchemy/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,6 @@ def searchable_alchemy_resource_attributes
%w[name urlname title]
end

# Used to store the current page previewed in the edit page template.
# @deprecated Use {Alchemy::Current#preview_page=} instead.
def current_preview=(page)
Current.preview_page = page
end
deprecate "current_preview=": :"Alchemy::Current.preview_page=", deprecator: Alchemy::Deprecation

# Returns the current page previewed in the edit page template.
# @deprecated Use {Alchemy::Current#preview_page} instead.
def current_preview
Current.preview_page
end
deprecate current_preview: :"Alchemy::Current.preview_page", deprecator: Alchemy::Deprecation

# @return the language root page for given language id.
# @param language_id [Fixnum]
#
Expand Down
15 changes: 0 additions & 15 deletions app/models/alchemy/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,6 @@ def default_language
end

class << self
# @deprecated Use {Alchemy::Current#site=} instead.
def current=(site)
Current.site = site
end
deprecate "current=": :"Alchemy::Current.site=", deprecator: Alchemy::Deprecation

# @deprecated Use {Alchemy::Current#site} instead.
def current
Current.site
end
deprecate current: :"Alchemy::Current.site", deprecator: Alchemy::Deprecation

alias_method :default, :first
deprecate default: :first, deprecator: Alchemy::Deprecation

def find_for_host(host)
# These are split up into two separate queries in order to run the
# fastest query first (selecting the domain by its primary host name).
Expand Down
1 change: 0 additions & 1 deletion app/serializers/alchemy/element_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class ElementSerializer < ActiveModel::Serializer
:tag_list,
:created_at,
:updated_at,
:dom_id,
:display_name

has_many :nested_elements
Expand Down
19 changes: 3 additions & 16 deletions app/views/alchemy/admin/ingredients/_file_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
<% css_classes = ingredient.settings[:css_classes] %>

<%= f.input :link_text %>
<%= f.input :title %>
<%- if css_classes.present? -%>
<%= f.input :css_class,
collection: css_classes,
include_blank: Alchemy.t('None') %>
<%- else -%>
<% Alchemy::Deprecation.warn %(Float positioning in File ingredients is deprecated. If you rely on them, please use `css_classes` in your "#{ingredient.role}" settings instead.) %>
<%= f.input :css_class,
label: Alchemy.t(:position_in_text),
collection: [
[Alchemy.t(:above), "no_float"],
[Alchemy.t(:left), "left"],
[Alchemy.t(:right), "right"]
], include_blank: Alchemy.t('Layout default') %>
<%- end -%>
<%= f.input :css_class,
collection: ingredient.settings[:css_classes],
include_blank: Alchemy.t('None') %>
9 changes: 0 additions & 9 deletions app/views/alchemy/admin/ingredients/_picture_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,4 @@
end
end %>
<%= f.input :css_class, collection: css_classes_collection, include_blank: false %>
<%- else -%>
<% Alchemy::Deprecation.warn %(Float positioning in Picture ingredients is deprecated. If you rely on them, please use `css_classes` in your "#{ingredient.role}" settings instead.) %>
<%= f.input :css_class,
label: Alchemy.t(:position_in_text),
collection: [
[Alchemy.t(:above), "no_float"],
[Alchemy.t(:left), "left"],
[Alchemy.t(:right), "right"]
], include_blank: Alchemy.t("Layout default") %>
<%- end -%>
32 changes: 0 additions & 32 deletions app/views/alchemy/admin/resources/_resource.html.erb

This file was deleted.

29 changes: 0 additions & 29 deletions app/views/alchemy/admin/resources/_table.html.erb

This file was deleted.

Loading

0 comments on commit 26a409b

Please sign in to comment.