alchemy_cms 2.5.0.b5 → 2.5.0.b9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -35,7 +35,7 @@ module Alchemy
35
35
  @options = hashified_options
36
36
  end
37
37
  @attachments = Attachment.find_paginated(params, per_page_value_for_screen_size)
38
- @message = t('File %{name} uploaded succesfully', :name => @attachment.name)
38
+ @message = _t('File %{name} uploaded succesfully', :name => @attachment.name)
39
39
  # Are we using the Flash uploader? Or the plain html file uploader?
40
40
  if params[Rails.application.config.session_options[:key]].blank?
41
41
  flash[:notice] = @message
@@ -52,7 +52,7 @@ module Alchemy
52
52
  @attachment = Attachment.find(params[:id])
53
53
  oldname = @attachment.name
54
54
  if @attachment.update_attributes(params[:attachment])
55
- flash[:notice] = t("File renamed successfully from: '%{from}' to '%{to}'", :from => oldname, :to => @attachment.name)
55
+ flash[:notice] = _t("File renamed successfully from: '%{from}' to '%{to}'", :from => oldname, :to => @attachment.name)
56
56
  else
57
57
  render :action => "edit"
58
58
  end
@@ -63,7 +63,7 @@ module Alchemy
63
63
  @attachment = Attachment.find(params[:id])
64
64
  name = @attachment.name
65
65
  @attachment.destroy
66
- flash[:notice] = t("File: '%{name}' deleted successfully", :name => name)
66
+ flash[:notice] = _t("File: '%{name}' deleted successfully", :name => name)
67
67
  end
68
68
 
69
69
  def show
@@ -93,7 +93,7 @@ module Alchemy
93
93
  def render_errors_or_redirect(object, redirect_url, flash_notice)
94
94
  if object.errors.empty?
95
95
  @redirect_url = redirect_url
96
- flash[:notice] = t(flash_notice)
96
+ flash[:notice] = _t(flash_notice)
97
97
  respond_to do |format|
98
98
  format.js { render :action => :redirect }
99
99
  format.html { redirect_to @redirect_url }
@@ -44,13 +44,13 @@ module Alchemy
44
44
  content = Content.find(id)
45
45
  content.move_to_bottom
46
46
  end
47
- @notice = t("Successfully saved content position")
47
+ @notice = _t("Successfully saved content position")
48
48
  end
49
49
 
50
50
  def destroy
51
51
  @content = Content.find(params[:id])
52
52
  @content_dup = @content.clone
53
- @notice = t("Successfully deleted content", :content => @content.name_for_label)
53
+ @notice = _t("Successfully deleted content", :content => @content.name_for_label)
54
54
  @content.destroy
55
55
  end
56
56
 
@@ -70,8 +70,8 @@ module Alchemy
70
70
  @element_validated = @element.update_attributes!(params[:element])
71
71
  else
72
72
  @element_validated = false
73
- @notice = t('Validation failed')
74
- @error_message = "<h2>#{@notice}</h2><p>#{t(:content_validations_headline)}</p>".html_safe
73
+ @notice = _t('Validation failed')
74
+ @error_message = "<h2>#{@notice}</h2><p>#{_t(:content_validations_headline)}</p>".html_safe
75
75
  end
76
76
  end
77
77
 
@@ -116,7 +116,7 @@ module Alchemy
116
116
  cell_name = element_with_cell_name.split('#').last
117
117
  cell_definition = Cell.definition_for(cell_name)
118
118
  if cell_definition.blank?
119
- raise "Cell definition not found for #{cell_name}"
119
+ raise CellDefinitionError, "Cell definition not found for #{cell_name}"
120
120
  end
121
121
  @page.cells.find_or_create_by_name(cell_definition['name'])
122
122
  end
@@ -40,7 +40,7 @@ module Alchemy
40
40
  end
41
41
  @ratio = @options[:fixed_ratio] == 'false' ? false : (@size_x.to_f / @size_y.to_f)
42
42
  else
43
- @no_image_notice = t('No image found. Did you saved the element?')
43
+ @no_image_notice = _t('No image found. Did you saved the element?')
44
44
  end
45
45
  render :layout => false
46
46
  end
@@ -73,7 +73,7 @@ module Alchemy
73
73
  @picture_essence.link = params[:link]
74
74
  @picture_essence.link_title = params[:title]
75
75
  @picture_essence.open_link_in_new_window = params[:blank]
