alchemy_cms 2.5.0.b5 → 2.5.0.b9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/README.md +1 -1
  2. data/alchemy_cms.gemspec +2 -2
  3. data/app/assets/javascripts/alchemy/alchemy.base.js +0 -24
  4. data/app/assets/javascripts/alchemy/alchemy.growler.js +2 -4
  5. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +0 -1
  6. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +1 -1
  7. data/app/assets/stylesheets/alchemy/base.scss +4 -20
  8. data/app/assets/stylesheets/alchemy/elements.scss +19 -31
  9. data/app/assets/stylesheets/alchemy/flash.scss +11 -0
  10. data/app/assets/stylesheets/alchemy/form_elements.scss +2 -14
  11. data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -0
  12. data/app/assets/stylesheets/alchemy/mixins.scss +37 -2
  13. data/app/assets/stylesheets/alchemy/notices.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/sitemap.scss +30 -0
  15. data/app/assets/stylesheets/alchemy/tables.scss +20 -27
  16. data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
  17. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  18. data/app/controllers/alchemy/admin/contents_controller.rb +2 -2
  19. data/app/controllers/alchemy/admin/elements_controller.rb +3 -3
  20. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +2 -2
  21. data/app/controllers/alchemy/admin/pages_controller.rb +16 -9
  22. data/app/controllers/alchemy/admin/pictures_controller.rb +8 -8
  23. data/app/controllers/alchemy/admin/resources_controller.rb +1 -1
  24. data/app/controllers/alchemy/admin/tags_controller.rb +4 -4
  25. data/app/controllers/alchemy/admin/users_controller.rb +3 -3
  26. data/app/controllers/alchemy/base_controller.rb +10 -12
  27. data/app/controllers/alchemy/messages_controller.rb +2 -2
  28. data/app/controllers/alchemy/pages_controller.rb +4 -1
  29. data/app/controllers/alchemy/pictures_controller.rb +1 -4
  30. data/app/controllers/alchemy/user_sessions_controller.rb +5 -5
  31. data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
  32. data/app/helpers/alchemy/admin/base_helper.rb +13 -13
  33. data/app/helpers/alchemy/admin/contents_helper.rb +6 -6
  34. data/app/helpers/alchemy/admin/elements_helper.rb +2 -2
  35. data/app/helpers/alchemy/admin/essences_helper.rb +8 -8
  36. data/app/helpers/alchemy/admin/pages_helper.rb +13 -7
  37. data/app/helpers/alchemy/base_helper.rb +20 -5
  38. data/app/helpers/alchemy/elements_helper.rb +2 -2
  39. data/app/helpers/alchemy/essences_helper.rb +2 -2
  40. data/app/helpers/alchemy/pages_helper.rb +2 -3
  41. data/app/models/alchemy/cell.rb +11 -3
  42. data/app/models/alchemy/content.rb +17 -17
  43. data/app/models/alchemy/element.rb +49 -26
  44. data/app/models/alchemy/legacy_page_url.rb +6 -0
  45. data/app/models/alchemy/page.rb +24 -45
  46. data/app/models/alchemy/picture.rb +1 -2
  47. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +3 -3
  48. data/app/views/alchemy/admin/attachments/_attachment.html.erb +6 -6
  49. data/app/views/alchemy/admin/attachments/_files_list.html.erb +2 -2
  50. data/app/views/alchemy/admin/attachments/edit.html.erb +5 -3
  51. data/app/views/alchemy/admin/attachments/index.html.erb +3 -3
  52. data/app/views/alchemy/admin/attachments/new.html.erb +2 -2
  53. data/app/views/alchemy/admin/clipboard/clear.js.erb +1 -1
  54. data/app/views/alchemy/admin/clipboard/index.html.erb +3 -3
  55. data/app/views/alchemy/admin/clipboard/insert.js.erb +2 -2
  56. data/app/views/alchemy/admin/clipboard/remove.js.erb +4 -4
  57. data/app/views/alchemy/admin/contents/_missing.html.erb +2 -2
  58. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  59. data/app/views/alchemy/admin/contents/new.html.erb +3 -3
  60. data/app/views/alchemy/admin/dashboard/index.html.erb +12 -12
  61. data/app/views/alchemy/admin/elements/_add_picture.html.erb +1 -1
  62. data/app/views/alchemy/admin/elements/_element.html.erb +1 -1
  63. data/app/views/alchemy/admin/elements/_element_foot.html.erb +5 -5
  64. data/app/views/alchemy/admin/elements/_element_head.html.erb +6 -6
  65. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -2
  66. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +4 -4
  67. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +1 -1
  68. data/app/views/alchemy/admin/elements/create.js.erb +2 -2
  69. data/app/views/alchemy/admin/elements/index.html.erb +2 -2
  70. data/app/views/alchemy/admin/elements/list.js.erb +1 -1
  71. data/app/views/alchemy/admin/elements/new.html.erb +4 -4
  72. data/app/views/alchemy/admin/elements/order.js.erb +1 -1
  73. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  74. data/app/views/alchemy/admin/elements/update.js.erb +1 -1
  75. data/app/views/alchemy/admin/essence_files/edit.html.erb +5 -5
  76. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +4 -4
  77. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +4 -4
  78. data/app/views/alchemy/admin/languages/_form.html.erb +6 -10
  79. data/app/views/alchemy/admin/languages/_language.html.erb +4 -4
  80. data/app/views/alchemy/admin/languages/_table.html.erb +1 -1
  81. data/app/views/alchemy/admin/languages/index.html.erb +1 -1
  82. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +6 -6
  83. data/app/views/alchemy/admin/layoutpages/index.html.erb +8 -8
  84. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +7 -7
  85. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +10 -9
  86. data/app/views/alchemy/admin/pages/_external_link.html.erb +7 -7
  87. data/app/views/alchemy/admin/pages/_file_link.html.erb +6 -6
  88. data/app/views/alchemy/admin/pages/_internal_link.html.erb +5 -5
  89. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  90. data/app/views/alchemy/admin/pages/_page.html.erb +28 -28
  91. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +5 -5
  92. data/app/views/alchemy/admin/pages/_page_infos.html.erb +3 -3
  93. data/app/views/alchemy/admin/pages/_page_status.html.erb +3 -3
  94. data/app/views/alchemy/admin/pages/_sitemap.html.erb +1 -1
  95. data/app/views/alchemy/admin/pages/configure.html.erb +11 -11
  96. data/app/views/alchemy/admin/pages/configure_external.html.erb +4 -4
  97. data/app/views/alchemy/admin/pages/destroy.js.erb +0 -1
  98. data/app/views/alchemy/admin/pages/edit.html.erb +35 -35
  99. data/app/views/alchemy/admin/pages/flush.js.erb +1 -1
  100. data/app/views/alchemy/admin/pages/fold.js.erb +0 -1
  101. data/app/views/alchemy/admin/pages/index.html.erb +14 -14
  102. data/app/views/alchemy/admin/pages/link.html.erb +4 -4
  103. data/app/views/alchemy/admin/pages/locked.html.erb +1 -1
  104. data/app/views/alchemy/admin/pages/new.html.erb +4 -4
  105. data/app/views/alchemy/admin/pages/update.js.erb +2 -2
  106. data/app/views/alchemy/admin/partials/_autocomplete_tag_list.html.erb +1 -1
  107. data/app/views/alchemy/admin/partials/_flash_notices.html.erb +3 -3
  108. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +8 -8
  109. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +1 -1
  110. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +1 -1
  111. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
  112. data/app/views/alchemy/admin/partials/_search_form.html.erb +2 -2
  113. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +1 -1
  114. data/app/views/alchemy/admin/partials/_upload_form.html.erb +11 -11
  115. data/app/views/alchemy/admin/pictures/_archive.html.erb +13 -13
  116. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +7 -7
  117. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +4 -4
  118. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
  119. data/app/views/alchemy/admin/pictures/_picture.html.erb +7 -7
  120. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  121. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +2 -2
  122. data/app/views/alchemy/admin/pictures/edit.html.erb +2 -2
  123. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +6 -6
  124. data/app/views/alchemy/admin/pictures/index.html.erb +10 -10
  125. data/app/views/alchemy/admin/pictures/info.html.erb +2 -2
  126. data/app/views/alchemy/admin/pictures/new.html.erb +2 -2
  127. data/app/views/alchemy/admin/resources/_boolean.html.erb +5 -0
  128. data/app/views/alchemy/admin/resources/_datetime.html.erb +2 -0
  129. data/app/views/alchemy/admin/resources/_form.html.erb +17 -28
  130. data/app/views/alchemy/admin/resources/_resource.html.erb +4 -4
  131. data/app/views/alchemy/admin/resources/_string.html.erb +5 -0
  132. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  133. data/app/views/alchemy/admin/resources/_text.html.erb +5 -0
  134. data/app/views/alchemy/admin/resources/index.html.erb +1 -1
  135. data/app/views/alchemy/admin/tags/_tag.html.erb +4 -4
  136. data/app/views/alchemy/admin/tags/edit.html.erb +4 -4
  137. data/app/views/alchemy/admin/tags/index.html.erb +5 -5
  138. data/app/views/alchemy/admin/tags/new.html.erb +2 -2
  139. data/app/views/alchemy/admin/trash/clear.js.coffee +1 -1
  140. data/app/views/alchemy/admin/trash/index.html.erb +3 -3
  141. data/app/views/alchemy/admin/users/_table.html.erb +3 -3
  142. data/app/views/alchemy/admin/users/_user.html.erb +6 -6
  143. data/app/views/alchemy/admin/users/index.html.erb +4 -4
  144. data/app/views/alchemy/base/error_notice.html.erb +1 -4
  145. data/app/views/alchemy/elements/_editor_not_found.html.erb +2 -2
  146. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +1 -1
  147. data/app/views/alchemy/essences/_essence_file_editor.html.erb +7 -7
  148. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +5 -5
  149. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +8 -8
  150. data/app/views/alchemy/essences/_linkable_essence_tools.html.erb +2 -2
  151. data/app/views/alchemy/search/_form.html.erb +2 -2
  152. data/app/views/alchemy/search/_result.html.erb +1 -1
  153. data/app/views/alchemy/search/_results.html.erb +3 -3
  154. data/app/views/alchemy/user_sessions/leave.html.erb +5 -5
  155. data/app/views/alchemy/user_sessions/login.html.erb +1 -1
  156. data/app/views/alchemy/user_sessions/signup.html.erb +2 -2
  157. data/app/views/kaminari/_gap.html.erb +1 -1
  158. data/app/views/kaminari/_next_page.html.erb +2 -2
  159. data/app/views/kaminari/_prev_page.html.erb +2 -2
  160. data/app/views/layouts/alchemy/admin.html.erb +7 -7
  161. data/bin/alchemy +1 -1
  162. data/config/authorization_rules.rb +1 -3
  163. data/config/locales/alchemy.de.yml +33 -23
  164. data/config/locales/alchemy.en.yml +31 -6
  165. data/db/migrate/{20121026100815_alchemy_two_point_three.rb → 20121118000000_alchemy_two_point_four.rb} +51 -28
  166. data/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +11 -0
  167. data/lib/alchemy/capistrano.rb +22 -30
  168. data/lib/alchemy/errors.rb +45 -0
  169. data/lib/alchemy/i18n.rb +7 -5
  170. data/lib/alchemy/logger.rb +16 -0
  171. data/lib/alchemy/page_layout.rb +3 -3
  172. data/lib/alchemy/resource.rb +17 -1
  173. data/lib/alchemy/resources_helper.rb +8 -1
  174. data/lib/alchemy/upgrader.rb +9 -0
  175. data/lib/alchemy/version.rb +1 -1
  176. data/lib/alchemy_cms.rb +1 -6
  177. data/lib/rails/generators/alchemy/scaffold/files/elements.yml +41 -19
  178. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +13 -0
  179. data/lib/tasks/alchemy/db.rake +5 -11
  180. data/lib/tasks/alchemy/install.rake +7 -7
  181. data/spec/controllers/admin/pages_controller_spec.rb +14 -2
  182. data/spec/controllers/pages_controller_spec.rb +50 -17
  183. data/spec/dummy/config/application.rb +1 -1
  184. data/spec/dummy/db/migrate/{20121026100815_alchemy_two_point_three.rb → 20121118000000_alchemy_two_point_four.rb} +51 -28
  185. data/spec/dummy/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +11 -0
  186. data/spec/dummy/db/schema.rb +10 -1
  187. data/spec/factories.rb +1 -0
  188. data/spec/integration/admin/picture_library_integration_spec.rb +8 -2
  189. data/spec/integration/security_spec.rb +2 -2
  190. data/spec/integration/translation_integration_spec.rb +20 -4
  191. data/spec/libraries/resources_helper_spec.rb +1 -1
  192. data/spec/models/cell_spec.rb +45 -0
  193. data/spec/models/page_spec.rb +19 -2
  194. data/spec/models/picture_spec.rb +12 -0
  195. data/spec/routing_spec.rb +115 -115
  196. data/spec/spec_helper.rb +3 -0
  197. data/spec/support/alchemy/specs_helpers.rb +6 -2
  198. data/spec/support/image.png +0 -0
  199. data/spec/support/image2.PNG +0 -0
  200. data/spec/support/image3.jpeg +0 -0
  201. metadata +27 -23
  202. data/db/migrate/20121113115120_create_alchemy_essence_links.rb +0 -13
  203. data/db/migrate/20121115100736_add_cached_tag_list_to_elements_pages_and_users.rb +0 -7
  204. data/db/migrate/20121116140636_add_cached_tag_list_to_alchemy_attachments.rb +0 -5
  205. data/db/migrate/20121116141016_change_alchemy_pictures_tag_list_column.rb +0 -9
  206. data/spec/dummy/db/migrate/20121113115120_create_alchemy_essence_links.rb +0 -13
  207. data/spec/dummy/db/migrate/20121115100736_add_cached_tag_list_to_elements_pages_and_users.rb +0 -7
  208. data/spec/dummy/db/migrate/20121116140636_add_cached_tag_list_to_alchemy_attachments.rb +0 -5
  209. data/spec/dummy/db/migrate/20121116141016_change_alchemy_pictures_tag_list_column.rb +0 -9
