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
@@ -1,9 +1,10 @@
|
|
1
1
|
module Alchemy
|
2
2
|
class UserSessionsController < Alchemy::BaseController
|
3
3
|
|
4
|
+
before_filter :set_translation
|
4
5
|
before_filter :check_user_count, :only => :login
|
5
6
|
|
6
|
-
layout 'alchemy/
|
7
|
+
layout 'alchemy/admin'
|
7
8
|
|
8
9
|
helper 'Alchemy::Admin::Base'
|
9
10
|
|
@@ -30,8 +31,6 @@ module Alchemy
|
|
30
31
|
else
|
31
32
|
if request.get?
|
32
33
|
@user_session = UserSession.new()
|
33
|
-
@user_roles = User::ROLES.map { |role| [User.human_rolename(role), role] }
|
34
|
-
@user_genders = User.genders_for_select
|
35
34
|
flash.now[:info] = params[:message] || t("welcome_please_identify_notice")
|
36
35
|
else
|
37
36
|
@user_session = UserSession.new(params[:alchemy_user_session])
|
@@ -51,7 +50,6 @@ module Alchemy
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def leave
|
54
|
-
::I18n.locale = current_user.try(:language)
|
55
53
|
render :layout => false
|
56
54
|
end
|
57
55
|
|
@@ -23,12 +23,12 @@ module Alchemy
|
|
23
23
|
# :overflow [Boolean] # Should the dialog have overlapping content. If not, it shows scrollbars. Good for select boxes. Default false.
|
24
24
|
# :resizable [Boolean] # Is the dialog window resizable? Default false.
|
25
25
|
# :modal [Boolean] # Show as modal window. Default true.
|
26
|
-
# :overflow [Boolean] # Should the window show overflowing content? Default
|
26
|
+
# :overflow [Boolean] # Should the window show overflowing content? Default true.
|
27
27
|
#
|
28
28
|
def link_to_overlay_window(content, url, options={}, html_options={})
|
29
29
|
default_options = {
|
30
30
|
:modal => true,
|
31
|
-
:overflow =>
|
31
|
+
:overflow => true,
|
32
32
|
:resizable => false
|
33
33
|
}
|
34
34
|
options = default_options.merge(options)
|
@@ -121,7 +121,7 @@ module Alchemy
|
|
121
121
|
def link_to_confirmation_window(link_string = "", message = "", url = "", html_options = {})
|
122
122
|
link_to(link_string, url,
|
123
123
|
html_options.merge(
|
124
|
-
'data-alchemy-confirm' => {
|
124
|
+
'data-alchemy-confirm-delete' => {
|
125
125
|
:title => t("please_confirm"),
|
126
126
|
:message => message,
|
127
127
|
:ok_label => t("Yes"),
|
@@ -334,7 +334,7 @@ module Alchemy
|
|
334
334
|
# :overlay_options [Hash] # Overlay options. See link_to_overlay_window helper.
|
335
335
|
# :if_permitted_to [Array] # Check permission for button. [:action, :controller]. Exactly how you defined the permission in your +authorization_rules.rb+. Defaults to controller and action from button url.
|
336
336
|
# :skip_permission_check [Boolean] # Skip the permission check. Default false. NOT RECOMMENDED!
|
337
|
-
# :loading_indicator [Boolean] # Shows the please wait overlay while loading.
|
337
|
+
# :loading_indicator [Boolean] # Shows the please wait overlay while loading. Default false.
|
338
338
|
#
|
339
339
|
def toolbar_button(options = {})
|
340
340
|
options.symbolize_keys!
|
@@ -344,25 +344,25 @@ module Alchemy
|
|
344
344
|
:active => false,
|
345
345
|
:link_options => {},
|
346
346
|
:overlay_options => {},
|
347
|
-
:loading_indicator =>
|
347
|
+
:loading_indicator => false
|
348
348
|
}
|
349
349
|
options = defaults.merge(options)
|
350
350
|
button = content_tag('div', :class => 'button_with_label' + (options[:active] ? ' active' : '')) do
|
351
351
|
link = if options[:overlay]
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
352
|
+
link_to_overlay_window(
|
353
|
+
render_icon(options[:icon]),
|
354
|
+
options[:url],
|
355
|
+
options[:overlay_options],
|
356
|
+
{
|
357
|
+
:class => 'icon_button',
|
358
|
+
:title => options[:title]
|
359
|
+
}
|
360
|
+
)
|
361
|
+
else
|
362
|
+
link_to options[:url], {:class => "icon_button#{options[:loading_indicator] ? nil : ' please_wait'}", :title => options[:title]}.merge(options[:link_options]) do
|
363
|
+
render_icon(options[:icon])
|
364
|
+
end
|
365
|
+
end
|
366
366
|
link += content_tag('label', options[:label])
|
367
367
|
end
|
368
368
|
if options[:skip_permission_check]
|
@@ -454,6 +454,85 @@ module Alchemy
|
|
454
454
|
}.merge(html_options))
|
455
455
|
end
|
456
456
|
|
457
|
+
# Merges the params-hash with the given hash
|
458
|
+
def merge_params(p={})
|
459
|
+
params.merge(p).delete_if { |k, v| v.blank? }
|
460
|
+
end
|
461
|
+
|
462
|
+
# Deletes one or several params from the params-hash and merges some new params in
|
463
|
+
def merge_params_without(excludes, p={})
|
464
|
+
current_params = params.clone.symbolize_keys
|
465
|
+
if excludes.is_a?(Array)
|
466
|
+
excludes.map { |i| current_params.delete(i.to_sym) }
|
467
|
+
else
|
468
|
+
current_params.delete(excludes.to_sym)
|
469
|
+
end
|
470
|
+
current_params.merge(p).delete_if { |k, v| v.blank? }
|
471
|
+
end
|
472
|
+
|
473
|
+
# Deletes all params from the params-hash except the given ones and merges some new params in
|
474
|
+
def merge_params_only(includes, p={})
|
475
|
+
current_params = params.clone.symbolize_keys
|
476
|
+
if includes.is_a?(Array)
|
477
|
+
symbolized_includes = includes.map(&:to_sym)
|
478
|
+
current_params.delete_if { |k, v| !symbolized_includes.include?(k) }
|
479
|
+
else
|
480
|
+
current_params.delete_if { |k, v| k != includes.to_sym }
|
481
|
+
end
|
482
|
+
current_params.merge(p).delete_if { |k, v| v.blank? }
|
483
|
+
end
|
484
|
+
|
485
|
+
# Checks if the pictures tag-filter contains the given tag
|
486
|
+
def pictures_filtered_by_tag?(tag)
|
487
|
+
if params[:tagged_with].present?
|
488
|
+
tags = params[:tagged_with].split(',')
|
489
|
+
tags.include?(tag.name)
|
490
|
+
else
|
491
|
+
false
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
# Adds the given tag to the pictures tag-filter
|
496
|
+
def add_to_picture_tag_filter(tag)
|
497
|
+
if params[:tagged_with].present?
|
498
|
+
tags = params[:tagged_with].split(',')
|
499
|
+
tags << tag.name
|
500
|
+
else
|
501
|
+
[tag.name]
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
# Removes the given tag from the pictures tag-filter
|
506
|
+
def remove_from_picture_tag_filter(tag)
|
507
|
+
if params[:tagged_with].present?
|
508
|
+
tags = params[:tagged_with].split(',')
|
509
|
+
tags.delete_if { |t| t == tag.name }
|
510
|
+
else
|
511
|
+
[]
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
# Returns the picture tag-filter from params.
|
516
|
+
# A tag can be added to the filter.
|
517
|
+
# A tag can also be removed.
|
518
|
+
#
|
519
|
+
# Options are:
|
520
|
+
# * options (Hash):
|
521
|
+
# ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
|
522
|
+
# ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
|
523
|
+
def picture_tag_filter(options={})
|
524
|
+
case
|
525
|
+
when options[:add]
|
526
|
+
taglist = add_to_picture_tag_filter(options[:add]) if options[:add]
|
527
|
+
when options[:remove]
|
528
|
+
taglist = remove_from_picture_tag_filter(options[:remove]) if options[:remove]
|
529
|
+
else
|
530
|
+
return params[:tagged_with]
|
531
|
+
end
|
532
|
+
return nil if taglist.blank?
|
533
|
+
taglist.uniq.join(',')
|
534
|
+
end
|
535
|
+
|
457
536
|
end
|
458
537
|
end
|
459
538
|
end
|
@@ -41,7 +41,7 @@ module Alchemy
|
|
41
41
|
render_icon(:create) + t('add new content'),
|
42
42
|
alchemy.new_admin_element_content_path(element),
|
43
43
|
{
|
44
|
-
:size => '
|
44
|
+
:size => '310x115',
|
45
45
|
:title => t('Select an content'),
|
46
46
|
:overflow => true
|
47
47
|
},
|
@@ -90,7 +90,7 @@ module Alchemy
|
|
90
90
|
:method => :post,
|
91
91
|
:remote => true,
|
92
92
|
:id => "add_content_for_element_#{element.id}",
|
93
|
-
:class => 'button new_content_link'
|
93
|
+
:class => 'button with_icon new_content_link'
|
94
94
|
)
|
95
95
|
end
|
96
96
|
|
@@ -52,11 +52,10 @@ module Alchemy
|
|
52
52
|
:grouped => true
|
53
53
|
}
|
54
54
|
options = default_options.merge(options)
|
55
|
-
picture_contents = element.contents.where(:essence_type => "Alchemy::EssencePicture")
|
56
55
|
render(
|
57
|
-
:partial => "alchemy/admin/elements/
|
56
|
+
:partial => "alchemy/admin/elements/picture_gallery_editor",
|
58
57
|
:locals => {
|
59
|
-
:
|
58
|
+
:pictures => element.contents.gallery_pictures,
|
60
59
|
:element => element,
|
61
60
|
:options => options
|
62
61
|
}
|
@@ -7,13 +7,14 @@ module Alchemy
|
|
7
7
|
text.truncate(:length => length)
|
8
8
|
end
|
9
9
|
|
10
|
-
# Returns @
|
10
|
+
# Returns @language set in the action (e.g. Page.show)
|
11
11
|
def current_language
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
ActiveSupport::Deprecation.warn('This Proxy-method is deprecated. Please use @language directly.')
|
13
|
+
if @language.nil?
|
14
|
+
warning('@language is not set')
|
15
|
+
nil
|
15
16
|
else
|
16
|
-
@
|
17
|
+
@language
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -153,13 +153,13 @@ module Alchemy
|
|
153
153
|
# Returns a string for the id attribute of a html element for the given element
|
154
154
|
def element_dom_id(element)
|
155
155
|
return "" if element.nil?
|
156
|
-
"#{element.name}_#{element.id}"
|
156
|
+
"#{element.name}_#{element.id}"
|
157
157
|
end
|
158
158
|
|
159
159
|
# Renders the data-alchemy-element HTML attribut used for the preview window hover effect.
|
160
160
|
def element_preview_code(element)
|
161
161
|
return "" if element.nil?
|
162
|
-
" data-alchemy-element='#{element.id}'"
|
162
|
+
" data-alchemy-element='#{element.id}'" if @preview_mode && element.page == @page
|
163
163
|
end
|
164
164
|
|
165
165
|
# Returns the full url containing host, page and anchor for the given element
|
@@ -129,15 +129,14 @@ module Alchemy
|
|
129
129
|
# == Options:
|
130
130
|
#
|
131
131
|
# :image_size => "111x93" # Used by EssencePicture to render the image via RMagick to that size. [Default nil]
|
132
|
-
# :date_format => "Am %d. %m. %Y, um %H:%Mh" #
|
133
|
-
# :
|
134
|
-
# :blank_value => "Not found" # Pass a String that gets rendered if the content.essence is blank. [Default nil]
|
132
|
+
# :date_format => "Am %d. %m. %Y, um %H:%Mh" # Especially for EssenceDate. See Rubys Date.strftime for date formatting options. [Default nil]
|
133
|
+
# :show_caption => true # Pass Boolean to show/hide the caption of an EssencePicture. [Default true]
|
135
134
|
#
|
136
135
|
def render_essence_view(content, options = {}, html_options = {})
|
137
136
|
defaults = {
|
138
|
-
:
|
137
|
+
:show_caption => true
|
139
138
|
}
|
140
|
-
render_essence(content, :view, {:for_view => options}, html_options)
|
139
|
+
render_essence(content, :view, {:for_view => defaults.update(options)}, html_options)
|
141
140
|
end
|
142
141
|
|
143
142
|
end
|
@@ -4,6 +4,7 @@ module Alchemy
|
|
4
4
|
include Alchemy::BaseHelper
|
5
5
|
include Alchemy::ElementsHelper
|
6
6
|
include Alchemy::PicturesHelper
|
7
|
+
include Alchemy::UrlHelper
|
7
8
|
|
8
9
|
def render_classes(classes=[])
|
9
10
|
s = classes.uniq.delete_if { |x| x.blank? }.join(" ")
|
@@ -49,7 +50,7 @@ module Alchemy
|
|
49
50
|
return nil if (pages.blank? || pages.length == 1)
|
50
51
|
pages.each_with_index do |page, i|
|
51
52
|
if (options[:link_to_page_with_layout] != nil)
|
52
|
-
page_found_by_layout = Page.where(:page_layout => options[:link_to_page_with_layout].to_s, :language_id => page.language_id)
|
53
|
+
page_found_by_layout = Page.where(:page_layout => options[:link_to_page_with_layout].to_s, :language_id => page.language_id).first
|
53
54
|
end
|
54
55
|
page = page_found_by_layout || page
|
55
56
|
page = (options[:link_to_public_child] ? (page.first_public_child.blank? ? nil : page.first_public_child) : nil) if !page.public?
|
@@ -91,7 +92,6 @@ module Alchemy
|
|
91
92
|
nil
|
92
93
|
end
|
93
94
|
end
|
94
|
-
|
95
95
|
alias_method :language_switches, :language_switcher
|
96
96
|
|
97
97
|
# Renders the layout from @page.page_layout. File resists in /app/views/page_layouts/_LAYOUT-NAME.html.erb
|
@@ -256,7 +256,8 @@ module Alchemy
|
|
256
256
|
:public_only => true,
|
257
257
|
:visible_only => true,
|
258
258
|
:restricted_only => false,
|
259
|
-
:reverse => false
|
259
|
+
:reverse => false,
|
260
|
+
:link_active_page => false
|
260
261
|
}
|
261
262
|
options = default_options.merge(options)
|
262
263
|
pages = breadcrumb(options[:page])
|
@@ -288,7 +289,11 @@ module Alchemy
|
|
288
289
|
elsif page == pages.first
|
289
290
|
css_class = css_class.blank? ? "first" : [css_class, "first"].join(" ")
|
290
291
|
end
|
291
|
-
|
292
|
+
if !options[:link_active_page] && page.name == @page.name
|
293
|
+
bc << content_tag(:span, h(page.name), :class => css_class)
|
294
|
+
else
|
295
|
+
bc << link_to(h(page.name), show_alchemy_page_path(page), :class => css_class, :title => page.title)
|
296
|
+
end
|
292
297
|
end
|
293
298
|
bc.join(options[:seperator]).html_safe
|
294
299
|
end
|
@@ -409,30 +414,6 @@ module Alchemy
|
|
409
414
|
return meta_string.html_safe
|
410
415
|
end
|
411
416
|
|
412
|
-
# This helper returns a path for use inside a link_to helper.
|
413
|
-
#
|
414
|
-
# You may pass a page_layout or an urlname.
|
415
|
-
# Any additional options are passed to the url_helper, so you can add arguments to your url.
|
416
|
-
#
|
417
|
-
# Example:
|
418
|
-
#
|
419
|
-
# <%= link_to '» order now', page_path_for(:page_layout => 'orderform', :product_id => element.id) %>
|
420
|
-
#
|
421
|
-
def page_path_for(options={})
|
422
|
-
return warning("No page_layout, or urlname given. I got #{options.inspect} ") if options[:page_layout].blank? && options[:urlname].blank?
|
423
|
-
if options[:urlname].blank?
|
424
|
-
page = Page.find_by_page_layout(options[:page_layout])
|
425
|
-
if page.blank?
|
426
|
-
warning("No page found for #{options.inspect} ")
|
427
|
-
return
|
428
|
-
end
|
429
|
-
urlname = page.urlname
|
430
|
-
else
|
431
|
-
urlname = options[:urlname]
|
432
|
-
end
|
433
|
-
alchemy.show_page_path({:urlname => urlname, :lang => multi_language? ? session[:language_code] : nil}.merge(options.except(:page_layout, :urlname, :lang)))
|
434
|
-
end
|
435
|
-
|
436
417
|
# Renders the partial for the cell with the given name of the current page.
|
437
418
|
# Cell partials are located in +app/views/cells/+ of your project.
|
438
419
|
#
|
@@ -467,68 +448,23 @@ module Alchemy
|
|
467
448
|
# Renders the search form
|
468
449
|
def render_search_form(options={})
|
469
450
|
default_options = {
|
470
|
-
:
|
471
|
-
:html5 => false,
|
472
|
-
:button_value => t("search"),
|
473
|
-
:button_class => nil
|
451
|
+
:html5 => false
|
474
452
|
}
|
475
|
-
|
476
|
-
|
477
|
-
warning("No page found for #{options[:page].inspect}")
|
453
|
+
if @search_result_page.blank?
|
454
|
+
warning("No search result page found")
|
478
455
|
return
|
479
456
|
end
|
480
|
-
|
481
|
-
if options[:html5]
|
482
|
-
search_field_tag(:query, params[:query])
|
483
|
-
else
|
484
|
-
text_field_tag(:query, params[:query]) + submit_tag(options[:button_value], :class => options[:button_class], :name => nil)
|
485
|
-
end
|
486
|
-
end
|
457
|
+
render :partial => 'alchemy/search/form', :locals => {:options => default_options.merge(options)}
|
487
458
|
end
|
488
459
|
|
489
|
-
# Renders the search
|
460
|
+
# Renders the search +results+ partial from +app/views/alchemy/search/+
|
490
461
|
def render_search_results(options={})
|
491
462
|
default_options = {
|
492
|
-
:partial => 'alchemy/search/result',
|
493
463
|
:show_language => true,
|
494
464
|
:show_result_count => true,
|
495
465
|
:show_heading => true
|
496
466
|
}
|
497
|
-
options
|
498
|
-
return content_tag :h2, t('search_result_page.no_results'), :class => 'no_search_results' if @search_results.blank?
|
499
|
-
results = ""
|
500
|
-
@search_results.each do |essence|
|
501
|
-
result = essence.highlight(
|
502
|
-
"*#{params[:query]}*", {
|
503
|
-
:field => (essence.class.name == "Alchemy::EssenceRichtext" ? :stripped_body : :body)
|
504
|
-
})
|
505
|
-
results << render(:partial => options[:partial], :locals => {:result => result, :options => options, :page => essence.page}) if essence.page
|
506
|
-
end
|
507
|
-
output = ""
|
508
|
-
output << content_tag(:h1, t("search_result_page.result_heading", :query => h(params[:query])), :class => 'search_results_heading') if options[:show_heading]
|
509
|
-
output << content_tag(:h2, t("search_result_page.result_count", :count => @search_results.length), :class => 'search_result_count') if options[:show_result_count]
|
510
|
-
output << content_tag(:ul, results.html_safe, :class => 'search_result_list')
|
511
|
-
content_tag :div, :class => 'search_results' do
|
512
|
-
output.html_safe
|
513
|
-
end
|
514
|
-
end
|
515
|
-
|
516
|
-
# Returns the correct params-hash for passing to show_page_path
|
517
|
-
def show_page_path_params(page, optional_params={})
|
518
|
-
url_params = {:level1 => nil, :level2 => nil, :level3 => nil, :urlname => page.urlname}
|
519
|
-
url_params.update(optional_params)
|
520
|
-
url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
|
521
|
-
return multi_language? ? url_params.update(:lang => page.language_code) : url_params
|
522
|
-
end
|
523
|
-
|
524
|
-
#
|
525
|
-
def show_alchemy_page_path(page, optional_params={})
|
526
|
-
alchemy.show_page_path(show_page_path_params(page, optional_params))
|
527
|
-
end
|
528
|
-
|
529
|
-
#
|
530
|
-
def show_alchemy_page_url(page, optional_params={})
|
531
|
-
alchemy.show_page_url(show_page_path_params(page, optional_params))
|
467
|
+
render 'alchemy/search/results', :options => default_options.merge(options)
|
532
468
|
end
|
533
469
|
|
534
470
|
# Renders a menubar for logged in users that are visiting a page.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Alchemy url helpers
|
2
|
+
#
|
3
|
+
# This helper is included within alchemy/pages_helper
|
4
|
+
#
|
5
|
+
module Alchemy
|
6
|
+
module UrlHelper
|
7
|
+
|
8
|
+
# Returns the correct params-hash for passing to show_page_path
|
9
|
+
def show_page_path_params(page, optional_params={})
|
10
|
+
url_params = {:level1 => nil, :level2 => nil, :level3 => nil, :urlname => page.urlname}
|
11
|
+
url_params.update(optional_params)
|
12
|
+
url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
|
13
|
+
multi_language? ? url_params.update(:lang => page.language_code) : url_params
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the path for rendering an alchemy page
|
17
|
+
def show_alchemy_page_path(page, optional_params={})
|
18
|
+
alchemy.show_page_path(show_page_path_params(page, optional_params))
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the url for rendering an alchemy page
|
22
|
+
def show_alchemy_page_url(page, optional_params={})
|
23
|
+
alchemy.show_page_url(show_page_path_params(page, optional_params))
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the correct params-hash for passing to show_picture_path
|
27
|
+
def show_picture_path_params(picture, optional_params={})
|
28
|
+
url_params = {:id => picture.id, :name => picture.urlname, :format => configuration(:image_output_format)}
|
29
|
+
url_params.update(optional_params.update({:crop => optional_params[:crop] ? 'crop' : nil}))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the path for rendering an alchemy picture
|
33
|
+
def show_alchemy_picture_path(picture, optional_params={})
|
34
|
+
alchemy.show_picture_path(show_picture_path_params(picture, optional_params))
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the url for rendering an alchemy picture
|
38
|
+
def show_alchemy_picture_url(picture, optional_params={})
|
39
|
+
alchemy.show_picture_url(show_picture_path_params(picture, optional_params))
|
40
|
+
end
|
41
|
+
|
42
|
+
# This helper returns a path for use inside a link_to helper.
|
43
|
+
#
|
44
|
+
# You may pass a page_layout or an urlname.
|
45
|
+
# Any additional options are passed to the url_helper, so you can add arguments to your url.
|
46
|
+
#
|
47
|
+
# Example:
|
48
|
+
#
|
49
|
+
# <%= link_to '» order now', page_path_for(:page_layout => 'orderform', :product_id => element.id) %>
|
50
|
+
#
|
51
|
+
def page_path_for(options={})
|
52
|
+
return warning("No page_layout, or urlname given. I got #{options.inspect} ") if options[:page_layout].blank? && options[:urlname].blank?
|
53
|
+
if options[:urlname].blank?
|
54
|
+
page = Page.find_by_page_layout(options[:page_layout])
|
55
|
+
if page.blank?
|
56
|
+
warning("No page found for #{options.inspect} ")
|
57
|
+
return
|
58
|
+
end
|
59
|
+
urlname = page.urlname
|
60
|
+
else
|
61
|
+
urlname = options[:urlname]
|
62
|
+
end
|
63
|
+
alchemy.show_page_path({:urlname => urlname, :lang => multi_language? ? session[:language_code] : nil}.merge(options.except(:page_layout, :urlname, :lang)))
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|