76
- @notice = t("saved_link")
76
+ @notice = _t("saved_link")
77
77
  @picture_essence.save
78
78
  end
79
79
 
@@ -28,8 +28,9 @@ module Alchemy
28
28
  end
29
29
  end
30
30
 
31
+ # Used by page preview iframe in Page#edit view.
32
+ #
31
33
  def show
32
- # fetching page via before filter
33
34
  @preview_mode = true
34
35
  @root_page = Page.language_root_for(session[:language_id])
35
36
  # Setting the locale to pages language. so the page content has its correct translation
@@ -63,14 +64,20 @@ module Alchemy
63
64
  else
64
65
  @page = Page.create(params[:page])
65
66
  end
66
- render_errors_or_redirect(@page, @page.valid? ? edit_admin_page_path(@page) : admin_pages_path, t("Page created", :name => @page.name))
67
+ redirect_path =
68
+ if @page.valid?
69
+ params[:redirect_to] || edit_admin_page_path(@page)
70
+ else
71
+ admin_pages_path
72
+ end
73
+ render_errors_or_redirect(@page, redirect_path, _t("Page created", :name => @page.name))
67
74
  end
68
75
 
69
76
  # Edit the content of the page and all its elements and contents.
70
77
  def edit
71
78
  # fetching page via before filter
72
79
  if @page.locked? && @page.locker && @page.locker.logged_in? && @page.locker != current_user
73
- flash[:notice] = t("This page is locked by %{name}", :name => (@page.locker.name rescue t('unknown')))
80
+ flash[:notice] = _t("This page is locked by %{name}", :name => (@page.locker.name rescue _t('unknown')))
74
81
  redirect_to admin_pages_path
75
82
  else
76
83
  @page.lock(current_user)
@@ -95,7 +102,7 @@ module Alchemy
95
102
  # storing old page_layout value, because unfurtunally rails @page.changes does not work here.
96
103
  @old_page_layout = @page.page_layout
97
104
  if @page.update_attributes(params[:page])
98
- @notice = t("Page saved", :name => @page.name)
105
+ @notice = _t("Page saved", :name => @page.name)
99
106
  @while_page_edit = request.referer.include?('edit')
100
107
  else
101
108
  render_remote_errors(@page, "#alchemyOverlay button.button")
@@ -109,7 +116,7 @@ module Alchemy
109
116
  @layoutpage = @page.layoutpage?
110
117
  if @page.destroy
111
118
  @page_root = Page.language_root_for(session[:language_id])
112
- @message = t("Page deleted", :name => name)
119
+ @message = _t("Page deleted", :name => name)
113
120
  flash[:notice] = @message
114
121
  respond_to do |format|
115
122
  format.js
@@ -153,7 +160,7 @@ module Alchemy
153
160
  def unlock
154
161
  # fetching page via before filter
155
162
  @page.unlock
156
- flash[:notice] = t("unlocked_page", :name => @page.name)
163
+ flash[:notice] = _t("unlocked_page", :name => @page.name)
157
164
  @pages_locked_by_user = Page.all_locked_by(current_user)
158
165
  respond_to do |format|
159
166
  format.js
@@ -173,7 +180,7 @@ module Alchemy
173
180
  # fetching page via before filter
174
181
  @page.public = true
175
182
  @page.save
176
- flash[:notice] = t("page_published", :name => @page.name)
183
+ flash[:notice] = _t("page_published", :name => @page.name)
177
184
  redirect_back_or_to_default(admin_pages_path)
178
185
  end
179
186
 
@@ -191,7 +198,7 @@ module Alchemy
191
198
  )
192
199
  new_language_root.move_to_child_of Page.root
193
200
  original_language_root.copy_children_to(new_language_root)
194
- flash[:notice] = t('language_pages_copied')
201
+ flash[:notice] = _t('language_pages_copied')
195
202
  redirect_to params[:layoutpage] == "true" ? admin_layoutpages_path : :action => :index
196
203
  end
197
204
 
@@ -213,7 +220,7 @@ module Alchemy
213
220
  prev_item = dbitem.reload
214
221
  end
215
222
 
216
- flash[:notice] = t("Pages order saved")
223
+ flash[:notice] = _t("Pages order saved")
217
224
  @redirect_url = admin_pages_path
218
225
  render :action => :redirect
219
226
  end
