alchemy_cms 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/alchemy_cms.gemspec +1 -1
  2. data/app/assets/javascripts/alchemy/alchemy.buttons.js.coffee +1 -1
  3. data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +93 -0
  4. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +2 -2
  5. data/app/assets/stylesheets/alchemy/archive.scss +18 -11
  6. data/app/assets/stylesheets/alchemy/base.scss +4 -0
  7. data/app/assets/stylesheets/alchemy/form_elements.scss +2 -1
  8. data/app/assets/stylesheets/alchemy/jquery-ui.scss +1 -0
  9. data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -1
  10. data/app/assets/stylesheets/alchemy/tables.scss +1 -0
  11. data/app/controllers/alchemy/admin/contents_controller.rb +2 -0
  12. data/app/controllers/alchemy/admin/dashboard_controller.rb +41 -15
  13. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  14. data/app/controllers/alchemy/admin/pictures_controller.rb +13 -5
  15. data/app/controllers/alchemy/user_sessions_controller.rb +9 -0
  16. data/app/helpers/alchemy/admin/base_helper.rb +5 -0
  17. data/app/helpers/alchemy/admin/essences_helper.rb +1 -0
  18. data/app/helpers/alchemy/essences_helper.rb +40 -2
  19. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  20. data/app/views/alchemy/admin/essence_pictures/update.js.erb +2 -0
  21. data/app/views/alchemy/essences/_essence_picture_view.html.erb +1 -39
  22. data/app/views/layouts/alchemy/admin.html.erb +1 -1
  23. data/config/locales/alchemy.de.yml +1 -0
  24. data/config/locales/alchemy.en.yml +1 -0
  25. data/lib/alchemy/version.rb +1 -1
  26. data/spec/views/essences/essence_picture_view_spec.rb +84 -0
  27. metadata +8 -6
  28. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +0 -120
data/alchemy_cms.gemspec CHANGED
@@ -32,7 +32,7 @@ POST_INSTALL
32
32
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
33
33
  s.require_paths = ["lib"]
34
34
 
35
- s.add_runtime_dependency %q<rails>, ["~> 3.2.11"]
35
+ s.add_runtime_dependency %q<rails>, ["~> 3.2.12"]
36
36
  s.add_runtime_dependency %q<devise>, ["~> 2.2.3"]
37
37
  s.add_runtime_dependency %q<devise-encryptable>, ["~> 0.1.1"]
38
38
  s.add_runtime_dependency %q<awesome_nested_set>, ["~> 2.0"]
@@ -1,4 +1,4 @@
1
- window.Alchemy = {} if window.Alchemy == undefined
1
+ window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
2
2
 
3
3
  Alchemy.Buttons =
4
4
 
