alchemy_cms 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +1 -1
- data/app/controllers/alchemy/admin/base_controller.rb +5 -9
- data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
- data/app/models/alchemy/content.rb +1 -1
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_text_editor.html.erb +2 -1
- data/lib/alchemy/admin/locale.rb +66 -0
- data/lib/alchemy/engine.rb +1 -1
- data/lib/alchemy/resource.rb +9 -4
- data/lib/alchemy/resources_helper.rb +3 -3
- data/lib/alchemy/upgrader/tasks/available_contents_upgrader.rb +7 -1
- data/lib/alchemy/version.rb +1 -1
- metadata +3 -3
- data/lib/alchemy/locale.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1447225839cddd63cc43645f83ab0ed6cd98493
|
4
|
+
data.tar.gz: c8976f40e5106dca884d4ff4a71a295622483cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d2fafce6f1c2ee32597a8a0c028184fcff046d4ffdbb4a79959b1b132185d7d92c571d8bd066545d6484798cc3bc99022bd33210a1ac45713e268b865303fe6
|
7
|
+
data.tar.gz: ba306bd99dbd07d682a7fa5e1c22f1b0719b9b46368b463ed92ed8e73f3b51ddff8fea999f8432e234cc5a1181a2da489a90d20a204c7bbc5d01da05bf4e91e1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 3.3.1 (2016-06-20)
|
4
|
+
|
5
|
+
* Fix use of Alchemy::Resource with namespaced models (#729)
|
6
|
+
* Allow setting the type of EssenceText input fields in the elements.yml via `settings[:input_type]`
|
7
|
+
* Admin locale switching does not switch language tree any more (#1065)
|
8
|
+
* Fixes bug where old site session causes not found errors (#1047)
|
9
|
+
* Fix inability to add nested elements on pages with cells (#1039)
|
10
|
+
* Skip upgrader if no element definitions are found (#1060)
|
11
|
+
* Fix selecting the active cell for elements with nested elements (#1041)
|
12
|
+
|
3
13
|
## 3.3.0 (2016-05-18)
|
4
14
|
|
5
15
|
__New Features__
|
@@ -72,7 +72,7 @@ Alchemy.ElementEditors =
|
|
72
72
|
selectCellForElement: ($element) ->
|
73
73
|
$cells = $("#cells .sortable_cell")
|
74
74
|
if $cells.size() > 0
|
75
|
-
$cell = $element.
|
75
|
+
$cell = $element.closest(".sortable_cell")
|
76
76
|
$("#cells").tabs("option", "active", $cells.index($cell))
|
77
77
|
|
78
78
|
# Marks an element as selected in the element window and scrolls to it.
|
@@ -28,7 +28,7 @@ Alchemy.Initializer = ->
|
|
28
28
|
$('select#change_locale').on 'change', (e) ->
|
29
29
|
url = window.location.pathname
|
30
30
|
delimiter = if url.match(/\?/) then '&' else '?'
|
31
|
-
window.location.href = "#{url}#{delimiter}
|
31
|
+
window.location.href = "#{url}#{delimiter}admin_locale=#{$(this).val()}"
|
32
32
|
|
33
33
|
# Site select handler
|
34
34
|
$('select#change_site').on 'change', (e) ->
|
@@ -2,7 +2,7 @@ module Alchemy
|
|
2
2
|
module Admin
|
3
3
|
class BaseController < Alchemy::BaseController
|
4
4
|
include Userstamp
|
5
|
-
include
|
5
|
+
include Locale
|
6
6
|
|
7
7
|
before_action { enforce_ssl if ssl_required? && !request.ssl? }
|
8
8
|
before_action :load_locked_pages
|
@@ -172,14 +172,10 @@ module Alchemy
|
|
172
172
|
#
|
173
173
|
def current_alchemy_site
|
174
174
|
@current_alchemy_site ||= begin
|
175
|
-
site_id = params[:site_id] || session[:
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
else
|
180
|
-
session[:site_id] = site_id
|
181
|
-
Site.find(site_id)
|
182
|
-
end
|
175
|
+
site_id = params[:site_id] || session[:alchemy_site_id]
|
176
|
+
site = Site.find_by(id: site_id) || super
|
177
|
+
session[:alchemy_site_id] = site.id
|
178
|
+
site
|
183
179
|
end
|
184
180
|
end
|
185
181
|
end
|
@@ -49,7 +49,7 @@ module Alchemy
|
|
49
49
|
resource_instance_variable.save
|
50
50
|
render_errors_or_redirect(
|
51
51
|
resource_instance_variable,
|
52
|
-
resources_path(resource_handler.
|
52
|
+
resources_path(resource_handler.namespaced_resources_name, current_location_params),
|
53
53
|
flash_notice_for_resource_action
|
54
54
|
)
|
55
55
|
end
|
@@ -58,7 +58,7 @@ module Alchemy
|
|
58
58
|
resource_instance_variable.update_attributes(resource_params)
|
59
59
|
render_errors_or_redirect(
|
60
60
|
resource_instance_variable,
|
61
|
-
resources_path(resource_handler.
|
61
|
+
resources_path(resource_handler.namespaced_resources_name, current_location_params),
|
62
62
|
flash_notice_for_resource_action
|
63
63
|
)
|
64
64
|
end
|
@@ -241,7 +241,7 @@ module Alchemy
|
|
241
241
|
# Returns true if there is a tinymce setting defined on the content definiton
|
242
242
|
# or if the +essence.has_tinymce?+ returns true.
|
243
243
|
def has_tinymce?
|
244
|
-
settings[:tinymce].present? || essence.has_tinymce?
|
244
|
+
settings[:tinymce].present? || (essence.present? && essence.has_tinymce?)
|
245
245
|
end
|
246
246
|
|
247
247
|
# Returns true if there is a tinymce setting defined that contains settings.
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<%- else -%>
|
7
7
|
<%= alchemy_form_for [:admin, @element] do |form| %>
|
8
8
|
<%= form.hidden_field :page_id %>
|
9
|
-
<%- if @page.can_have_cells? -%>
|
9
|
+
<%- if @page.can_have_cells? && @parent_element.blank? -%>
|
10
10
|
<%= form.input :name,
|
11
11
|
label: Alchemy.t(:element_of_type),
|
12
12
|
collection: grouped_elements_for_select(@elements),
|
@@ -5,7 +5,8 @@
|
|
5
5
|
content.form_field_name,
|
6
6
|
content.ingredient,
|
7
7
|
class: ["thin_border #{content.settings[:linkable] ? ' text_with_icon' : ''}", html_options[:class]].join(' '),
|
8
|
-
style: html_options[:style]
|
8
|
+
style: html_options[:style],
|
9
|
+
type: content.settings_value(:input_type) || "text"
|
9
10
|
) %>
|
10
11
|
<% if content.settings[:linkable] %>
|
11
12
|
<%= hidden_field_tag content.form_field_name(:link), content.essence.link %>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Alchemy
|
2
|
+
module Admin
|
3
|
+
module Locale
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_action :set_translation
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Sets Alchemy's GUI translation.
|
13
|
+
#
|
14
|
+
# Uses the most preferred locale or falls back to the default locale if none of the preferred is available.
|
15
|
+
#
|
16
|
+
# It respects the default translation from your +config/application.rb+ +default_locale+ config option.
|
17
|
+
#
|
18
|
+
def set_translation
|
19
|
+
if locale_change_needed?
|
20
|
+
locale = available_locale || ::I18n.default_locale
|
21
|
+
else
|
22
|
+
locale = session[:alchemy_locale]
|
23
|
+
end
|
24
|
+
::I18n.locale = session[:alchemy_locale] = locale
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks if we need to change to locale or not.
|
28
|
+
def locale_change_needed?
|
29
|
+
params[:admin_locale].present? || session[:alchemy_locale].blank?
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns either the most preferred locale that is within the list of available locales or nil
|
33
|
+
#
|
34
|
+
# The availability of the locales is checked in the exact order of either
|
35
|
+
#
|
36
|
+
# * the passed parameter: +params[:admin_locale]+
|
37
|
+
# * the user's locale
|
38
|
+
# * the locale of the browser
|
39
|
+
#
|
40
|
+
def available_locale
|
41
|
+
locales = [params[:admin_locale], locale_from_user, locale_from_browser].compact
|
42
|
+
locales.detect { |locale| ::I18n.available_locales.include?(locale.to_sym) }
|
43
|
+
end
|
44
|
+
|
45
|
+
# Try to get the locale from user settings.
|
46
|
+
def locale_from_user
|
47
|
+
return if !current_alchemy_user
|
48
|
+
if user_has_preferred_language?
|
49
|
+
current_alchemy_user.language
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Checks if the +current_alchemy_user+ has a preferred language set or not.
|
54
|
+
def user_has_preferred_language?
|
55
|
+
return if !current_alchemy_user
|
56
|
+
current_alchemy_user.respond_to?(:language) &&
|
57
|
+
current_alchemy_user.language.present?
|
58
|
+
end
|
59
|
+
|
60
|
+
# Try to get the locale from browser headers.
|
61
|
+
def locale_from_browser
|
62
|
+
request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /\A[a-z]{2}/).try(:first)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/alchemy/engine.rb
CHANGED
@@ -23,6 +23,7 @@ require 'turbolinks'
|
|
23
23
|
require 'userstamp'
|
24
24
|
|
25
25
|
# Require globally used Alchemy mixins
|
26
|
+
require_relative './admin/locale'
|
26
27
|
require_relative './auth_accessors'
|
27
28
|
require_relative './cache_digests/template_tracker'
|
28
29
|
require_relative './config'
|
@@ -34,7 +35,6 @@ require_relative './filetypes'
|
|
34
35
|
require_relative './forms/builder'
|
35
36
|
require_relative './hints'
|
36
37
|
require_relative './i18n'
|
37
|
-
require_relative './locale'
|
38
38
|
require_relative './logger'
|
39
39
|
require_relative './modules'
|
40
40
|
require_relative './mount_point'
|
data/lib/alchemy/resource.rb
CHANGED
@@ -117,10 +117,15 @@ module Alchemy
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def namespaced_resource_name
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
@_namespaced_resource_name ||= namespaced_resources_name.singularize
|
121
|
+
end
|
122
|
+
|
123
|
+
def namespaced_resources_name
|
124
|
+
@_namespaced_resources_name ||= begin
|
125
|
+
resource_name_array = resource_array.dup
|
126
|
+
resource_name_array.delete(engine_name) if in_engine?
|
127
|
+
resource_name_array.join('_')
|
128
|
+
end
|
124
129
|
end
|
125
130
|
|
126
131
|
def namespace_for_scope
|
@@ -31,16 +31,16 @@ module Alchemy
|
|
31
31
|
@_resource_scope ||= [resource_url_proxy].concat(resource_handler.namespace_for_scope)
|
32
32
|
end
|
33
33
|
|
34
|
-
def resources_path(resource_or_name = resource_handler.
|
34
|
+
def resources_path(resource_or_name = resource_handler.namespaced_resources_name, options = {})
|
35
35
|
polymorphic_path (resource_scope + [resource_or_name]), options
|
36
36
|
end
|
37
37
|
|
38
|
-
def resource_path(resource = resource_handler.
|
38
|
+
def resource_path(resource = resource_handler.namespaced_resource_name, options = {})
|
39
39
|
resources_path(resource, options)
|
40
40
|
end
|
41
41
|
|
42
42
|
def new_resource_path(options = {})
|
43
|
-
new_polymorphic_path (resource_scope + [resource_handler.
|
43
|
+
new_polymorphic_path (resource_scope + [resource_handler.namespaced_resource_name]), options
|
44
44
|
end
|
45
45
|
|
46
46
|
def edit_resource_path(resource = nil, options = {})
|
@@ -9,6 +9,10 @@ module Alchemy::Upgrader::Tasks
|
|
9
9
|
no_tasks do
|
10
10
|
def convert_available_contents
|
11
11
|
config = read_config
|
12
|
+
unless config
|
13
|
+
puts "\nNo elements config found. Skipping."
|
14
|
+
return
|
15
|
+
end
|
12
16
|
|
13
17
|
elements_with_available_contents, new_elements = config.partition do |e|
|
14
18
|
e['available_contents']
|
@@ -39,7 +43,9 @@ module Alchemy::Upgrader::Tasks
|
|
39
43
|
old_config_file = Rails.root.join('config', 'alchemy', 'elements.yml')
|
40
44
|
config = YAML.load_file(old_config_file)
|
41
45
|
|
42
|
-
|
46
|
+
if config
|
47
|
+
puts "done.\n"
|
48
|
+
end
|
43
49
|
|
44
50
|
config
|
45
51
|
end
|
data/lib/alchemy/version.rb
CHANGED
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: 3.3.
|
4
|
+
version: 3.3.1
|
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: 2016-
|
16
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: actionpack-page_caching
|
@@ -812,6 +812,7 @@ files:
|
|
812
812
|
- db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb
|
813
813
|
- db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb
|
814
814
|
- db/migrate/20150906195818_add_locale_to_alchemy_languages.rb
|
815
|
+
- lib/alchemy/admin/locale.rb
|
815
816
|
- lib/alchemy/auth_accessors.rb
|
816
817
|
- lib/alchemy/cache_digests/template_tracker.rb
|
817
818
|
- lib/alchemy/config.rb
|
@@ -825,7 +826,6 @@ files:
|
|
825
826
|
- lib/alchemy/hints.rb
|
826
827
|
- lib/alchemy/i18n.rb
|
827
828
|
- lib/alchemy/kaminari/scoped_pagination_url_helper.rb
|
828
|
-
- lib/alchemy/locale.rb
|
829
829
|
- lib/alchemy/logger.rb
|
830
830
|
- lib/alchemy/modules.rb
|
831
831
|
- lib/alchemy/mount_point.rb
|
data/lib/alchemy/locale.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
module Locale
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
before_action :set_translation
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Sets Alchemy's GUI translation.
|
12
|
-
#
|
13
|
-
# Uses the most preferred locale or falls back to the default locale if none of the preferred is available.
|
14
|
-
#
|
15
|
-
# It respects the default translation from your +config/application.rb+ +default_locale+ config option.
|
16
|
-
#
|
17
|
-
def set_translation
|
18
|
-
if locale_change_needed?
|
19
|
-
locale = available_locale || ::I18n.default_locale
|
20
|
-
else
|
21
|
-
locale = session[:alchemy_locale]
|
22
|
-
end
|
23
|
-
::I18n.locale = session[:alchemy_locale] = locale
|
24
|
-
end
|
25
|
-
|
26
|
-
# Checks if we need to change to locale or not.
|
27
|
-
def locale_change_needed?
|
28
|
-
params[:locale].present? || session[:alchemy_locale].blank?
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns either the most preferred locale that is within the list of available locales or nil
|
32
|
-
#
|
33
|
-
# The availability of the locales is checked in the exact order of either
|
34
|
-
#
|
35
|
-
# * the passed parameter: +params[:locale]+
|
36
|
-
# * the user's locale
|
37
|
-
# * the locale of the browser
|
38
|
-
#
|
39
|
-
def available_locale
|
40
|
-
locales = [params[:locale], locale_from_user, locale_from_browser].compact
|
41
|
-
locales.detect { |locale| ::I18n.available_locales.include?(locale.to_sym) }
|
42
|
-
end
|
43
|
-
|
44
|
-
# Try to get the locale from user settings.
|
45
|
-
def locale_from_user
|
46
|
-
return if !current_alchemy_user
|
47
|
-
if user_has_preferred_language?
|
48
|
-
current_alchemy_user.language
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Checks if the +current_alchemy_user+ has a preferred language set or not.
|
53
|
-
def user_has_preferred_language?
|
54
|
-
return if !current_alchemy_user
|
55
|
-
current_alchemy_user.respond_to?(:language) &&
|
56
|
-
current_alchemy_user.language.present?
|
57
|
-
end
|
58
|
-
|
59
|
-
# Try to get the locale from browser headers.
|
60
|
-
def locale_from_browser
|
61
|
-
request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /\A[a-z]{2}/).try(:first)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|