@@ -57,7 +57,7 @@ module Alchemy
57
57
  @per_page = pictures_per_page_for_size(@size)
58
58
  end
59
59
  @pictures = Picture.find_paginated(params, pictures_per_page_for_size(@size))
60
- @message = t('Picture uploaded succesfully', :name => @picture.name)
60
+ @message = _t('Picture uploaded succesfully', :name => @picture.name)
61
61
  # Are we using the single file uploader?
62
62
  if params[Rails.application.config.session_options[:key]].blank?
63
63
  flash[:notice] = @message
@@ -82,9 +82,9 @@ module Alchemy
82
82
  @picture = Picture.find(params[:id])
83
83
 
84
84
  if @picture.update_attributes(params[:picture])
85
- flash[:notice] = t('picture_updated_successfully', :name => @picture.name)
85
+ flash[:notice] = _t('picture_updated_successfully', :name => @picture.name)
86
86
  else
87
- flash[:error] = t('picture_update_failed')
87
+ flash[:error] = _t('picture_update_failed')
88
88
  end
89
89
  redirect_to_index
90
90
  end
@@ -97,7 +97,7 @@ module Alchemy
97
97
  picture.tag_list = params[:pictures_tag_list]
98
98
  picture.save
99
99
  end
100
- flash[:notice] = t("Pictures updated successfully")
100
+ flash[:notice] = _t("Pictures updated successfully")
101
101
  redirect_to_index
102
102
  end
103
103
 
@@ -110,9 +110,9 @@ module Alchemy
110
110
  names << picture.name
111
111
  picture.destroy
112
112
  end
113
- flash[:notice] = t("Pictures deleted successfully", :names => names.to_sentence)
113
+ flash[:notice] = _t("Pictures deleted successfully", :names => names.to_sentence)
114
114
  else
115
- flash[:notice] = t("Could not delete Pictures")
115
+ flash[:notice] = _t("Could not delete Pictures")
116
116
  end
117
117
  rescue Exception => e
118
118
  flash[:error] = e.message
@@ -124,7 +124,7 @@ module Alchemy
124
124
  @picture = Picture.find(params[:id])
125
125
  name = @picture.name
126
126
  @picture.destroy
127
- flash[:notice] = t("Picture deleted successfully", :name => name)
127
+ flash[:notice] = _t("Picture deleted successfully", :name => name)
128
128
  rescue Exception => e
129
129
  flash[:error] = e.message
130
130
  ensure
@@ -135,7 +135,7 @@ module Alchemy
135
135
  def flush
136
136
  # FileUtils.rm_rf only takes arrays of folders...
137
137
  FileUtils.rm_rf Dir.glob(Rails.root.join('public', Alchemy.mount_point, 'pictures', '*'))
138
- @notice = t('Picture cache flushed')
138
+ @notice = _t('Picture cache flushed')
139
139
  end
140
140
 
141
141
  def show_in_window
@@ -75,7 +75,7 @@ module Alchemy
75
75
  when :destroy
76
76
  verb = "removed"
77
77
  end
78
- flash[:notice] = t("#{resource_handler.model_name.classify} successfully #{verb}", :default => t("Succesfully #{verb}"))
78
+ flash[:notice] = _t("#{resource_handler.model_name.classify} successfully #{verb}", :default => _t("Succesfully #{verb}"))
79
79
  end
80
80
 
81
81
  def is_alchemy_module?
@@ -17,7 +17,7 @@ module Alchemy
17
17
 
18
18
  def create
19
19
  @tag = ActsAsTaggableOn::Tag.create(params[:tag])
20
- render_errors_or_redirect @tag, admin_tags_path, t('New Tag Created')
20
+ render_errors_or_redirect @tag, admin_tags_path, _t('New Tag Created')
21
21
  end
22
22
 
23
23
  def edit
@@ -29,12 +29,12 @@ module Alchemy
29
29
  if params[:replace]
30
30
  @new_tag = ActsAsTaggableOn::Tag.find(params[:tag][:merge_to])
31
31
  Tag.replace(@tag, @new_tag)
32
- operation_text = t('Replaced Tag %{old_tag} with %{new_tag}') % {:old_tag => @tag.name, :new_tag => @new_tag.name}
32
+ operation_text = _t('Replaced Tag %{old_tag} with %{new_tag}') % {:old_tag => @tag.name, :new_tag => @new_tag.name}
33
33
  @tag.destroy