@@ -0,0 +1,93 @@
1
+ window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
2
+
3
+ Alchemy.ElementsWindow =
4
+
5
+ init: (path, options, callback) ->
6
+ self = Alchemy.ElementsWindow
7
+ $dialog = $('<div style="display: none" id="alchemyElementWindow"></div>')
8
+ closeCallback = ->
9
+ $dialog.dialog "destroy"
10
+ $("#alchemyElementWindow").remove()
11
+ Alchemy.ElementsWindow.button.enable()
12
+
13
+ self.path = path
14
+ self.callback = callback
15
+ $dialog.html Alchemy.getOverlaySpinner(x: 420, y: 300)
16
+ self.dialog = $dialog
17
+ $('#main_content').append($dialog)
18
+ Alchemy.ElementsWindow.currentWindow = $dialog.dialog(
19
+ modal: false
20
+ minWidth: 420
21
+ minHeight: 300
22
+ height: $(window).height() - 88
23
+ title: options.texts.title
24
+ show: "fade"
25
+ hide: "fade"
26
+ position:
27
+ my: "right bottom", at: "right-4px bottom-4px"
28
+ closeOnEscape: false
29
+ create: ->
30
+ $dialog.before Alchemy.ElementsWindow.createToolbar(options.toolbarButtons)
31
+
32
+ open: (event, ui) ->
33
+ Alchemy.ElementsWindow.button.disable()
34
+ Alchemy.ElementsWindow.reload callback
35
+
36
+ beforeClose: ->
37
+ if Alchemy.isPageDirty()
38
+ Alchemy.openConfirmWindow
39
+ title: options.texts.dirtyTitle
40
+ message: options.texts.dirtyMessage
41
+ okLabel: options.texts.okLabel
42
+ cancelLabel: options.texts.cancelLabel
43
+ okCallback: closeCallback
44
+
45
+ false
46
+ else
47
+ true
48
+
49
+ close: closeCallback
50
+ )
51
+
52
+ button:
53
+ enable: ->
54
+ $("div#show_element_window").removeClass("disabled").find("a").removeAttr "tabindex"
55
+
56
+ disable: ->
57
+ $("div#show_element_window").addClass("disabled").find("a").attr "tabindex", "-1"
58
+
59
+ toggle: ->
60
+ if $("div#show_element_window").hasClass("disabled")
61
+ Alchemy.ElementsWindow.button.enable()
62
+ else
63
+ Alchemy.ElementsWindow.button.disable()
64
+
65
+ createToolbar: (buttons) ->
66
+ $toolbar = $("<div id=\"overlay_toolbar\"></div>")
67
+ btn = undefined
68
+ i = 0
69
+ while i < buttons.length
70
+ btn = buttons[i]
71
+ $toolbar.append Alchemy.ToolbarButton(
72
+ buttonTitle: btn.title
73
+ buttonLabel: btn.label
74
+ iconClass: btn.iconClass
75
+ onClick: btn.onClick
76
+ buttonId: btn.buttonId
77
+ )
78
+ i++
79
+ $toolbar
80
+
81
+ reload: ->
82
+ self = Alchemy.ElementsWindow
83
+ $.ajax
84
+ url: self.path
85
+ success: (data, textStatus, XMLHttpRequest) ->
86
+ self.dialog.html data
87
+ Alchemy.Buttons.observe "#alchemyElementWindow"
88
+ Alchemy.overlayObserver "#alchemyElementWindow"
89
+ Alchemy.Datepicker "#alchemyElementWindow input.date, #alchemyElementWindow input[type=\"date\"]"
90
+ self.callback.call() if self.callback
91
+
92
+ error: (XMLHttpRequest, textStatus, errorThrown) ->
93
+ Alchemy.AjaxErrorHandler $dialog, XMLHttpRequest.status, textStatus, errorThrown
@@ -22,8 +22,8 @@ if (typeof(Alchemy) === 'undefined') {
22
22
  Alchemy.PreviewWindow.currentWindow = $iframe.dialog({
23
23
  modal: false,
24
24
  title: title,
25
- width: $(window).width() - 504,
26
- height: $(window).height() - 78,
25
+ width: $(window).width() - 502,
26
+ height: $(window).height() - 76,
27
27
  minWidth: 600,
28
28
  minHeight: 300,
29
29
  show: "fade",
@@ -244,7 +244,7 @@ div#library_sidebar {
244
244
  right: 0;
245
245
  width: 232px;
246
246
  padding-top: 96px;
247
- padding: 0 4*$default-padding;
247
+ padding: 84px 4*$default-padding 0 4*$default-padding;
248
248
  height: 100%;
249
249
  z-index: 1;
250
250
  background-color: $light-gray;
@@ -257,13 +257,13 @@ div#library_sidebar {
257
257
  div#filter_bar {
258
258
 
259
259
  .selectboxit {
260
- width: 180px;
260
+ width: 192px;
261
261
  }
262
262
  }
263
263
 
264
264
  div#tag_list {
265
265
  @include box-sizing(border-box);
266
- height: 85%;
266
+ height: 80%;
267
267
 
268
268
  .js_filter_field_box {
269
269
 
@@ -316,23 +316,30 @@ div#tag_list {
316
316
  }
317
317
  }
318
318
 
319
- div#alchemy_window_body div#tag_list ul {
320
- height: 364px;
319
+ div#alchemy_window_body {
320
+
321
+ #library_sidebar {
322
+ padding: 0 4*$default-padding;
323
+ }
324
+
325
+ div#tag_list ul {
326
+ height: 364px;
327
+ }
321
328
  }
322
329
 
323
330
  div#pictures_page_list {
324
331
 