@@ -3,7 +3,7 @@ module Alchemy
3
3
  module AttachmentsHelper
4
4
 
5
5
  def mime_to_human mime
6
- Alchemy::I18n.t(mime, :scope => :mime_types, :default => t('document'))
6
+ Alchemy::I18n.t(mime, :scope => :mime_types, :default => _t('document'))
7
7
  end
8
8
 
9
9
  end
@@ -52,10 +52,10 @@ module Alchemy
52
52
  return '' if page.level == 1
53
53
  if page.folded?(current_user.id)
54
54
  css_class = 'folded'
55
- title = t('Show childpages')
55
+ title = _t('Show childpages')
56
56
  else
57
57
  css_class = 'collapsed'
58
- title = t('Hide childpages')
58
+ title = _t('Hide childpages')
59
59
  end
60
60
  link_to(
61
61
  '',
@@ -78,7 +78,7 @@ module Alchemy
78
78
  # Used for translations selector in Alchemy cockpit user settings.
79
79
  def translations_for_select
80
80
  Alchemy::I18n.available_locales.map do |locale|
81
- [t(locale, :scope => :translations), locale]
81
+ [_t(locale, :scope => :translations), locale]
82
82
  end
83
83
  end
84
84
 
@@ -98,9 +98,9 @@ module Alchemy
98
98
  :onclick => "jQuery('##{options[:id]}').val(''); #{options[:onkeyup]}",
99
99
  :class => "js_filter_field_clear",
100
100
  :style => "display: none",
101
- :title => t("click_to_show_all")
101
+ :title => _t("click_to_show_all")
102
102
  })