34
34
  else
35
35
  @tag.update_attributes(params[:tag])
36
36
  @tag.save
37
- operation_text = t(:successfully_updated_tag)
37
+ operation_text = _t(:successfully_updated_tag)
38
38
  end
39
39
  render_errors_or_redirect @tag, admin_tags_path, operation_text
40
40
  end
@@ -42,7 +42,7 @@ module Alchemy
42
42
  def destroy
43
43
  if request.delete?
44
44
  @tag.destroy
45
- flash[:notice] = t(:successfully_deleted_tag)
45
+ flash[:notice] = _t(:successfully_deleted_tag)
46
46
  end
47
47
  @redirect_url = admin_tags_path
48
48
  render :action => :redirect
@@ -39,7 +39,7 @@ module Alchemy
39
39
  render_errors_or_redirect(
40
40
  @user,
41
41
  admin_users_path,
42
- t("User created", :name => @user.name)
42
+ _t("User created", :name => @user.name)
43
43
  )
44
44
  end
45
45
 
@@ -55,7 +55,7 @@ module Alchemy
55
55
  render_errors_or_redirect(
56
56
  @user,
57
57
  admin_users_path,
58
- t("User updated", :name => @user.name)
58
+ _t("User updated", :name => @user.name)
59
59
  )
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ module Alchemy
63
63
  # User is fetched via before filter
64
64
  name = @user.name
65
65
  if @user.destroy
66
- flash[:notice] = t("User deleted", :name => name)
66
+ flash[:notice] = _t("User deleted", :name => name)
67
67
  end
68
68
  @redirect_url = admin_users_path
69
69
  render :action => :redirect
@@ -10,7 +10,7 @@ module Alchemy
10
10
  before_filter :set_language
11
11
  before_filter :mailer_set_url_options
12
12
 
13
- helper_method :current_server, :current_site, :t
13
+ helper_method :current_server, :current_site
14
14
 
15
15
  # Returns a host string with the domain the app is running on.
16
16
  def current_server
@@ -39,9 +39,9 @@ module Alchemy
39
39
  raise ActionController::RoutingError.new('Not Found')
40
40
  end
41
41
 
42
- # Overriding +I18n+s default +t+ helper, so we can pass it through +Alchemy::I18n+
43
- def t(key, *args)
44
- ::Alchemy::I18n.t(key, *args)
42
+ # Shortcut for Alchemy::I18n.translate method
43
+ def _t(key, *args)
44
+ I18n.t(key, *args)
45
45
  end
46
46
 
47
47
  private
@@ -74,10 +74,8 @@ module Alchemy
74
74
  session[:current_locale] = ::I18n.locale = params[:locale]
75
75
  elsif current_user && current_user.language.present?
76
76
  ::I18n.locale = current_user.language
77
- elsif Rails.env == 'test' # OMG I hate to do this. But it helps...
78
- ::I18n.locale = 'en'
79
77
  else
80
- ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first)
78
+ ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale
81
79
  end
82
80
  end
83
81
 
@@ -117,7 +115,7 @@ module Alchemy
117
115
  end
118
116
 
119
117
  def load_language_default
120
- Language.get_default
118
+ Language.get_default || raise(DefaultLanguageNotFoundError)
121
119
  end
122
120
 
123
121
  def store_language_in_session(language)
@@ -201,19 +199,19 @@ module Alchemy
201
199
  elsif request.xhr?
202
200
  respond_to do |format|
203
201
  format.js {
204
- render :js => "Alchemy.growl('#{t('You are not authorized')}', 'warning'); Alchemy.Buttons.enable();"
202
+ render :js => "Alchemy.growl('#{_t('You are not authorized')}', 'warning'); Alchemy.Buttons.enable();"
205
203
  }
206
204
  format.html {
207
- render :partial => 'alchemy/admin/partials/flash', :locals => {:message => t('You are not authorized'), :flash_type => 'warning'}
205
+ render :partial => 'alchemy/admin/partials/flash', :locals => {:message => _t('You are not authorized'), :flash_type => 'warning'}
208
206
  }
209
207
  end
210
208
  else
211
- flash[:error] = t('You are not authorized')
209
+ flash[:error] = _t('You are not authorized')
212
210
  redirect_to alchemy.admin_dashboard_path
213
211
  end
214
212
  end
215
213
  else
