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
@@ -10,10 +10,13 @@ module Alchemy::Language::Code
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
+
|
13
14
|
def find_by_code(code)
|
14
15
|
codes = code.split('-')
|
15
|
-
codes <<
|
16
|
+
codes << '' if codes.length == 1
|
16
17
|
find_by_language_code_and_country_code *codes
|
17
18
|
end
|
19
|
+
|
18
20
|
end
|
21
|
+
|
19
22
|
end
|
@@ -12,13 +12,27 @@
|
|
12
12
|
module Alchemy
|
13
13
|
class Message
|
14
14
|
|
15
|
-
@@config = Config.get(:mailer)
|
16
|
-
|
17
15
|
extend ::ActiveModel::Naming
|
18
16
|
include ::ActiveModel::Validations
|
19
17
|
include ::ActiveModel::Conversion
|
20
18
|
include ::ActiveModel::MassAssignmentSecurity
|
21
19
|
|
20
|
+
def self.attr_accessor(*vars)
|
21
|
+
@attributes ||= {}
|
22
|
+
vars.map { |v| @attributes[v] = nil}
|
23
|
+
super(*vars)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.attributes
|
27
|
+
@attributes
|
28
|
+
end
|
29
|
+
|
30
|
+
def attributes
|
31
|
+
self.class.attributes
|
32
|
+
end
|
33
|
+
|
34
|
+
@@config = Config.get(:mailer)
|
35
|
+
|
22
36
|
attr_accessor :contact_form_id, :ip
|
23
37
|
attr_accessible :contact_form_id
|
24
38
|
|
@@ -39,8 +53,10 @@ module Alchemy
|
|
39
53
|
end
|
40
54
|
|
41
55
|
def initialize(attributes = {})
|
56
|
+
@attributes ||= {}
|
42
57
|
attributes.keys.each do |a|
|
43
58
|
send("#{a}=", attributes[a])
|
59
|
+
@attributes[a] = attributes[a]
|
44
60
|
end
|
45
61
|
end
|
46
62
|
|
@@ -48,7 +64,7 @@ module Alchemy
|
|
48
64
|
false
|
49
65
|
end
|
50
66
|
|
51
|
-
|
67
|
+
private
|
52
68
|
|
53
69
|
def email_is_filled #:nodoc:
|
54
70
|
!email.blank?
|
data/app/models/alchemy/page.rb
CHANGED
@@ -56,8 +56,8 @@ module Alchemy
|
|
56
56
|
before_save :set_language_code, :unless => :systempage?
|
57
57
|
before_save :set_restrictions_to_child_pages, :if => proc { |page| !page.systempage? && page.restricted_changed? }
|
58
58
|
before_save :inherit_restricted_status, :if => proc { |page| !page.systempage? && page.parent && page.parent.restricted? }
|
59
|
-
after_create :autogenerate_elements, :unless => proc { |page| page.systempage? || page.do_not_autogenerate }
|
60
59
|
after_create :create_cells, :unless => :systempage?
|
60
|
+
after_create :autogenerate_elements, :unless => proc { |page| page.systempage? || page.do_not_autogenerate }
|
61
61
|
|
62
62
|
scope :language_roots, where(:language_root => true)
|
63
63
|
scope :layoutpages, where(:layoutpage => true)
|
@@ -141,12 +141,7 @@ module Alchemy
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def elements_grouped_by_cells
|
144
|
-
|
145
|
-
self.cells.each { |cell| group[cell] = cell.elements.not_trashed }
|
146
|
-
if element_names_not_in_cell.any?
|
147
|
-
group[Cell.new({:name => 'for_other_elements'})] = elements.not_trashed.not_in_cell
|
148
|
-
end
|
149
|
-
return group
|
144
|
+
elements.not_trashed.in_cell.group_by(&:cell)
|
150
145
|
end
|
151
146
|
|
152
147
|
def element_names_from_cells
|
@@ -161,27 +156,25 @@ module Alchemy
|
|
161
156
|
# Options:
|
162
157
|
# => :restricted => boolean (standard: nil) - next restricted page (true), skip restricted pages (false), ignore restriction (nil)
|
163
158
|
# => :public => boolean (standard: true) - next public page (true), skip public pages (false)
|
164
|
-
def
|
165
|
-
|
159
|
+
def previous(options = {})
|
160
|
+
next_or_previous(:previous, {
|
166
161
|
:restricted => nil,
|
167
162
|
:public => true
|
168
|
-
}
|
169
|
-
options = default_options.merge(options)
|
170
|
-
find_next_or_previous_page("previous", options)
|
163
|
+
}.merge(options))
|
171
164
|
end
|
165
|
+
alias_method :previous_page, :previous
|
172
166
|
|
173
167
|
# Finds the next page on the same structure level. Otherwise it returns nil.
|
174
168
|
# Options:
|
175
169
|
# => :restricted => boolean (standard: nil) - next restricted page (true), skip restricted pages (false), ignore restriction (nil)
|
176
170
|
# => :public => boolean (standard: true) - next public page (true), skip public pages (false)
|
177
|
-
def
|
178
|
-
|
171
|
+
def next(options = {})
|
172
|
+
next_or_previous(:next, {
|
179
173
|
:restricted => nil,
|
180
174
|
:public => true
|
181
|
-
}
|
182
|
-
options = default_options.merge(options)
|
183
|
-
find_next_or_previous_page("next", options)
|
175
|
+
}.merge(options))
|
184
176
|
end
|
177
|
+
alias_method :next_page, :next
|
185
178
|
|
186
179
|
def find_first_public(page)
|
187
180
|
if (page.public == true)
|
@@ -372,7 +365,7 @@ module Alchemy
|
|
372
365
|
|
373
366
|
def set_restrictions_to_child_pages
|
374
367
|
descendants.each do |child|
|
375
|
-
child.
|
368
|
+
child.update_attributes(:restricted => self.restricted?)
|
376
369
|
end
|
377
370
|
end
|
378
371
|
|
@@ -427,7 +420,7 @@ module Alchemy
|
|
427
420
|
end
|
428
421
|
return page
|
429
422
|
else
|
430
|
-
raise page.errors.full_messages
|
423
|
+
raise "`#{page.name}`: #{page.errors.full_messages}"
|
431
424
|
end
|
432
425
|
end
|
433
426
|
|
@@ -451,11 +444,11 @@ module Alchemy
|
|
451
444
|
return layoutroot if layoutroot
|
452
445
|
language = Language.find(language_id)
|
453
446
|
layoutroot = Page.new({
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
447
|
+
:name => "Layoutroot for #{language.name}",
|
448
|
+
:layoutpage => true,
|
449
|
+
:language => language,
|
450
|
+
:do_not_autogenerate => true
|
451
|
+
})
|
459
452
|
if layoutroot.save(:validate => false)
|
460
453
|
layoutroot.move_to_child_of(Page.root)
|
461
454
|
return layoutroot
|
@@ -536,23 +529,22 @@ module Alchemy
|
|
536
529
|
|
537
530
|
private
|
538
531
|
|
539
|
-
def
|
540
|
-
|
541
|
-
|
532
|
+
def next_or_previous(direction = :next, options = {})
|
533
|
+
pages = self.class.scoped
|
534
|
+
if direction == :previous
|
535
|
+
step_direction = ["#{self.class.table_name}.lft < ?", self.lft]
|
542
536
|
order_direction = "lft DESC"
|
543
537
|
else
|
544
|
-
step_direction = ["
|
538
|
+
step_direction = ["#{self.class.table_name}.lft > ?", self.lft]
|
545
539
|
order_direction = "lft"
|
546
540
|
end
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
step_direction
|
551
|
-
)
|
541
|
+
pages = pages.where(:public => options[:public])
|
542
|
+
pages = pages.where(:parent_id => self.parent_id)
|
543
|
+
pages = pages.where(step_direction)
|
552
544
|
if !options[:restricted].nil?
|
553
|
-
|
545
|
+
pages = pages.where(:restricted => options[:restricted])
|
554
546
|
end
|
555
|
-
|
547
|
+
pages.order(order_direction).limit(1).first
|
556
548
|
end
|
557
549
|
|
558
550
|
# Converts the given nbame into an url friendly string
|
@@ -563,14 +555,27 @@ module Alchemy
|
|
563
555
|
return url_name
|
564
556
|
end
|
565
557
|
|
566
|
-
# Looks in the
|
567
|
-
#
|
558
|
+
# Looks in the page_layout descripion, if there are elements to autogenerate.
|
559
|
+
#
|
560
|
+
# And if so, it generates them.
|
561
|
+
#
|
562
|
+
# If the page has cells, it looks if there are elements to generate.
|
563
|
+
#
|
568
564
|
def autogenerate_elements
|
569
565
|
elements = self.layout_description["autogenerate"]
|
570
|
-
|
566
|
+
if elements.present?
|
571
567
|
elements.each do |element|
|
572
|
-
|
573
|
-
|
568
|
+
if self.has_cells? && (cell_definition = cell_definitions.detect { |c| c['elements'].include?(element) })
|
569
|
+
cell = self.cells.find_by_name(cell_definition['name'])
|
570
|
+
if cell
|
571
|
+
attributes = {'page_id' => self.id, 'cell_id' => cell.id, 'name' => element}
|
572
|
+
else
|
573
|
+
raise "Cell not found for page #{self.inspect}"
|
574
|
+
end
|
575
|
+
else
|
576
|
+
attributes = {'page_id' => self.id, 'name' => element}
|
577
|
+
end
|
578
|
+
Element.create_from_scratch(attributes)
|
574
579
|
end
|
575
580
|
end
|
576
581
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Alchemy
|
2
2
|
class Picture < ActiveRecord::Base
|
3
3
|
|
4
|
+
has_many :essence_pictures, :class_name => 'Alchemy::EssencePicture', :foreign_key => 'picture_id'
|
5
|
+
has_many :contents, :through => :essence_pictures
|
6
|
+
has_many :elements, :through => :contents
|
7
|
+
has_many :pages, :through => :elements
|
8
|
+
|
4
9
|
acts_as_fleximage do
|
5
10
|
image_directory 'uploads/pictures'
|
6
11
|
image_storage_format Config.get(:image_store_format).to_sym
|
@@ -15,18 +20,30 @@ module Alchemy
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
23
|
+
acts_as_taggable
|
24
|
+
|
18
25
|
attr_accessible(
|
19
26
|
:image_file,
|
20
27
|
:image_filename,
|
21
28
|
:image_height,
|
22
29
|
:image_width,
|
23
|
-
:name
|
30
|
+
:name,
|
31
|
+
:upload_hash,
|
32
|
+
:tag_list
|
24
33
|
)
|
25
34
|
|
26
35
|
stampable(:stamper_class_name => 'Alchemy::User')
|
27
36
|
|
37
|
+
scope :recent, where("#{self.table_name}.created_at > ?", Time.now-24.hours).order(:created_at)
|
38
|
+
|
28
39
|
def self.find_paginated(params, per_page)
|
29
|
-
Picture.where("name LIKE
|
40
|
+
Picture.where("name LIKE ?", "%#{params[:query]}%").page(params[:page] || 1).per(per_page).order(:name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.last_upload
|
44
|
+
last_picture = Picture.last
|
45
|
+
return Picture.scoped unless last_picture
|
46
|
+
Picture.where(:upload_hash => last_picture.upload_hash)
|
30
47
|
end
|
31
48
|
|
32
49
|
# Returning the filepath relative to Rails.root public folder.
|
@@ -119,5 +136,10 @@ module Alchemy
|
|
119
136
|
"#{new_x.round}x#{new_y.round}"
|
120
137
|
end
|
121
138
|
|
139
|
+
# Checks if the picture is restricted, because it is attached on restricted pages only
|
140
|
+
def restricted?
|
141
|
+
pages.any? && pages.not_restricted.blank?
|
142
|
+
end
|
143
|
+
|
122
144
|
end
|
123
145
|
end
|
data/app/models/alchemy/user.rb
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
<div id="overlay_toolbar">
|
3
3
|
<div class="button_with_label">
|
4
4
|
<%= link_to_overlay_window(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:title => t('upload_file'),
|
13
|
-
:size => '540x550'
|
14
|
-
},
|
5
|
+
render_icon('upload'),
|
6
|
+
alchemy.new_admin_attachment_path(
|
7
|
+
:content_id => @content.blank? ? nil : @content.id,
|
8
|
+
:swap => @swap,
|
9
|
+
:options => @options
|
10
|
+
),
|
11
|
+
{
|
15
12
|
:title => t('upload_file'),
|
16
|
-
:
|
17
|
-
|
13
|
+
:size => '540x550'
|
14
|
+
},
|
15
|
+
:title => t('upload_file'),
|
16
|
+
:class => 'icon_button'
|
17
|
+
) %>
|
18
18
|
<label><%= t('upload_file') %></label>
|
19
19
|
</div>
|
20
20
|
<%= js_filter_field(:onkeyup => "Alchemy.ListFilter('.assign_file_file')") %>
|
@@ -2,11 +2,17 @@
|
|
2
2
|
<table>
|
3
3
|
<tr>
|
4
4
|
<td class="label"><%= f.label 'name', :class => "short" %></td>
|
5
|
-
<td class="input"><%= f.text_field 'name', :class => 'thin_border very_long' %></td>
|
5
|
+
<td class="input"><%= f.text_field 'name', :class => 'thin_border very_long', :autofocus => true %></td>
|
6
6
|
</tr>
|
7
7
|
<tr>
|
8
|
-
<td
|
9
|
-
<td class="
|
8
|
+
<td class="label"><%= f.label 'filename', :class => "short" %>*</td>
|
9
|
+
<td class="input"><%= f.text_field 'filename', :class => 'thin_border very_long' %></td>
|
10
|
+
</tr>
|
11
|
+
<tr>
|
12
|
+
<td colspan="2" class="submit">
|
13
|
+
<%= f.button t('save'), :class => 'button' %>
|
14
|
+
</td>
|
10
15
|
</tr>
|
11
16
|
</table>
|
17
|
+
<p class="foot_note"><%= t(:attachment_filename_notice) %></p>
|
12
18
|
<% end %>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
<% if params[:was_missing] %>
|
4
|
+
|
5
|
+
$("#element_<%= @element.id %>_content_missing").replaceWith('<%= escape_javascript(
|
6
|
+
render(
|
7
|
+
:partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
|
8
|
+
:locals => @locals
|
9
|
+
)
|
10
|
+
) %>');
|
11
|
+
|
12
|
+
<% else %>
|
13
|
+
|
14
|
+
$("<%= @content_dom_id %>").before('<%= escape_javascript(
|
15
|
+
render(
|
16
|
+
:partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
|
17
|
+
:locals => @locals
|
18
|
+
)
|
19
|
+
) %>');
|
20
|
+
Alchemy.enableButton('.disabled.button');
|
21
|
+
Alchemy.overlayObserver('#<%= content_dom_id(@content) %>');
|
22
|
+
Alchemy.growl('<%= t("Successfully added content") % {:content => @content.name_for_label} %>')
|
23
|
+
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% if @content.essence_type == "Alchemy::EssencePicture" %>
|
27
|
+
|
28
|
+
$('#picture_to_assign_<%= @content.ingredient.id %> a').attr('href', '#').off('click');
|
29
|
+
|
30
|
+
<% if @contents_of_this_type.length > 1 %>
|
31
|
+
$('#element_<%= @element.id %>_contents .essence_picture_editor').addClass('dragable_picture');
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% if !max_image_count.blank? && @contents_of_this_type.length >= max_image_count %>
|
35
|
+
$("#add_picture_<%= @element.id %>").remove();
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
Alchemy.SortableContents('#element_<%= @element.id %>_contents', '<%= form_authenticity_token %>');
|
39
|
+
|
40
|
+
<% elsif @content.essence_type == "Alchemy::EssenceDate" %>
|
41
|
+
|
42
|
+
Alchemy.Datepicker('#element_<%= @element.id %> input.date');
|
43
|
+
|
44
|
+
<% elsif @content.essence_type == "Alchemy::EssenceRichtext" %>
|
45
|
+
|
46
|
+
Alchemy.Tinymce.addEditor('contents_content_<%= @content.id %>_body');
|
47
|
+
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
Alchemy.reloadPreview();
|
51
|
+
Alchemy.closeCurrentWindow();
|
52
|
+
Alchemy.SelectBox("#element_<%= @element.id %>");
|
53
|
+
|
54
|
+
})()
|
@@ -3,11 +3,16 @@
|
|
3
3
|
<%= f.hidden_field :element_id %>
|
4
4
|
<table>
|
5
5
|
<tr>
|
6
|
-
<td>
|
7
|
-
|
8
|
-
<%=
|
6
|
+
<td class="label"><%= f.label :name, t('name') %></td>
|
7
|
+
<td class="select">
|
8
|
+
<%= f.select('name', @contents.map { |a|
|
9
|
+
[t("content_names.#{a['name']}"), a['name']]
|
10
|
+
}, {}, {:class => 'alchemy_selectbox'}) %>
|
9
11
|
</td>
|
10
|
-
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td class="submit" colspan="2">
|
15
|
+
<%= hidden_field_tag('options', @options) %>
|
11
16
|
<%= f.button t(:create), :class => 'button' %>
|
12
17
|
</td>
|
13
18
|
</tr>
|