alchemy_cms 2.2.4 → 2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +3 -4
- data/Gemfile +1 -0
- data/README.md +10 -6
- data/alchemy_cms.gemspec +5 -2
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/images/sassy-ie-overlay.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
- data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
- data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
- data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
- data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
- data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
- data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
- data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
- data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
- data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
- data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
- data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
- data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
- data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
- data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
- data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
- data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
- data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
- data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
- data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
- data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
- data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
- data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
- data/app/controllers/alchemy/admin/base_controller.rb +1 -9
- data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
- data/app/controllers/alchemy/attachments_controller.rb +8 -2
- data/app/controllers/alchemy/base_controller.rb +47 -5
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +12 -12
- data/app/controllers/alchemy/pages_controller.rb +5 -1
- data/app/controllers/alchemy/pictures_controller.rb +9 -4
- data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
- data/app/helpers/alchemy/admin/base_helper.rb +98 -19
- data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
- data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
- data/app/helpers/alchemy/base_helper.rb +6 -5
- data/app/helpers/alchemy/elements_helper.rb +2 -2
- data/app/helpers/alchemy/essences_helper.rb +4 -5
- data/app/helpers/alchemy/pages_helper.rb +15 -79
- data/app/helpers/alchemy/url_helper.rb +67 -0
- data/app/mailers/alchemy/messages.rb +1 -1
- data/app/mailers/alchemy/notifications.rb +1 -1
- data/app/models/alchemy/attachment.rb +11 -2
- data/app/models/alchemy/cell.rb +20 -10
- data/app/models/alchemy/content.rb +4 -3
- data/app/models/alchemy/element.rb +170 -178
- data/app/models/alchemy/language/code.rb +4 -1
- data/app/models/alchemy/message.rb +19 -3
- data/app/models/alchemy/page.rb +45 -40
- data/app/models/alchemy/picture.rb +24 -2
- data/app/models/alchemy/user.rb +2 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
- data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
- data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
- data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
- data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
- data/app/views/alchemy/admin/contents/create.js.erb +54 -0
- data/app/views/alchemy/admin/contents/new.html.erb +9 -4
- data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
- data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
- data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
- data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
- data/app/views/alchemy/admin/elements/index.html.erb +24 -24
- data/app/views/alchemy/admin/elements/list.js.erb +11 -9
- data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
- data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
- data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
- data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
- data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
- data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
- data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
- data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
- data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
- data/app/views/alchemy/admin/pages/index.html.erb +26 -24
- data/app/views/alchemy/admin/pages/link.html.erb +2 -5
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
- data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
- data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
- data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
- data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
- data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
- data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
- data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
- data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
- data/app/views/alchemy/admin/resources/index.html.erb +3 -1
- data/app/views/alchemy/admin/users/_table.html.erb +1 -1
- data/app/views/alchemy/admin/users/index.html.erb +27 -23
- data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
- data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
- data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
- data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
- data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
- data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
- data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
- data/app/views/alchemy/search/_form.html.erb +8 -0
- data/app/views/alchemy/search/_result.html.erb +3 -2
- data/app/views/alchemy/search/_results.html.erb +28 -0
- data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
- data/app/views/alchemy/user_sessions/login.html.erb +1 -2
- data/app/views/layouts/alchemy/admin.html.erb +30 -10
- data/app/views/layouts/alchemy/login.html.erb +2 -39
- data/config/alchemy/elements.yml +1 -2
- data/config/alchemy/page_layouts.yml +8 -5
- data/config/authorization_rules.rb +27 -18
- data/config/initializers/localeapp.rb +9 -0
- data/config/locales/alchemy.de.yml +93 -56
- data/config/locales/alchemy.en.yml +73 -50
- data/config/routes.rb +3 -1
- data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
- data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
- data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
- data/lib/alchemy/capistrano.rb +2 -2
- data/lib/alchemy/essence.rb +14 -0
- data/lib/alchemy/page_layout.rb +0 -6
- data/lib/alchemy/resource.rb +9 -15
- data/lib/alchemy/upgrader.rb +18 -3
- data/lib/alchemy/version.rb +5 -1
- data/lib/alchemy_cms.rb +4 -1
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
- data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
- data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
- data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
- data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
- data/lib/tasks/fleximage.rake +2 -2
- data/spec/controllers/admin/contents_controller_spec.rb +2 -2
- data/spec/controllers/admin/elements_controller_spec.rb +30 -1
- data/spec/controllers/admin/pages_controller_spec.rb +35 -18
- data/spec/controllers/admin/trash_controller_spec.rb +40 -16
- data/spec/controllers/attachments_controller_spec.rb +62 -0
- data/spec/controllers/base_controller_spec.rb +43 -42
- data/spec/controllers/elements_controller_spec.rb +30 -0
- data/spec/controllers/pages_controller_spec.rb +22 -5
- data/spec/controllers/pictures_controller_spec.rb +82 -0
- data/spec/dummy/app/models/event.rb +2 -1
- data/spec/dummy/config/database.yml +3 -2
- data/spec/dummy/db/schema.rb +51 -27
- data/spec/factories.rb +29 -8
- data/spec/helpers/admin/base_helper_spec.rb +134 -21
- data/spec/helpers/admin/contents_helper_spec.rb +2 -2
- data/spec/helpers/admin/elements_helper_spec.rb +17 -9
- data/spec/helpers/admin/essences_helper_spec.rb +7 -6
- data/spec/helpers/essences_helper_spec.rb +8 -7
- data/spec/helpers/pages_helper_spec.rb +208 -325
- data/spec/helpers/url_helper_spec.rb +171 -0
- data/spec/integration/admin/link_overlay_spec.rb +53 -0
- data/spec/integration/admin/modules_integration_spec.rb +22 -26
- data/spec/integration/admin/pages_controller_spec.rb +10 -19
- data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
- data/spec/integration/admin/resources_integration_spec.rb +68 -75
- data/spec/integration/pages_controller_spec.rb +70 -61
- data/spec/integration/security_spec.rb +3 -5
- data/spec/integration/translation_integration_spec.rb +56 -0
- data/spec/libraries/essence_spec.rb +18 -0
- data/spec/libraries/resource_spec.rb +101 -79
- data/spec/libraries/resources_helper_spec.rb +3 -0
- data/spec/models/content_spec.rb +63 -60
- data/spec/models/element_spec.rb +203 -93
- data/spec/models/language_spec.rb +90 -65
- data/spec/models/page_layout_spec.rb +37 -0
- data/spec/models/page_spec.rb +181 -113
- data/spec/models/picture_spec.rb +73 -26
- data/spec/models/resource_spec.rb +52 -23
- data/spec/support/alchemy/specs_helpers.rb +2 -0
- data/spec/support/image.png +0 -0
- data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
- data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
- metadata +106 -33
- data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
- data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
- data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
- data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
- data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
- data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
- data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/locales/fo.yml +0 -5
- data/spec/page_layout_spec.rb +0 -35
- data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
- data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -14,15 +14,7 @@ module Alchemy
|
|
14
14
|
|
15
15
|
layout 'alchemy/admin'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
# Setting the Alchemy GUI translation to users preffered language, or taking default translation.
|
20
|
-
# You can set the default translation in your +config/application.rb+ file
|
21
|
-
def set_translation
|
22
|
-
if current_user && current_user.language
|
23
|
-
::I18n.locale = current_user.language
|
24
|
-
end
|
25
|
-
end
|
17
|
+
private
|
26
18
|
|
27
19
|
# Handles exceptions
|
28
20
|
def exception_handler(e)
|
@@ -15,13 +15,13 @@ module Alchemy
|
|
15
15
|
@options = params[:options] || {}
|
16
16
|
@html_options = params[:html_options] || {}
|
17
17
|
if @options.is_a?(String)
|
18
|
-
@options = JSON.parse(@options)
|
18
|
+
@options = @options.present? ? JSON.parse(@options) : {}
|
19
19
|
end
|
20
20
|
if @content.essence_type == "Alchemy::EssencePicture"
|
21
|
-
@content_dom_id = "#
|
21
|
+
@content_dom_id = "#add_picture_#{@element.id}"
|
22
22
|
@content.essence.picture_id = params[:picture_id]
|
23
23
|
@content.essence.save
|
24
|
-
@contents_of_this_type = @element.contents.
|
24
|
+
@contents_of_this_type = @element.contents.gallery_pictures
|
25
25
|
@dragable = @contents_of_this_type.length > 1
|
26
26
|
@options = @options.merge(:dragable => @dragable)
|
27
27
|
else
|
@@ -50,9 +50,7 @@ module Alchemy
|
|
50
50
|
def destroy
|
51
51
|
@content = Content.find(params[:id])
|
52
52
|
@content_dup = @content.clone
|
53
|
-
|
54
|
-
content_name = @content.name
|
55
|
-
@notice = t("Successfully deleted content", :content => content_name)
|
53
|
+
@notice = t("Successfully deleted content", :content => @content.name_for_label)
|
56
54
|
@content.destroy
|
57
55
|
end
|
58
56
|
|
@@ -37,6 +37,7 @@ module Alchemy
|
|
37
37
|
# Creates a element as discribed in config/alchemy/elements.yml on page via AJAX.
|
38
38
|
def create
|
39
39
|
@page = Page.find(params[:element][:page_id])
|
40
|
+
@element_name = params[:element][:name] # storing the original element name, because the model alters the params hash
|
40
41
|
@paste_from_clipboard = !params[:paste_from_clipboard].blank?
|
41
42
|
if @paste_from_clipboard
|
42
43
|
source_element = Element.find(element_from_clipboard[:id])
|
@@ -50,7 +51,6 @@ module Alchemy
|
|
50
51
|
@element = Element.new_from_scratch(params[:element])
|
51
52
|
end
|
52
53
|
put_element_in_cell if @page.can_have_cells?
|
53
|
-
@element.page = @page
|
54
54
|
if @element.save
|
55
55
|
render :action => :create
|
56
56
|
else
|
@@ -103,7 +103,7 @@ module Alchemy
|
|
103
103
|
private
|
104
104
|
|
105
105
|
def put_element_in_cell
|
106
|
-
element_with_cell_name = @paste_from_clipboard ? params[:paste_from_clipboard] :
|
106
|
+
element_with_cell_name = @paste_from_clipboard ? params[:paste_from_clipboard] : @element_name
|
107
107
|
cell_definition = Cell.definition_for(element_with_cell_name.split('#').last) if !element_with_cell_name.blank?
|
108
108
|
if cell_definition
|
109
109
|
@cell = @page.cells.find_or_create_by_name(cell_definition['name'])
|
@@ -101,7 +101,6 @@ module Alchemy
|
|
101
101
|
name = @page.name
|
102
102
|
@page_id = @page.id
|
103
103
|
@layoutpage = @page.layoutpage?
|
104
|
-
session[:language_id] = @page.language_id
|
105
104
|
if @page.destroy
|
106
105
|
@page_root = Page.language_root_for(session[:language_id])
|
107
106
|
@message = t("Page deleted", :name => name)
|
@@ -109,6 +108,8 @@ module Alchemy
|
|
109
108
|
respond_to do |format|
|
110
109
|
format.js
|
111
110
|
end
|
111
|
+
# remove from clipboard
|
112
|
+
get_clipboard.remove(:pages, @page_id)
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
@@ -121,7 +122,6 @@ module Alchemy
|
|
121
122
|
end
|
122
123
|
@area_name = params[:area_name]
|
123
124
|
@content_id = params[:content_id]
|
124
|
-
@link_target_options = Page.link_target_options
|
125
125
|
@attachments = Attachment.all.collect { |f| [f.name, download_attachment_path(:id => f.id, :name => f.name)] }
|
126
126
|
if params[:link_urls_for] == "newsletter"
|
127
127
|
# TODO: links in newsletters has to go through statistic controller. therfore we have to put a string inside the content_rtfs and replace this string with recipient.id before sending the newsletter.
|
@@ -8,8 +8,16 @@ module Alchemy
|
|
8
8
|
respond_to :html, :js
|
9
9
|
|
10
10
|
def index
|
11
|
-
@size = params[:size]
|
12
|
-
@pictures = Picture.
|
11
|
+
@size = params[:size].present? ? params[:size] : 'medium'
|
12
|
+
@pictures = Picture.scoped
|
13
|
+
@pictures = @pictures.tagged_with(params[:tagged_with], :any => true) if params[:tagged_with].present?
|
14
|
+
case params[:filter]
|
15
|
+
when 'recent'
|
16
|
+
@pictures = @pictures.recent
|
17
|
+
when 'last_upload'
|
18
|
+
@pictures = @pictures.last_upload
|
19
|
+
end
|
20
|
+
@pictures = @pictures.find_paginated(params, pictures_per_page_for_size(@size))
|
13
21
|
if in_overlay?
|
14
22
|
archive_overlay
|
15
23
|
else
|
@@ -23,7 +31,7 @@ module Alchemy
|
|
23
31
|
@size = params[:size] || 'medium'
|
24
32
|
if in_overlay?
|
25
33
|
@while_assigning = true
|
26
|
-
@content = Content.
|
34
|
+
@content = Content.find_by_id(params[:content_id], :select => 'id')
|
27
35
|
@element = Element.find(params[:element_id], :select => 'id')
|
28
36
|
@options = hashified_options
|
29
37
|
@page = params[:page]
|
@@ -33,7 +41,10 @@ module Alchemy
|
|
33
41
|
end
|
34
42
|
|
35
43
|
def create
|
36
|
-
@picture = Picture.new(
|
44
|
+
@picture = Picture.new(
|
45
|
+
:image_file => params[:Filedata],
|
46
|
+
:upload_hash => params[:upload_hash]
|
47
|
+
)
|
37
48
|
@picture.name = @picture.humanized_name
|
38
49
|
@picture.save
|
39
50
|
@size = params[:size] || 'medium'
|
@@ -52,17 +63,55 @@ module Alchemy
|
|
52
63
|
flash[:notice] = @message
|
53
64
|
#redirect_to :back
|
54
65
|
#TODO temporary workaround; has to be fixed.
|
55
|
-
redirect_to admin_pictures_path
|
66
|
+
redirect_to admin_pictures_path(:filter => 'last_upload')
|
56
67
|
end
|
57
68
|
end
|
58
69
|
|
70
|
+
def edit
|
71
|
+
@picture = Picture.find(params[:id])
|
72
|
+
render :layout => !request.xhr?
|
73
|
+
end
|
74
|
+
|
75
|
+
def edit_multiple
|
76
|
+
@pictures = Picture.find(params[:picture_ids])
|
77
|
+
render :layout => !request.xhr?
|
78
|
+
end
|
79
|
+
|
59
80
|
def update
|
60
|
-
@size = params[:size] || 'medium'
|
61
81
|
@picture = Picture.find(params[:id])
|
62
|
-
|
63
|
-
@picture.
|
64
|
-
|
65
|
-
|
82
|
+
|
83
|
+
if @picture.update_attributes(params[:picture])
|
84
|
+
flash[:notice] = t('picture_updated_successfully', :name => @picture.name)
|
85
|
+
else
|
86
|
+
flash[:error] = t('picture_update_failed')
|
87
|
+
end
|
88
|
+
redirect_to_index
|
89
|
+
end
|
90
|
+
|
91
|
+
def update_multiple
|
92
|
+
@pictures = Picture.find(params[:picture_ids])
|
93
|
+
@pictures.each do |picture|
|
94
|
+
# Do not delete name from multiple pictures, if the form field is blank!
|
95
|
+
picture.name = params[:pictures_name] if params[:pictures_name].present?
|
96
|
+
picture.tag_list = params[:pictures_tag_list]
|
97
|
+
picture.save
|
98
|
+
end
|
99
|
+
flash[:notice] = t("Pictures updated successfully")
|
100
|
+
redirect_to_index
|
101
|
+
end
|
102
|
+
|
103
|
+
def delete_multiple
|
104
|
+
if request.delete? && params[:picture_ids].present?
|
105
|
+
pictures = Picture.find(params[:picture_ids])
|
106
|
+
names = pictures.map(&:name).to_sentence
|
107
|
+
pictures.each do |picture|
|
108
|
+
picture.destroy
|
109
|
+
end
|
110
|
+
flash[:notice] = t("Pictures deleted successfully", :names => names)
|
111
|
+
else
|
112
|
+
flash[:notice] = t("Could not delete Pictures")
|
113
|
+
end
|
114
|
+
redirect_to_index
|
66
115
|
end
|
67
116
|
|
68
117
|
def destroy
|
@@ -84,16 +133,16 @@ module Alchemy
|
|
84
133
|
render :layout => false
|
85
134
|
end
|
86
135
|
|
87
|
-
|
136
|
+
private
|
88
137
|
|
89
138
|
def pictures_per_page_for_size(size)
|
90
139
|
case size
|
91
140
|
when 'small'
|
92
|
-
per_page = in_overlay? ?
|
141
|
+
per_page = in_overlay? ? 37 : (per_page_value_for_screen_size * 2.9).floor
|
93
142
|
when 'large'
|
94
|
-
per_page = in_overlay? ? 4 : (per_page_value_for_screen_size / 1.7).floor
|
143
|
+
per_page = in_overlay? ? 4 : (per_page_value_for_screen_size / 1.7).floor + 1
|
95
144
|
else
|
96
|
-
per_page = in_overlay? ?
|
145
|
+
per_page = in_overlay? ? 9 : (per_page_value_for_screen_size / 1.0).ceil + 1
|
97
146
|
end
|
98
147
|
return per_page
|
99
148
|
end
|
@@ -111,11 +160,21 @@ module Alchemy
|
|
111
160
|
render :partial => 'archive_overlay'
|
112
161
|
}
|
113
162
|
format.js {
|
114
|
-
render :action =>
|
163
|
+
render :action => 'archive_overlay'
|
115
164
|
}
|
116
165
|
end
|
117
166
|
end
|
118
167
|
|
168
|
+
def redirect_to_index
|
169
|
+
redirect_to(
|
170
|
+
:action => :index,
|
171
|
+
:query => params[:query],
|
172
|
+
:tagged_with => params[:tagged_with],
|
173
|
+
:size => params[:size],
|
174
|
+
:filter => params[:filter]
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
119
178
|
end
|
120
179
|
end
|
121
180
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Alchemy
|
2
2
|
class AttachmentsController < Alchemy::BaseController
|
3
3
|
|
4
|
+
filter_access_to [:show, :download], :attribute_check => true, :model => Alchemy::Attachment, :load_method => :load_attachment
|
5
|
+
|
4
6
|
# sends file inline. i.e. for viewing pdfs/movies in browser
|
5
7
|
def show
|
6
|
-
@attachment = Attachment.find(params[:id])
|
7
8
|
send_file(
|
8
9
|
@attachment.public_filename,
|
9
10
|
{
|
@@ -16,7 +17,6 @@ module Alchemy
|
|
16
17
|
|
17
18
|
# sends file as attachment. aka download
|
18
19
|
def download
|
19
|
-
@attachment = Attachment.find(params[:id])
|
20
20
|
send_file(
|
21
21
|
@attachment.full_filename, {
|
22
22
|
:name => @attachment.filename,
|
@@ -26,5 +26,11 @@ module Alchemy
|
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_attachment
|
32
|
+
@attachment = Attachment.find(params[:id])
|
33
|
+
end
|
34
|
+
|
29
35
|
end
|
30
36
|
end
|
@@ -39,7 +39,29 @@ module Alchemy
|
|
39
39
|
::Alchemy::I18n.t(key, *args)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
# Sets Alchemy's GUI translation to users preffered language and stores it in the session.
|
45
|
+
#
|
46
|
+
# Guesses the language from browser locale. If not successful it takes the default.
|
47
|
+
#
|
48
|
+
# You can set the default translation in your +config/application.rb+ file, via Rails +default_locale+ config option.
|
49
|
+
#
|
50
|
+
# If one passes a locale parameter the locale is set to its value
|
51
|
+
#
|
52
|
+
def set_translation
|
53
|
+
if params[:locale].blank? && session[:current_locale].present?
|
54
|
+
::I18n.locale = session[:current_locale]
|
55
|
+
elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)
|
56
|
+
session[:current_locale] = ::I18n.locale = params[:locale]
|
57
|
+
elsif current_user && current_user.language.present?
|
58
|
+
::I18n.locale = current_user.language
|
59
|
+
elsif Rails.env == 'test' # OMG I hate to do this. But it helps...
|
60
|
+
::I18n.locale = 'en'
|
61
|
+
else
|
62
|
+
::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first)
|
63
|
+
end
|
64
|
+
end
|
43
65
|
|
44
66
|
# Sets the language for rendering pages in pages controller
|
45
67
|
def set_language
|
@@ -101,9 +123,29 @@ module Alchemy
|
|
101
123
|
end
|
102
124
|
end
|
103
125
|
|
126
|
+
# Handles the layout rendering
|
127
|
+
#
|
128
|
+
# Can be used inside the controller´s +layout+ class method
|
129
|
+
#
|
130
|
+
# === Example:
|
131
|
+
# layout :layout_for_page
|
132
|
+
#
|
133
|
+
# === Usage:
|
134
|
+
# 1. You can pass none or false as url parameter to avoid any layout rendering.
|
135
|
+
# 2. You can pass a layout name of any existing layout file in +app/views/layouts+ folder.
|
136
|
+
#
|
137
|
+
# If no layout name is given, Alchemy tries to render +app/views/layouts/application/+ layout.
|
138
|
+
# If that is not present, Alchemy tries to render +app/views/layouts/alchemy/pages+ layout.
|
139
|
+
#
|
104
140
|
def layout_for_page
|
105
|
-
if
|
106
|
-
|
141
|
+
if params[:layout] == 'none' || params[:layout] == 'false'
|
142
|
+
false
|
143
|
+
elsif !params[:layout].blank?
|
144
|
+
if File.exist?(Rails.root.join('app/views/layouts', "#{params[:layout]}.html.erb"))
|
145
|
+
params[:layout]
|
146
|
+
else
|
147
|
+
raise_not_found_error
|
148
|
+
end
|
107
149
|
elsif File.exist?(Rails.root.join('app/views/layouts', 'application.html.erb'))
|
108
150
|
'application'
|
109
151
|
else
|
@@ -116,10 +158,10 @@ module Alchemy
|
|
116
158
|
logger.info "Rendering 404: #{exception.message}"
|
117
159
|
end
|
118
160
|
@page = Page.language_root_for(session[:language_id])
|
119
|
-
render :file =>
|
161
|
+
render :file => Rails.root.join("public/404.html"), :status => 404, :layout => !@page.nil?
|
120
162
|
end
|
121
163
|
|
122
|
-
|
164
|
+
protected
|
123
165
|
|
124
166
|
def permission_denied
|
125
167
|
if current_user
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# == Sending Messages:
|
2
2
|
# To send Messages via contact forms you can create your form fields in the config.yml
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# === Example:
|
5
5
|
# Make an Element with this options inside your @elements.yml file:
|
6
6
|
#
|
@@ -17,9 +17,9 @@
|
|
17
17
|
#
|
18
18
|
# The fields +mail_to+, +mail_from+, +subject+ and +success_page+ are recommended.
|
19
19
|
# The +Alchemy::MessagesController+ uses them to send your mails. So your customer has full controll of these values inside his contactform element.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# Then make a page layout for your contact page in the +page_layouts.yml+ file:
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# - name: contact
|
24
24
|
# unique: true
|
25
25
|
# cache: false
|
@@ -29,12 +29,12 @@
|
|
29
29
|
# Disabling the page caching is stronlgy recommended!
|
30
30
|
#
|
31
31
|
# The editor view for your element should have this layout:
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# <%= render_essence_editor_by_name(element, 'mail_from') %>
|
34
34
|
# <%= render_essence_editor_by_name(element, 'mail_to') %>
|
35
35
|
# <%= render_essence_editor_by_name(element, 'subject') %>
|
36
36
|
# <%= page_selector(element, 'success_page', :page_attribute => :urlname) %>
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# Please have a look at the +alchemy/config/config.yml+ file for further Message settings.
|
39
39
|
|
40
40
|
module Alchemy
|
@@ -76,26 +76,26 @@ module Alchemy
|
|
76
76
|
def mail_to
|
77
77
|
@element.ingredient("mail_to")
|
78
78
|
rescue
|
79
|
-
mailer_config[
|
79
|
+
mailer_config['mail_to']
|
80
80
|
end
|
81
81
|
|
82
82
|
def mail_from
|
83
83
|
@element.ingredient("mail_from")
|
84
84
|
rescue
|
85
|
-
mailer_config[
|
85
|
+
mailer_config['mail_from']
|
86
86
|
end
|
87
87
|
|
88
88
|
def subject
|
89
89
|
@element.ingredient("subject")
|
90
90
|
rescue
|
91
|
-
mailer_config[
|
91
|
+
mailer_config['subject']
|
92
92
|
end
|
93
93
|
|
94
94
|
def redirect_to_success_page
|
95
95
|
if @element.ingredient("success_page")
|
96
96
|
urlname = @element.ingredient("success_page")
|
97
|
-
elsif mailer_config[
|
98
|
-
urlname = Page.find_by_urlname(mailer_config[
|
97
|
+
elsif mailer_config['forward_to_page'] && mailer_config['mail_success_page']
|
98
|
+
urlname = Page.find_by_urlname(mailer_config['mail_success_page']).urlname
|
99
99
|
else
|
100
100
|
flash[:notice] = t(:success, :scope => 'contactform.messages')
|
101
101
|
urlname = Page.language_root_for(session[:language_id]).urlname
|
@@ -104,8 +104,8 @@ module Alchemy
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def get_page
|
107
|
-
@page = Page.find_by_page_layout_and_language_id(mailer_config[
|
108
|
-
raise "Page for page_layout #{mailer_config[
|
107
|
+
@page = Page.find_by_page_layout_and_language_id(mailer_config['page_layout_name'], session[:language_id])
|
108
|
+
raise "Page for page_layout #{mailer_config['page_layout_name']} not found" if @page.blank?
|
109
109
|
@root_page = @page.get_language_root
|
110
110
|
end
|
111
111
|
|
@@ -66,7 +66,11 @@ module Alchemy
|
|
66
66
|
store_language_in_session(@page.language) if @page.present?
|
67
67
|
return @page
|
68
68
|
else
|
69
|
-
@page = Page.contentpages.
|
69
|
+
@page = Page.contentpages.where(
|
70
|
+
:urlname => params[:urlname],
|
71
|
+
:language_id => session[:language_id], # Make sure that the current language
|
72
|
+
:language_code => params[:lang] # matches the requested language code.
|
73
|
+
).first
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -3,10 +3,12 @@ module Alchemy
|
|
3
3
|
|
4
4
|
caches_page :show, :thumbnail, :zoom
|
5
5
|
|
6
|
+
before_filter :load_picture
|
7
|
+
|
8
|
+
filter_access_to :show, :attribute_check => true, :model => Alchemy::Picture, :load_method => :load_picture
|
6
9
|
filter_access_to :thumbnail
|
7
10
|
|
8
11
|
def show
|
9
|
-
@picture = Picture.find(params[:id])
|
10
12
|
@size = params[:size]
|
11
13
|
@crop = !params[:crop].nil?
|
12
14
|
@crop_from = normalized_size(params[:crop_from])
|
@@ -22,7 +24,6 @@ module Alchemy
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def thumbnail
|
25
|
-
@picture = Picture.find(params[:id])
|
26
27
|
case params[:size]
|
27
28
|
when "small"
|
28
29
|
@size = "80x60"
|
@@ -43,10 +44,10 @@ module Alchemy
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def zoom
|
46
|
-
|
47
|
+
#
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
private
|
50
51
|
|
51
52
|
def normalized_size(size)
|
52
53
|
return "" if size.blank?
|
@@ -55,5 +56,9 @@ module Alchemy
|
|
55
56
|
end.join('x')
|
56
57
|
end
|
57
58
|
|
59
|
+
def load_picture
|
60
|
+
@picture ||= Picture.find(params[:id])
|
61
|
+
end
|
62
|
+
|
58
63
|
end
|
59
64
|
end
|