325
- h2 { margin: 0 8px }
326
- h3 { padding: 0 }
332
+ h2 { margin: 0 2*$default-padding }
333
+ h3 { padding: 0 $default-padding }
327
334
 
328
335
  ul.list {
329
- height: 100px;
336
+ max-height: 100px;
330
337
  overflow: auto;
331
- margin: 8px;
338
+ margin: 2*$default-margin;
332
339
  background-color: $medium-gray;
333
340
 
334
- ul { padding: 0 4px }
341
+ ul { padding: 0 $default-padding }
335
342
  }
336
343
 
337
- li.even, li.odd { padding: 4px }
344
+ li.even, li.odd { padding: $default-padding }
338
345
  }
@@ -26,6 +26,9 @@ body {
26
26
  background-color: $light-gray;
27
27
  height: 100%;
28
28
  cursor: default;
29
+
30
+ // Fix for strange element window offset
31
+ &.pages.edit { overflow: hidden }
29
32
  }
30
33
 
31
34
  h1 {
@@ -844,6 +847,7 @@ div#overlay_toolbar {
844
847
  background: $medium-gray url('shading.png') repeat-x 0 -42px;
845
848
  border: $default-border;
846
849
  height: 44px;
850
+ border-top-style: none;
847
851
  border-left-style: none;
848
852
  border-right-style: none;
849
853
  padding: $default-padding;
@@ -319,10 +319,11 @@ select {
319
319
  * Author: @gregfranko
320
320
  */
321
321
 
322
- form td.select .selectboxit {
322
+ td.select .selectboxit {
323
323
 
324
324
  .selectboxit-text {
325
325
  line-height: 17px !important;
326
+ max-width: 80% !important;
326
327
  }
327
328
  }
328
329
 
@@ -1473,6 +1473,7 @@ button.ui-button::-moz-focus-inner {
1473
1473
  padding: 8px 12px;
1474
1474
  position: relative;
1475
1475
  margin-bottom: 0;
1476
+ @include border-bottom-radius(0)
1476
1477
  }
1477
1478
 
1478
1479
  #alchemy .ui-dialog .ui-dialog-title {
@@ -88,7 +88,7 @@
88
88
  height: auto;
89
89
 
90
90
  li {
91
- height: auto;
91
+ height: 35px;
92
92
  margin: 0 $default-padding 0 0;
93
93
  padding: 0;
94
94
  @include inline-block;
@@ -90,6 +90,7 @@ td.checkbox {
90
90
 
91
91
  td.value {
92
92
  padding-top: 4px;
93
+ overflow: hidden;
93
94
 
94
95
  p {
95
96
  @include inline-block;
@@ -2,6 +2,8 @@ module Alchemy
2
2
  module Admin
3
3
  class ContentsController < Alchemy::Admin::BaseController
4
4
 
5
+ helper "alchemy/admin/essences"
6
+
5
7
  def new
6
8
  @element = Element.find(params[:element_id])
7
9
  @contents = @element.available_contents
@@ -30,28 +30,54 @@ module Alchemy
30
30
 
31
31
  private
32
32
 
33
- def alchemy_tags
34
- url = URI.parse('https://api.github.com/repos/magiclabs/alchemy_cms/tags')
35
- request = Net::HTTP::Get.new(url.path)
36
- connection = Net::HTTP.new(url.host, url.port)
37
- connection.use_ssl = true
38
- connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
- response = connection.request(request)
33
+ # Returns latest alchemy version.
34
+ def latest_alchemy_version
35
+ versions = get_alchemy_versions
36
+ return '' if versions.blank?
37
+ # reject any non release version
38
+ versions.reject! { |v| v =~ /[a-z]/ }
39
+ versions.sort.last
40
+ end
41
+
42
+ # Get alchemy versions from rubygems or github, if rubygems failes.
43
+ def get_alchemy_versions
44
+ # first we try rubygems.org
45
+ response = query_rubygems
40
46
  if response.code == "200"
41
- JSON.parse(response.body)
47
+ alchemy_versions = JSON.parse(response.body)
48
+ alchemy_versions.collect { |h| h['number'] }.sort
42
49
  else
43
- raise UpdateServiceUnavailable
50
+ # rubygems.org not available?
51
+ # then we try github
52
+ response = query_github
53
+ if response.code == "200"
54
+ alchemy_tags = JSON.parse(response.body)
55
+ alchemy_tags.collect { |h| h['name'] }.sort
56
+ else
57
+ # no luck at all?
58
+ raise UpdateServiceUnavailable
59
+ end
44
60
  end
45
61
  end
46
62
 
47
- def alchemy_versions
48
- return [] if alchemy_tags.blank?
49
- alchemy_tags.collect { |h| h['name'] }.sort
63
+ # Query the RubyGems API for alchemy versions.
64
+ def query_rubygems
65
+ make_api_request('https://rubygems.org/api/v1/versions/alchemy_cms.json')
50
66
  end
51
67
 
52
- def latest_alchemy_version
53
- return '' if alchemy_versions.blank?
54
- alchemy_versions.last.gsub(/^v/, '')
68
+ # Query the GitHub API for alchemy tags.
69
+ def query_github
70
+ make_api_request('https://api.github.com/repos/magiclabs/alchemy_cms/tags')
71
+ end
72
+
73
+ # Make a HTTP API request for given request url.
74
+ def make_api_request(request_url)
75
+ url = URI.parse(request_url)
76
+ request = Net::HTTP::Get.new(url.path)
77
+ connection = Net::HTTP.new(url.host, url.port)
78
+ connection.use_ssl = true
79
+ connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
80
+ connection.request(request)
55
81
  end
56
82
 
57
83
  end
@@ -107,7 +107,7 @@ module Alchemy
107
107
  @notice = _t("Page saved", :name => @page.name)
108
108
  @while_page_edit = request.referer.include?('edit')
109
109
  else
110
- render_remote_errors(@page, "#alchemyOverlay button.button")
110
+ render_remote_errors(@page)
111
111
  end
112
112
  end
113
113
 
@@ -105,14 +105,22 @@ module Alchemy
105
105
  if request.delete? && params[:picture_ids].present?
106
106
  pictures = Picture.find(params[:picture_ids])
107
107
  names = []
108
+ not_deletable = []
108
109
  pictures.each do |picture|
109
- next unless picture.deletable?
110
- names << picture.name
111
- picture.destroy
110
+ if picture.deletable?
111
+ names << picture.name
112
+ picture.destroy
113
+ else
114
+ not_deletable << picture.name
115
+ end
116
+ end
117
+ if not_deletable.any?
118
+ flash[:warn] = _t("These pictures could not be deleted, because they where in use", :names => not_deletable.to_sentence)
119
+ else
120
+ flash[:notice] = _t("Pictures deleted successfully", :names => names.to_sentence)
112
121
  end
113
- flash[:notice] = _t("Pictures deleted successfully", :names => names.to_sentence)
114
122
  else
115
- flash[:notice] = _t("Could not delete Pictures")
123
+ flash[:warn] = _t("Could not delete Pictures")
116
124
  end
117
125
  rescue Exception => e
118
126
  flash[:error] = e.message
@@ -53,5 +53,14 @@ module Alchemy
53
53
  session[:screen_size] = params[:user_screensize]
54
54
  end
55
55
 
56
+ # Ovewriting the default of Devise
57
+ def after_sign_out_path_for(resource_or_scope)
58
+ if request.referer.blank? || request.referer.to_s =~ /admin/
59
+ root_path
60
+ else
61
+ request.referer
62
+ end
63
+ end
64
+
56
65
  end
57
66
  end
@@ -546,6 +546,11 @@ module Alchemy
546
546
  end
547
547
  end
548
548
 
549
+ # Appends the current controller and action to body as css class.
550
+ def body_class
551
+ "#{controller_name} #{action_name}"
552
+ end
553
+
549
554
  end
550
555
  end
551
556
  end
@@ -126,6 +126,7 @@ module Alchemy
126
126
  end
127
127
 
128
128
  def essence_picture_thumbnail(content, options)
129
+ return if content.ingredient.blank?
129
130
  image_options = {
130
131
  :size => content.ingredient.cropped_thumbnail_size(content.essence.render_size.blank? ? options[:image_size] : content.essence.render_size),
131
132
  :crop_from => content.essence.crop_from.blank? ? nil : content.essence.crop_from,
@@ -134,8 +134,46 @@ module Alchemy
134
134
  # :disable_link => true # You can surpress the link of an EssencePicture. Default false
135
135
  #
136
136
  def render_essence_view(content, options = {}, html_options = {})
137
- defaults = {:show_caption => true, :disable_link => false}
138
- render_essence(content, :view, {:for_view => defaults.update(options)}, html_options)
137
+ render_essence(content, :view, {:for_view => options}, html_options)
138
+ end
139
+
140
+ # Renders a essence picture
141
+ #
142
+ def render_essence_picture_view(content, options, html_options)
143
+ options = {:show_caption => true, :disable_link => false}.update(options)
144
+ return if content.essence.picture.blank?
145
+ if content.essence.caption.present? && options[:show_caption]
146
+ caption = content_tag(:figcaption, content.essence.caption, :id => "#{dom_id(content.essence.picture)}_caption", :class => "image_caption")
147
+ end
148
+ img_tag = image_tag(
149
+ show_alchemy_picture_url(content.essence.picture,
150
+ options.merge(
151
+ :size => options.delete(:image_size),
152
+ :crop_from => options[:crop] && !content.essence.crop_from.blank? ? content.essence.crop_from : nil,
153
+ :crop_size => options[:crop] && !content.essence.crop_size.blank? ? content.essence.crop_size : nil
154
+ ).delete_if { |k, v| v.blank? || k.to_sym == :show_caption || k.to_sym == :disable_link }
155
+ ),
156
+ {
157
+ :alt => (content.essence.alt_tag.blank? ? nil : content.essence.alt_tag),
158
+ :title => (content.essence.title.blank? ? nil : content.essence.title),
159
+ :class => (caption || content.essence.css_class.blank? ? nil : content.essence.css_class)
160
+ }.merge(caption ? {} : html_options)
161
+ )
162
+ output = caption ? img_tag + caption : img_tag
163
+ if content.essence.link.present? && !options[:disable_link]
164
+ output = link_to(url_for(content.essence.link), {
165
+ :title => content.essence.link_title.blank? ? nil : content.essence.link_title,
166
+ :target => (content.essence.link_target == "blank" ? "_blank" : nil),
167
+ 'data-link-target' => content.essence.link_target.blank? ? nil : content.essence.link_target
168
+ }) do
169
+ output
170
+ end
171
+ end
172
+ if caption
173
+ content_tag(:figure, output, {class: content.essence.css_class.blank? ? nil : content.essence.css_class}.merge(html_options))
174
+ else
175
+ output
176
+ end
139
177
  end
140
178
 
141
179
  end
@@ -7,7 +7,7 @@
7
7
  <tr>
8
8
  <td class="label"><%= f.label "caption" %></td>
9
9
  <td class="input">
10
- <%- if @options[:caption_as_textarea] -%>
10
+ <%- if @options[:caption_as_textarea] == 'true' -%>
11
11
  <%= f.text_area "caption", :class => 'thin_border' %>
12
12
  <%- else -%>
13
13
  <%= f.text_field "caption", :class => 'thin_border' %>
@@ -43,7 +43,7 @@
43
43
  </td>
44
44
  </tr>
45
45
  <%- end -%>
46
- <%- if @options[:image_float_selector] -%>
46
+ <%- if @options[:image_float_selector] == 'true' -%>
47
47
  <tr>
48
48
  <td class="label"><%= f.label "css_class" %></td>
49
49
  <td class="select">
@@ -2,5 +2,7 @@
2
2
  Alchemy.ImageCropper.destroy();
3
3
  Alchemy.closeCurrentWindow();
4
4
  Alchemy.setElementDirty('#element_<%= @content.element.id %>');
5
+ <% if @content.ingredient %>
5
6
  $('.thumbnail_background img', '#<%= content_dom_id(@content) %>').replaceWith('<%= essence_picture_thumbnail(@content, @options) %>');
7
+ <% end %>
6
8
  })(jQuery);
@@ -1,39 +1 @@
1
- <% if content.essence.picture.present? %>
2
-
3
- <% img_tag = image_tag(
4
- show_alchemy_picture_url(content.essence.picture,
5
- options.merge(
6
- :size => options.delete(:image_size),
7
- :crop_from => options[:crop] && !content.essence.crop_from.blank? ? content.essence.crop_from : nil,
8
- :crop_size => options[:crop] && !content.essence.crop_size.blank? ? content.essence.crop_size : nil
9
- ).delete_if { |k,v| v.blank? || k.to_sym == :show_caption || k.to_sym == :disable_link }
10
- ),
11
- {
12
- :alt => (content.essence.alt_tag.blank? ? nil : content.essence.alt_tag),
13
- :title => (content.essence.title.blank? ? nil : content.essence.title),
14
- :class => (content.essence.css_class.blank? ? nil : content.essence.css_class)
15
- }.merge(html_options)
16
- ) %>
17
-
18
- <% if content.essence.caption.present? && options[:show_caption] %>
19
- <% caption = content_tag(:figcaption, content.essence.caption, :id => "#{dom_id(content.essence.picture)}_caption", :class => "image_caption") %>
20
- <figure>
21
- <% end %>
22
-
23
- <% if content.essence.link.blank? || options[:disable_link] %>
24
-
25
- <%= caption ? img_tag + caption : img_tag %>
26
-
27
- <% else %>
28
-
29
- <%= link_to(url_for(content.essence.link), {
30
- :title => content.essence.link_title,
31
- :target => (content.essence.link_target == "blank" ? "_blank" : nil),
32
- 'data-link-target' => content.essence.link_target
33
- }) do %>
34
- <%= caption ? img_tag + caption : img_tag %>
35
- <% end %>
36
-
37
- <% end %>
38
- <% if caption %></figure><% end %>
39
- <% end %>
1
+ <%= render_essence_picture_view(content, options, html_options) %>
@@ -25,7 +25,7 @@
25
25
  <%= javascript_include_tag('alchemy/alchemy') %>
26
26
  <%= yield :javascript_includes %>
27
27
  </head>
28
- <body id="alchemy">
28
+ <body id="alchemy" class="<%= body_class %>">
29
29
  <noscript>
30
30
  <h1><%= _t(:javascript_disabled_headline) %></h1>
31
31
  <p><%= _t(:javascript_disabled_text) %></p>
@@ -306,6 +306,7 @@ de:
306
306
  searchresults_editor_info: "Dieses Element stellt die Suchergebnisse dar. Es Bedarf keinerlei Anpassung."
307
307
  element_dirty_notice: "Dieses Element hat nicht gespeicherte Änderungen. Möchten Sie es wirklich einklappen?"
308
308
  "Tags": "Tags"
309
+ "These pictures could not be deleted, because they where in use": "Diese Bilder konnten nicht gelöscht werden, da sie in Benutzung sind: %{names}"
309
310
  "This page is locked by %{name}": "Diese Seite wird gerade von %{name} blockiert"
310
311
  "Title": "Titel"
311
312
  "Trash": "Papierkorb"
@@ -392,6 +392,7 @@ en:
392
392
  successfully_added_element: "Succesfully added new element."
393
393
  successfully_saved_element_position: "Element position updated succesfully."
394
394
  swap_image: "Change image"
395
+ "These pictures could not be deleted, because they where in use": "These pictures could not be deleted, because they where in use: %{names}"
395
396
  insert_image: "Insert image"
396
397
  swfupload:
397
398
  cancel_uploads: "Cancel uploads"
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.5.0"
3
+ VERSION = "2.5.1"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe "essences/_essence_picture_view" do
4
+
5
+ let(:essence_picture) { stub_model(Alchemy::EssencePicture, picture: stub_model(Alchemy::Picture), caption: 'This is a cute cat') }
6
+ let(:content) { stub_model(Alchemy::Content, name: 'image', essence_type: 'EssencePicture', essence: essence_picture) }
7
+
8
+ before do
9
+ ActionView::Base.send(:include, Alchemy::UrlHelper)
10
+ ActionView::Base.send(:include, Alchemy::EssencesHelper)
11
+ view.stub!(:configuration).and_return(:jpg)
12
+ end
13
+
14
+ context "with caption" do
15
+ let(:options) { {show_caption: true} }
16
+ let(:html_options) { {} }
17
+
18
+ subject do
19
+ render partial: "alchemy/essences/essence_picture_view", locals: {
20
+ content: content,
21
+ options: options,
22
+ html_options: html_options
23
+ }
24
+ end
25
+
26
+ it "should enclose the image in a <figure> element" do
27
+ should have_selector('figure img')
28
+ end
29
+
30
+ context "and essence with css class" do
31
+ before { essence_picture.css_class = 'left' }
32
+
33
+ it "should have the class on the <figure> element" do
34
+ should have_selector('figure.left img')
35
+ end
36
+
37
+ it "should not have the class on the <img> element" do
38
+ should_not have_selector('figure img.left')
39
+ end
40
+ end
41
+
42
+ context "and css class in the html_options" do
43
+ before { html_options[:class] = 'right' }
44
+
45
+ it "should have the class from the html_options on the <figure> element" do
46
+ should have_selector('figure.right img')
47
+ end
48
+
49
+ it "should not have the class from the essence on the <figure> element" do
50
+ should_not have_selector('figure.left img')
51
+ end
52
+
53
+ it "should not have the class from the html_options on the <img> element" do
54
+ should_not have_selector('figure img.right')
55
+ end
56
+ end
57
+ end
58
+
59
+ context "with link" do
60
+ let(:options) { {} }
61
+
62
+ subject do
63
+ essence_picture.link = '/home'
64
+ render partial: "alchemy/essences/essence_picture_view", locals: {
65
+ content: content,
66
+ options: options,
67
+ html_options: {}
68
+ }
69
+ end
70
+
71
+ it "should enclose the image in a link tag" do
72
+ should have_selector('a[href="/home"] img')
73
+ end
74
+
75
+ context "but disabled link option" do
76
+ before { options[:disable_link] = true }
77
+
78
+ it "should not enclose the image in a link tag" do
79
+ should_not have_selector('a img')
80
+ end
81
+ end
82
+ end
83
+
84
+ end
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: 2.5.0
4
+ version: 2.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-02-04 00:00:00.000000000 Z
16
+ date: 2013-02-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ~>
24
24
  - !ruby/object:Gem::Version
25
- version: 3.2.11
25
+ version: 3.2.12
26
26
  type: :runtime
27
27
  prerelease: false
28
28
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.11
33
+ version: 3.2.12
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: devise
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -485,7 +485,7 @@ files:
485
485
  - app/assets/javascripts/alchemy/alchemy.dirty.js
486
486
  - app/assets/javascripts/alchemy/alchemy.dragndrop.js
487
487
  - app/assets/javascripts/alchemy/alchemy.element_editor_selector.js
488
- - app/assets/javascripts/alchemy/alchemy.elements_window.js
488
+ - app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee
489
489
  - app/assets/javascripts/alchemy/alchemy.file_progress.js
490
490
  - app/assets/javascripts/alchemy/alchemy.growler.js
491
491
  - app/assets/javascripts/alchemy/alchemy.gui.js.coffee
@@ -1001,6 +1001,7 @@ files:
1001
1001
  - spec/support/image2.PNG
1002
1002
  - spec/support/image3.jpeg
1003
1003
  - spec/url_helpers_spec.rb
1004
+ - spec/views/essences/essence_picture_view_spec.rb
1004
1005
  - vendor/assets/images/Jcrop.gif
1005
1006
  - vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js
1006
1007
  - vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.1_0_1.js
@@ -1128,7 +1129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1128
1129
  version: '0'
1129
1130
  segments:
1130
1131
  - 0
1131
- hash: -4006673498087041620
1132
+ hash: 1217136868404784011
1132
1133
  requirements:
1133
1134
  - ImageMagick (libmagick), v6.6 or greater.
1134
1135
  rubyforge_project:
@@ -1265,4 +1266,5 @@ test_files:
1265
1266
  - spec/support/image2.PNG
1266
1267
  - spec/support/image3.jpeg
1267
1268
  - spec/url_helpers_spec.rb
1269
+ - spec/views/essences/essence_picture_view_spec.rb
1268
1270
  has_rdoc:
@@ -1,120 +0,0 @@
1
- if (typeof(Alchemy) === 'undefined') {
2
- var Alchemy = {};
3
- }
4
-
5
- (function($) {
6
-
7
- var ElementsWindow = {};
8
- $.extend(Alchemy, ElementsWindow);
9
-
10
- Alchemy.ElementsWindow = {
11
-
12
- init: function(path, options, callback) {
13
- var self = Alchemy.ElementsWindow;
14
- var $dialog = $('<div style="display: none" id="alchemyElementWindow"></div>');
15
- var closeCallback = function() {
16
- $dialog.dialog("destroy");
17
- $('#alchemyElementWindow').remove();
18
- Alchemy.ElementsWindow.button.enable();
19
- };
20
- self.path = path;
21
- self.callback = callback;
22
- $dialog.html(Alchemy.getOverlaySpinner({
23
- x: 420,
24
- y: 300
25
- }));
26
- self.dialog = $dialog;
27
- Alchemy.ElementsWindow.currentWindow = $dialog.dialog({
28
- modal: false,
29
- minWidth: 422,
30
- minHeight: 300,
31
- height: $(window).height() - 90,
32
- title: options.texts.title,
33
- show: "fade",
34
- hide: "fade",
35
- position: [$(window).width() - 428, 84],
36
- closeOnEscape: false,
37
- create: function() {
38
- $dialog.before(Alchemy.ElementsWindow.createToolbar(options.toolbarButtons));
39
- },
40
- open: function(event, ui) {
41
- Alchemy.ElementsWindow.button.disable();
42
- Alchemy.ElementsWindow.reload(callback);
43
- },
44
- beforeClose: function() {
45
- if (Alchemy.isPageDirty()) {
46
- Alchemy.openConfirmWindow({
47
- title: options.texts.dirtyTitle,
48
- message: options.texts.dirtyMessage,
49
- okLabel: options.texts.okLabel,
50
- cancelLabel: options.texts.cancelLabel,
51
- okCallback: closeCallback
52
- });
53
- return false;
54
- } else {
55
- return true;
56
- }
57
- },
58
- close: closeCallback
59
- });
60
- },
61
-
62
- button: {
63
- enable: function() {
64
- $('div#show_element_window').
65
- removeClass('disabled').
66
- find('a').removeAttr('tabindex');
67
- },
68
- disable: function() {
69
- $('div#show_element_window').
70
- addClass('disabled').
71
- find('a').attr('tabindex', '-1');
72
- },
73
- toggle: function() {
74
- if ($('div#show_element_window').hasClass('disabled')) {
75
- Alchemy.ElementsWindow.button.enable();
76
- } else {
77
- Alchemy.ElementsWindow.button.disable();
78
- }
79
- }
80
- },
81
-
82
- createToolbar: function(buttons) {
83
- var $toolbar = $('<div id="overlay_toolbar"></div>'),
84
- btn;
85
- for (i = 0; i < buttons.length; i++) {
86
- btn = buttons[i];
87
- $toolbar.append(
88
- Alchemy.ToolbarButton({
89
- buttonTitle: btn.title,
90
- buttonLabel: btn.label,
91
- iconClass: btn.iconClass,
92
- onClick: btn.onClick,
93
- buttonId: btn.buttonId
94
- }));
95
- }
96
- return $toolbar;
97
- },
98
-
99
- reload: function() {
100
- var self = Alchemy.ElementsWindow;
101
- $.ajax({
102
- url: self.path,
103
- success: function(data, textStatus, XMLHttpRequest) {
104
- self.dialog.html(data);
105
- Alchemy.Buttons.observe('#alchemyElementWindow');
106
- Alchemy.overlayObserver('#alchemyElementWindow');
107
- Alchemy.Datepicker('#alchemyElementWindow input.date, #alchemyElementWindow input[type="date"]');
108
- if (self.callback) {
109
- self.callback.call();
110
- }
111
- },
112
- error: function(XMLHttpRequest, textStatus, errorThrown) {
113
- Alchemy.AjaxErrorHandler($dialog, XMLHttpRequest.status, textStatus, errorThrown);
114
- }
115
- });
116
- }
117
-
118
- }
119
-
120
- })(jQuery);