103
- filter_field << %(<label for="#{options[:id]}">#{t(:search)}</label>)
103
+ filter_field << %(<label for="#{options[:id]}">#{_t(:search)}</label>)
104
104
  filter_field << '</div>'
105
105
  filter_field.html_safe
106
106
  end
@@ -122,10 +122,10 @@ module Alchemy
122
122
  link_to(link_string, url,
123
123
  html_options.merge(
124
124
  'data-alchemy-confirm-delete' => {
125
- :title => t("please_confirm"),
125
+ :title => _t("please_confirm"),
126
126
  :message => message,
127
- :ok_label => t("Yes"),
128
- :cancel_label => t("No")
127
+ :ok_label => _t("Yes"),
128
+ :cancel_label => _t("No")
129
129
  }.to_json
130
130
  )
131
131
  )
@@ -143,7 +143,7 @@ module Alchemy
143
143
  defaults = {
144
144
  :from_page => nil,
145
145
  :elements_with_name => nil,
146
- :prompt => t('Please choose')
146
+ :prompt => _t('Please choose')
147
147
  }
148
148
  options = defaults.merge(options)
149
149
  if options[:from_page]
@@ -171,7 +171,7 @@ module Alchemy
171
171
  # 4. The fourth parameter is the method that is called on the page object to get the value that is passed with the params of the form.
172
172
  #
173
173
  def pages_for_select(pages = nil, selected = nil, prompt = "", page_attribute = :id)
174
- result = [[prompt.blank? ? t('Choose page') : prompt, ""]]
174
+ result = [[prompt.blank? ? _t('Choose page') : prompt, ""]]
175
175
  if pages.blank?
176
176
  pages = Page.with_language(session[:language_id]).published.order(:lft)
177
177
  pages.each do |p|
@@ -192,7 +192,7 @@ module Alchemy
192
192
  content = element.contents[content - 1]
193
193
  end
194
194
  if content.essence.nil?
195
- return warning('Element', t('content_essence_not_found'))
195
+ return warning('Element', _t('content_essence_not_found'))
196
196
  end
197
197
  select_options = options_for_select(select_options, content.essence.content)
198
198
  select_tag(
@@ -292,7 +292,7 @@ module Alchemy
292
292
  if content_for?(:title)
293
293
  title = content_for(:title)
294
294
  else
295
- title = t(controller_name, :scope => :modules)
295
+ title = _t(controller_name, :scope => :modules)
296
296
  end
297
297
  "Alchemy CMS - #{title}"
298
298
  end
@@ -314,7 +314,7 @@ module Alchemy
314
314
 
315
315
  # (internal) Renders a select tag for all items in the clipboard
316
316
  def clipboard_select_tag(items, html_options = {})
317
- options = [[t('Please choose'), ""]]
317
+ options = [[_t('Please choose'), ""]]
318
318
  items.each do |item|
319
319
  options << [item.class.to_s == 'Alchemy::Element' ? item.display_name_with_preview_text : item.name, item.id]
320
320
  end
@@ -26,7 +26,7 @@ module Alchemy
26
26
  end
27
27
  if content.description.blank?
28
28
  warning("Content #{content.name} is missing its description")
29
- title = t("Warning: Content is missing its description.", :contentname => content.name)
29
+ title = _t(:content_description_missing)
30
30
  content_name = %(<span class="warning icon" title="#{title}"></span>&nbsp;#{content_name}).html_safe
31
31
  end
32
32
  content.has_validations? ? "#{content_name}<span class='validation_indicator'>*</span>".html_safe : content_name
@@ -38,11 +38,11 @@ module Alchemy
38
38
  #
39
39
  def render_new_content_link(element)
40
40
  link_to_overlay_window(
41
- render_icon(:create) + t('add new content'),
41
+ render_icon(:create) + _t('add new content'),
42
42
  alchemy.new_admin_element_content_path(element),
43
43
  {
44
44
  :size => '310x115',
45
- :title => t('Select an content'),
45
+ :title => _t('Select an content'),
46
46
  :overflow => true
47
47
  },
48
48
  {
@@ -77,7 +77,7 @@ module Alchemy
77
77
  #
78
78
  def render_create_content_link(element, content_name, options = {}, options_for_content = {})
79
79
  defaults = {
80
- :label => t('Add %{name}', :name => t(content_name, :scope => :content_names))
80
+ :label => _t('Add %{name}', :name => _t(content_name, :scope => :content_names))
81
81
  }
82
82
  options = defaults.merge(options)
83
83
  link_to(render_icon(:create) + options[:label], alchemy.admin_contents_path(
@@ -98,10 +98,10 @@ module Alchemy
98
98
  def delete_content_link(content)
99
99
  link_to_confirmation_window(
100
100
  render_icon('delete-small'),
101
- t('Do you really want to delete this content?'),
101
+ _t('Do you really want to delete this content?'),
102
102
  alchemy.admin_content_path(content),
103
103
  :class => 'icon_button small',
104
- :title => t('Remove this content')
104
+ :title => _t('Remove this content')
105
105
  ) if content.settings[:deletable]
106
106
  end
107
107
 
@@ -68,7 +68,7 @@ module Alchemy
68
68
  # The elements are returned as an array to be used in alchemy_selectbox form builder.
69
69
  def elements_for_select(elements)
70
70
  return [] if elements.nil?
71
- options = elements.collect { |e| [t(e['name'], :scope => :element_names), e["name"]] }
71
+ options = elements.collect { |e| [_t(e['name'], :scope => :element_names), e["name"]] }
72
72
  return options_for_select(options)
73
73
  end
74
74
 
@@ -90,7 +90,7 @@ module Alchemy
90
90
  end
91
91
  other_elements = elements - celled_elements
92
92
  unless other_elements.blank?
93
- optgroup_label = t(:main_content)
93
+ optgroup_label = _t(:main_content)
94
94
  options[optgroup_label] = other_elements.map do |e|
95
95
  element_array_for_options(e, object_method)
96
96
  end
@@ -22,8 +22,8 @@ module Alchemy
22
22
  # * editor_options (Hash) - Will be passed to the render_essence_editor partial renderer
23
23
  #
24
24
  def render_essence_editor_by_type(element, essence_type, options = {}, editor_options = {})
25
- return warning('Element is nil', t("no_element_given")) if element.blank?
26
- return warning('EssenceType is blank', t("No EssenceType given")) if essence_type.blank?
25
+ return warning('Element is nil', _t("no_element_given")) if element.blank?
26
+ return warning('EssenceType is blank', _t("No EssenceType given")) if essence_type.blank?
27
27
  defaults = {
28
28
  :position => 1,
29
29
  :all => false
@@ -68,7 +68,7 @@ module Alchemy
68
68
  #
69
69
  def render_essence_editor_by_name(element, name, options = {}, html_options = {})
70
70
  if element.blank?
71
- return warning('Element is nil', t("no_element_given"))
71
+ return warning('Element is nil', _t("no_element_given"))
72
72
  end
73
73
  content = element.content_by_name(name)
74
74
  if content.nil?
@@ -78,24 +78,24 @@ module Alchemy
78
78
  end
79
79
  end
80
80
 
81
- # Renders the EssenceSelect editor partial with a form select for storing page urlnames
81
+ # Renders the EssenceSelect editor partial with a form select for storing page ids
82
82
  #
83
83
  # === Options:
84
84
  #
85
85
  # :only [Hash] # Pagelayout names. Only pages with this page_layout will be displayed inside the select.
86
- # :page_attribute [Symbol] # The Page attribute which will be stored.
86
+ # :page_attribute [Symbol] # The Page attribute which will be stored. Default is id.
87
87
  # :global [Boolean] # Display only global pages. Default is false.
88
88
  # :order_by [Symbol] # Order pages by this attribute.
89
89
  #
90
- # NOTE: The order option only works if the +only+ option is also set.
91
- # Then the default is :name.
90
+ # NOTE: The +order_by+ option only works if the +only+ or the +global+ option is also set.
91
+ # Then the default ordering is by :name.
92
92
  # Otherwise the pages are ordered by their position in the nested set.
93
93
  #
94
94
  def page_selector(element, content_name, options = {}, select_options = {})
95
95
  default_options = {
96
96
  :page_attribute => :id,
97
97
  :global => false,
98
- :prompt => t('Choose page'),
98
+ :prompt => _t('Choose page'),
99
99
  :order_by => :name
100
100
  }
101
101
  options = default_options.merge(options)
@@ -52,7 +52,7 @@ module Alchemy
52
52
  custom_config_contents = Alchemy::Tinymce.custom_config_contents
53
53
  content_names = custom_config_contents.collect{ |c| c['name'] }
54
54
  if content_names.uniq.length != content_names.length
55
- raise "Duplicated content names with tinymce setting in elements.yml found. Please rename these contents."
55
+ raise TinymceError, "Duplicated content names with tinymce setting in elements.yml found. Please rename these contents."
56
56
  end
57
57
  custom_config_contents.each do |content|
58
58
  next unless content['settings']['tinymce']
@@ -84,15 +84,21 @@ module Alchemy
84
84
  def preview_sizes_for_select
85
85
  options_for_select([
86
86
  'auto',
87
- [t('240', :scope => 'preview_sizes'), 240],
88
- [t('320', :scope => 'preview_sizes'), 320],
89
- [t('480', :scope => 'preview_sizes'), 480],
90
- [t('768', :scope => 'preview_sizes'), 768],
91
- [t('1024', :scope => 'preview_sizes'), 1024],
92
- [t('1280', :scope => 'preview_sizes'), 1280]
87
+ [_t('240', :scope => 'preview_sizes'), 240],
88
+ [_t('320', :scope => 'preview_sizes'), 320],
89
+ [_t('480', :scope => 'preview_sizes'), 480],
90
+ [_t('768', :scope => 'preview_sizes'), 768],
91
+ [_t('1024', :scope => 'preview_sizes'), 1024],
92
+ [_t('1280', :scope => 'preview_sizes'), 1280]
93
93
  ])
94
94
  end
95
95
 
96
+ # Returns the translated explanation of the page´s status.
97
+ #
98
+ def combined_page_status(page)
99
+ _t(page.status.to_a.map{ |k, v| "#{k}.#{v}" }.flatten, :scope => "page_states").delete_if(&:blank?).join("<br>").html_safe
100
+ end
101
+
96
102
  end
97
103
  end
98
104
  end
@@ -1,6 +1,10 @@
1
1
  module Alchemy
2
2
  module BaseHelper
3
3
 
4
+ def _t(key, *args)
5
+ I18n.t(key, *args)
6
+ end
7
+
4
8
  # An alias for truncate.
5
9
  # Left here for downwards compatibilty.
6
10
  def shorten(text, length)
@@ -29,9 +33,7 @@ module Alchemy
29
33
 
30
34
  # Logs a message in the Rails logger (warn level) and optionally displays an error message to the user.
31
35
  def warning(message, text = nil)
32
- logger.warn %(\n
33
- ++++ WARNING: #{message}! from: #{caller.first}\n
34
- )
36
+ Logger.warn(message, caller.first)
35
37
  unless text.nil?
36
38
  warning = content_tag('p', :class => 'content_editor_error') do
37
39
  render_icon('warning') + text
@@ -55,8 +57,12 @@ module Alchemy
55
57
  # <p>Caution! This is a warning!</p>
56
58
  # <% end %>
57
59
  #
58
- def render_message(type = :info, &blk)
59
- content_tag :div, render_icon(type) + capture(&blk), :class => "#{type} message"
60
+ def render_message(type = :info, msg = nil, &blk)
61
+ if block_given?
62
+ content_tag :div, render_icon(type) + capture(&blk), :class => "#{type} message"
63
+ else
64
+ content_tag :div, render_icon(type) + msg, :class => "#{type} message"
65
+ end
60
66
  end
61
67
 
62
68
  # Returns an array of all pages in the same branch from current.
@@ -105,5 +111,14 @@ module Alchemy
105
111
  Alchemy::Language.published.count > 1
106
112
  end
107
113
 
114
+ # Renders the flash partial (+alchemy/admin/partials/flash+)
115
+ #
116
+ # @param [String] notice The notice you want to display
117
+ # @param [Symbol] style The style of this flash. Valid values are +:notice+ (default), +:warn+ and +:error+
118
+ #
119
+ def render_flash_notice(notice, style = :notice)
120
+ render('alchemy/admin/partials/flash', flash_type: style, message: notice)
121
+ end
122
+
108
123
  end
109
124
  end
@@ -81,7 +81,7 @@ module Alchemy
81
81
  end
82
82
 
83
83
  # This helper renders the Element partial for either the view or the editor part.
84
- # Generate element partials with ./script/generate elements
84
+ # Generate element partials with rails generate alchemy:elements
85
85
  def render_element(element, part = :view, options = {}, i = 1)
86
86
  begin
87
87
  if element.blank?
@@ -108,7 +108,7 @@ module Alchemy
108
108
  Element #{part} partial not found for #{element.name}.\n
109
109
  #{e}
110
110
  ))
111
- render :partial => "alchemy/elements/#{part}_not_found", :locals => {:name => element.name, :error => "Element #{part} partial not found. Use rails generate alchemy:elements to generate them."}
111
+ render :partial => "alchemy/elements/#{part}_not_found", :locals => {:name => element.name, :error => "Element #{part} partial not found.<br>Use <code>rails generate alchemy:elements</code> to generate it."}
112
112
  end
113
113
  end
114
114
 
@@ -110,9 +110,9 @@ module Alchemy
110
110
  def render_essence(content, part = :view, options = {}, html_options = {})
111
111
  options = {:for_view => {}, :for_editor => {}}.update(options)
112
112
  if content.nil?
113
- return part == :view ? "" : warning('Content is nil', t("content_not_found"))
113
+ return part == :view ? "" : warning('Content is nil', _t("content_not_found"))
114
114
  elsif content.essence.nil?
115
- return part == :view ? "" : warning('Essence is nil', t("content_essence_not_found"))
115
+ return part == :view ? "" : warning('Essence is nil', _t("content_essence_not_found"))
116
116
  end
117
117
  render(
118
118
  :partial => "alchemy/essences/#{content.essence_partial_name}_#{part.to_s}",
@@ -362,14 +362,13 @@ module Alchemy
362
362
  # Description = Your page description
363
363
  # Keywords: cms, ruby, rubyonrails, rails, software, development, html, javascript, ajax
364
364
  #
365
- # Then placing +render_meta_data(:title_prefix => "company", :title_seperator => "-")+ into the <head> part of the +pages.html.erb+ layout produces:
365
+ # Then placing +render_meta_data(:title_prefix => "Company", :title_seperator => "-")+ into the <head> part of the +pages.html.erb+ layout produces:
366
366
  #
367
367
  # <meta charset="UTF-8">
368
368
  # <title>Company - #{@page.title}</title>
369
369
  # <meta name="description" content="Your page description">
370
370
  # <meta name="keywords" content="cms, ruby, rubyonrails, rails, software, development, html, javascript, ajax">
371
- # <meta name="generator" content="Alchemy VERSION">
372
- # <meta name="date" content="Tue Dec 16 10:21:26 +0100 2008">
371
+ # <meta name="created" content="Tue Dec 16 10:21:26 +0100 2008">
373
372
  # <meta name="robots" content="index, follow">
374
373
  #
375
374
  def render_meta_data options={}
@@ -12,6 +12,7 @@
12
12
  #
13
13
  module Alchemy
14
14
  class Cell < ActiveRecord::Base
15
+ include Logger
15
16
 
16
17
  attr_accessible :page_id, :name
17
18
 
@@ -57,13 +58,20 @@ module Alchemy
57
58
  end
58
59
 
59
60
  # Returns the cell definition defined in +config/alchemy/cells.yml+
60
- def definition
61
- self.class.definition_for(self.name)
61
+ def description
62
+ description = self.class.definition_for(self.name)
63
+ if description.blank?
64
+ warn "Could not find cell definition for #{self.name}. Please check your cells.yml!"
65
+ return {}
66
+ else
67
+ description
68
+ end
62
69
  end
70
+ alias_method :definition, :description
63
71
 
64
72
  # Returns all elements that can be placed in this cell
65
73
  def available_elements
66
- definition['elements']
74
+ description['elements'] || []
67
75
  end
68
76
 
69
77
  def name_for_label
@@ -1,5 +1,6 @@
1
1
  module Alchemy
2
2
  class Content < ActiveRecord::Base
3
+ include Logger
3
4
 
4
5
  attr_accessible(
5
6
  :do_not_index,
@@ -50,7 +51,9 @@ module Alchemy
50
51
  description = element.content_description_for(essences_hash[:name])
51
52
  description = element.available_content_description_for(essences_hash[:name]) if description.blank?
52
53
  end
53
- raise "No description found in elements.yml for #{essences_hash.inspect} and #{element.inspect}" if description.blank?
54
+ if description.blank?
55
+ raise ContentDefinitionError, "No description found in elements.yml for #{essences_hash.inspect} and #{element.inspect}"
56
+ end
54
57
  content = new(:name => description['name'], :element_id => element.id)
55
58
  content.create_essence!(description)
56
59
  content
@@ -139,17 +142,15 @@ module Alchemy
139
142
  # Returns my description hash from elements.yml
140
143
  # Returns the description from available_contents if my own description is blank
141
144
  def description
142
- if self.element.blank?
143
- logger.warn("\n+++++++++++ Warning: Content with id #{self.id} is missing its Element\n")
144
- return nil
145
- else
146
- @desc ||= self.element.content_description_for(self.name)
147
- if @desc.blank?
148
- @desc ||= self.element.available_content_description_for(self.name)
149
- else
150
- return @desc
151
- end
145
+ if element.blank?
146
+ warn "Content with id #{self.id} is missing its Element."
147
+ return {}
148
+ end
149
+ desc = self.element.content_description_for(self.name)
150
+ if desc.blank?
151
+ self.element.available_content_description_for(self.name)
152
152
  end
153
+ desc || {}
153
154
  end
154
155
  alias_method :definition, :description
155
156
 
@@ -161,14 +162,14 @@ module Alchemy
161
162
 
162
163
  # Sets the ingredient from essence
163
164
  def ingredient=(value)
164
- raise "No essence found" if essence.nil?
165
+ raise EssenceMissingError if essence.nil?
165
166
  essence.ingredient = value
166
167
  end
167
168
 
168
169
  # Calls essence.update_attributes. Called from +Alchemy::Element#save_contents+
169
170
  # Ads errors to self.base if essence validation fails.
170
171
  def update_essence(params={})
171
- raise "Essence not found" if essence.nil?
172
+ raise EssenceMissingError if essence.nil?
172
173
  if essence.update_attributes(params)
173
174
  return true
174
175
  else
@@ -182,8 +183,7 @@ module Alchemy
182
183
  end
183
184
 
184
185
  def has_validations?
185
- return false if description.blank?
186
- !description['validate'].blank?
186
+ description['validate'].present?
187
187
  end
188
188
 
189
189
  # Returns a string to be passed to Rails form field tags to ensure we have same params layout everywhere.
@@ -243,7 +243,7 @@ module Alchemy
243
243
  def create_essence!(description)
244
244
  essence_class = self.class.normalize_essence_type(description['type']).constantize
245
245
  attributes = {
246
- :ingredient => default_or_lorem_ipsum(description['default'])
246
+ :ingredient => default_text(description['default'])
247
247
  }
248
248
  if description['type'] == "EssenceRichtext" || description['type'] == "EssenceText"
249
249
  attributes.merge!(:do_not_index => !description['do_not_index'].nil?)
@@ -257,7 +257,7 @@ module Alchemy
257
257
  end
258
258
  end
259
259
 
260
- def default_or_lorem_ipsum(default)
260
+ def default_text(default)
261
261
  return if default.nil?
262
262
  if default.is_a? Symbol
263
263
  I18n.t(default, :scope => :default_content_texts)