216
- flash[:info] = t('Please log in')
214
+ flash[:info] = _t('Please log in')
217
215
  if request.xhr?
218
216
  render :action => :permission_denied
219
217
  else
@@ -17,7 +17,7 @@ module Alchemy
17
17
  # - name: mail_from
18
18
  # type: EssenceText
19
19
  # - name: success_page
20
- # type: EssenceText
20
+ # type: EssenceSelect
21
21
  #
22
22
  # The fields +mail_to+, +mail_from+, +subject+ and +success_page+ are recommended.
23
23
  # The +Alchemy::MessagesController+ uses them to send your mails. So your customer has full controll of these values inside his contactform element.
@@ -99,12 +99,12 @@ module Alchemy
99
99
  end
100
100
 
101
101
  def redirect_to_success_page
102
+ flash[:notice] = _t(:success, :scope => 'contactform.messages')
102
103
  if @element.ingredient("success_page")
103
104
  urlname = @element.ingredient("success_page")
104
105
  elsif mailer_config['forward_to_page'] && mailer_config['mail_success_page']
105
106
  urlname = Page.find_by_urlname(mailer_config['mail_success_page']).urlname
106
107
  else
107
- flash[:notice] = t(:success, :scope => 'contactform.messages')
108
108
  urlname = Page.language_root_for(session[:language_id]).urlname
109
109
  end
110
110
  redirect_to show_page_path(:urlname => urlname, :lang => multi_language? ? session[:language_code] : nil)
@@ -80,7 +80,7 @@ module Alchemy
80
80
 
81
81
  def enforce_primary_host_for_site
82
82
  if needs_redirect_to_primary_host?
83
- redirect_to url_for(host: current_site.host)
83
+ redirect_to url_for(host: current_site.host), :status => 301
84
84
  end
85
85
  end
86
86
 
@@ -94,6 +94,9 @@ module Alchemy
94
94
  @page ||= load_page
95
95
  if User.admins.count == 0 && @page.nil?
96
96
  redirect_to signup_path
97
+ elsif @page.nil? && legacy_url = LegacyPageUrl.where(urlname: params[:urlname]).last
98
+ @page = legacy_url.page
99
+ redirect_page
97
100
  elsif @page.blank?
98
101
  raise_not_found_error
99
102
  elsif multi_language? && params[:lang].blank?
@@ -33,6 +33,7 @@ module Alchemy
33
33
  image_file = image_file.process(:resize, size + '>')
34
34
  end
35
35
 
36
+ expires_in 1.month, public: !@picture.restricted?
36
37
  respond_to { |format| send_image(image_file, format) }
37
38
  end
38
39
 
@@ -106,8 +107,4 @@ module Alchemy
106
107
  end
107
108
 
108
109
  end
109
-
110
- class MissingImageFileError < StandardError
111
- end
112
-
113
110
  end
@@ -21,22 +21,22 @@ module Alchemy
21
21
  if params[:send_credentials]
22
22
  Notifications.admin_user_created(@user).deliver
23
23
  end
24
- flash[:notice] = t('Successfully signup admin user')
24
+ flash[:notice] = _t('Successfully signup admin user')
25
25
  redirect_to admin_dashboard_path
26
26
  end
27
27
  end
28
28
  rescue Errno::ECONNREFUSED => e
29
- flash[:error] = t(:signup_mail_delivery_error)
29
+ flash[:error] = _t(:signup_mail_delivery_error)
30
30
  redirect_to admin_dashboard_path
31
31
  end
32
32
 
33
33
  def login
34
34
  if current_user
35
- redirect_to admin_dashboard_path, :notice => t('You are already logged in')
35
+ redirect_to admin_dashboard_path, :notice => _t('You are already logged in')
36
36
  else
37
37
  if request.get?
38
38
  @user_session = UserSession.new()
39
- flash.now[:info] = params[:message] || t("welcome_please_identify_notice")
39
+ flash.now[:info] = params[:message] || _t("welcome_please_identify_notice")
40
40
  else
41
41
  @user_session = UserSession.new(params[:alchemy_user_session])
42
42
  store_screen_size
@@ -59,7 +59,7 @@ module Alchemy
59
59
  end
60
60
 
61
61
  def logout
62
- message = params[:message] || t("logged_out")
62
+ message = params[:message] || _t("logged_out")
63
63
  @user_session = UserSession.find
64
64
  if @user_session
65
65
  @user_session.destroy