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
@@ -2,7 +2,7 @@ module Alchemy
2
2
  module ResourcesHelper
3
3
 
4
4
  def resource_window_size
5
- @resource_window_size ||= "400x#{100 + resource_handler.attributes.length * 35}"
5
+ @resource_window_size ||= "420x#{100 + resource_handler.attributes.length * 40}"
6
6
  end
7
7
 
8
8
  def resource_instance_variable
@@ -60,5 +60,12 @@ module Alchemy
60
60
  end
61
61
  obj
62
62
  end
63
+
64
+ def resource_help_text(attribute)
65
+ if help_text = resource_handler.help_text_for(attribute)
66
+ content_tag(:p, help_text, class: 'foot_note')
67
+ end
68
+ end
69
+
63
70
  end
64
71
  end
@@ -22,6 +22,7 @@ module Alchemy
22
22
  convert_picture_storage
23
23
  upgrade_to_sites
24
24
  removed_standard_set_notice
25
+ renamed_t_method
25
26
 
26
27
  display_todos
27
28
  end
@@ -256,6 +257,14 @@ WARN
256
257
  warn = <<-WARN
257
258
  We removed the standard set from Alchemy core!
258
259
  In order to get the standard set back, install the `alchemy-demo_kit` gem.
260
+ WARN
261
+ todo warn
262
+ end
263
+
264
+ def renamed_t_method
265
+ warn = <<-WARN
266
+ We renamed alchemy's `t` method override into `_t` to avoid conflicts with Rails own t method!
267
+ If you use the `t` method to translate alchemy scoped keys, then you have to use the `_t` method from now on.
259
268
  WARN
260
269
  todo warn
261
270
  end
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.5.0.b5"
3
+ VERSION = "2.5.0.b9"
4
4
 
5
5
  def self.version
6
6
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -26,15 +26,10 @@ if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
26
26
  require 'alchemy/auth_engine'
27
27
  require 'alchemy/engine'
28
28
  require 'alchemy/picture_attributes'
29
- %w(config essence page_layout modules tinymce i18n scoped_pagination_url_helper resource resources_helper ferret_search).each do |class_name|
29
+ %w(config logger errors essence page_layout modules tinymce i18n scoped_pagination_url_helper resource resources_helper ferret_search).each do |class_name|
30
30
  require File.join(File.dirname(__FILE__), "alchemy", class_name)
31
31
  end
32
32
  require File.join(File.dirname(__FILE__), "alchemy", "seeder")
33
33
  else
34
34
  raise "Alchemy 2.5 needs Rails 3.2 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
35
35
  end
36
-
37
- module Alchemy
38
- class EssenceError < StandardError;
39
- end
40
- end
@@ -1,12 +1,12 @@
1
1
  # == In this configuration you setup Alchemy´s element layouts.
2
- #
2
+ #
3
3
  # Use rails generate alchemy:scaffold to generate this file for your app.
4
- #
4
+ #
5
5
  # Elements containing all necessary basic tools for displaying and editing content inside Alchemy.
6
6
  # They consists of composed contents (different essence-types) as shown in the illustration of an elements-sheme below.
7
7
  #
8
8
  # == Schema of an element
9
- #
9
+ #
10
10
  # =================================
11
11
  # # Content 1 (EssenceText) #
12
12
  # # #
@@ -16,7 +16,7 @@
16
16
  # =================================
17
17
  #
18
18
  # == Example of a basic element layout
19
- #
19
+ #
20
20
  # - name: a_unique_name (Used for the partial name in +app/views/elements+ and translated as Element.display_name)
21
21
  # unique: Bool //pass true if this element only can be displayed once on page
22
22
  # contents:
@@ -36,34 +36,34 @@
36
36
  # * EssenceFlash (Used to store attachment ids from attachments assigned through the library. The view renders an embeded object.)
37
37
  # * EssenceDate (Used to store a DateTime object. The view output is passed through Rails I18n Library, so it will be fully localized.)
38
38
  # * EssenceHtml (Used to store a String (max. 255 Chars.). The view output renders the raw, not sanitized or unescaped String. So be carefull!)
39
- #
39
+ #
40
40
  # After finishing the setup of your element layouts, you need to generate the files for the elements before using them in Alchemy.
41
41
  # For creating these files, use the following command in your terminal:
42
- #
43
- # rails generate elements
44
- #
42
+ #
43
+ # rails generate alchemy:elements
44
+ #
45
45
  # All new elements will be created as two different partials in Rails.root/app/views/elements.
46
46
  # For each element there is an editor-view wich will be rendered when editing them in Alchemy and another view for the website´s frontend.
47
- #
47
+ #
48
48
  # app/views/elements/_elements_name_editor.html.erb
49
49
  # app/views/elements/_elements_name_view.html.erb
50
- #
51
- # For most contents in an element you can specify additional options, so they get rendered in a specific way.
50
+ #
51
+ # For most contents of an element you can specify additional options, so they get rendered in a specific way.
52
52
  # These options can be defined as symbols, but its too much to list them up here.
53
53
  # You can find these options described in the application_helper.rb, most of them at the render_essence method.
54
54
  #
55
55
  # == Setting a content as preview-text for the element
56
- #
56
+ #
57
57
  # You can set a content-essence as preview-text for its element like this
58
58
  # take_me_for_preview: true
59
59
  #
60
60
  #
61
61
  # == Adding contents dynamically in the frontend
62
- #
62
+ #
63
63
  # You are able to add content-essences dynamically to the element from the Alchemy frontend.
64
64
  # You just have to make contents available for adding them.
65
65
  # This example enables this feature
66
- #
66
+ #
67
67
  # - name: headline
68
68
  # unique: false
69
69
  # contents:
@@ -77,15 +77,37 @@
77
77
  #
78
78
  # Now an Alchemy user can add the content 'big_text' from the element as much as desired.
79
79
  #
80
- # === Translate element names
81
- #
82
- # Element names are passed through the I18n library. So you can translate them in your config/locales language yml file.
83
- #
80
+ #
81
+ # == Deactivate indexing (Ferret search) for certain contents
82
+ #
83
+ # Contents of type EssenceText and EssenceRichtext can be excluded from being indexed by the Ferret search engine.
84
+ #
84
85
  # Example:
85
- #
86
+ #
87
+ # - name: contactform
88
+ # unique: true
89
+ # contents:
90
+ # - name: mail_to
91
+ # type: EssenceText
92
+ # do_not_index: true
93
+ #
94
+ #
95
+ # == Validate contents before updating the element
96
+ #
97
+ # More informations in [Content#essence_validations]
98
+ #
99
+ #
100
+ # == Translate element and content names
101
+ #
102
+ # Element and content names are passed through the I18n library. So you can translate them in your config/locales language yml file.
103
+ #
104
+ # Example:
105
+ #
86
106
  # de:
87
107
  # alchemy:
88
108
  # element_names:
89
109
  # contact: Kontakt
90
110
  # search: Suche
111
+ # content_names:
112
+ # headline: Überschrift
91
113
 
@@ -4,6 +4,7 @@ module Alchemy
4
4
  module Generators
5
5
  class ScaffoldGenerator < ::Rails::Generators::Base
6
6
  desc "This generator generates the Alchemy scaffold."
7
+ class_option :copy_views, :default => false, :type => :boolean, :desc => "Copy all Alchemy views into your app.", :aliases => '-v'
7
8
  source_root File.expand_path('templates', File.dirname(__FILE__))
8
9
 
9
10
  def create_config_dir
@@ -15,6 +16,10 @@ module Alchemy
15
16
  empty_directory Rails.root.join("app/views/alchemy/page_layouts")
16
17
  end
17
18
 
19
+ def copy_view_dirs
20
+ copy_alchemy_views if @options['copy_views']
21
+ end
22
+
18
23
  def copy_config
19
24
  copy_file "#{config_path}/config.yml", "#{Rails.root}/config/alchemy/config.yml"
20
25
  end
@@ -31,6 +36,14 @@ module Alchemy
31
36
  @config_path ||= File.expand_path('../../../../../config/alchemy', File.dirname(__FILE__))
32
37
  end
33
38
 
39
+ def copy_alchemy_views
40
+ %w(messages navigation notifications search).each do |dir|
41
+ src = File.expand_path("../../../../../app/views/alchemy/#{dir}", File.dirname(__FILE__))
42
+ dest = Rails.root.join('app/views/alchemy', dir)
43
+ directory src, dest
44
+ end
45
+ end
46
+
34
47
  end
35
48
  end
36
49
  end
@@ -6,19 +6,13 @@ namespace :alchemy do
6
6
  Alchemy::Seeder.seed!
7
7
  end
8
8
 
9
- desc "Dumps the database into 'db/dumps'. NOTE: This only works with MySQL yet."
9
+ desc "Dumps the database to STDOUT (Pass DUMP_FILENAME to store the dump into a file). NOTE: This only works with MySQL yet."
10
10
  task :dump => :environment do
11
11
  db_conf = Rails.configuration.database_configuration.fetch(Rails.env)
12
- raise "Alchemy only supports MySQL database dumping at the moment." unless db_conf['adapter'] =~ /mysql/
13
- FileUtils.mkdir_p(Rails.root.join('db/dumps'))
14
- `mysqldump -u#{db_conf['username']}#{db_conf['password'].present? ? " -p'#{db_conf['password']}'" : nil} #{db_conf['database']} > #{Rails.root.join('db/dumps', dump_name)}`
15
- end
16
-
17
- def dump_name
18
- return ENV['DUMP_FILENAME'] if ENV['DUMP_FILENAME'].present?
19
- app_name = Rails.application.class.name.underscore.split('/').first
20
- timestamp = Time.now.strftime('%Y-%m-%d-%H-%M')
21
- dump_name = "#{app_name}-#{timestamp}.sql"
12
+ raise "Sorry, but Alchemy only supports MySQL database dumping at the moment." unless db_conf['adapter'] =~ /mysql/
13
+ dump_store = ENV['DUMP_FILENAME'] ? " > #{Rails.root.join('db/dumps', dump_name)}" : ""
14
+ cmd = "mysqldump --user='#{db_conf['username']}'#{db_conf['password'].present? ? " --password='#{db_conf['password']}'" : nil} #{db_conf['database']}#{dump_store}"
15
+ system cmd
22
16
  end
23
17
 
24
18
  end
@@ -3,16 +3,16 @@ require 'thor'
3
3
  class Alchemy::RoutesInjector < Thor
4
4
  include Thor::Actions
5
5
 
6
- def initialize; super; end
7
-
8
6
  no_tasks do
9
7
  def inject
10
- @mountpoint = ask "\nWhere do you want to mount Alchemy CMS? (/)"
11
- @mountpoint = "/" if @mountpoint.empty?
8
+ mountpoint = ask "\nWhere do you want to mount Alchemy CMS? (/)"
9
+ mountpoint = "/" if mountpoint.empty?
12
10
  sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
13
- inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{@mountpoint}'\n", { :after => sentinel, :verbose => true }
11
+ inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{mountpoint}'\n", { :after => sentinel, :verbose => true }
12
+ mountpoint
14
13
  end
15
14
  end
15
+
16
16
  end
17
17
 
18
18
  namespace :alchemy do
@@ -37,7 +37,7 @@ Now cd into your app folder and
37
37
 
38
38
  2. Open your browser and enter the following URL:
39
39
 
40
- http://localhost:3000/#{@mountpoint}
40
+ http://localhost:3000/#{@mountpoint.gsub(/^\//, '')}
41
41
 
42
42
  3. Follow the instructions to complete the installation!
43
43
 
@@ -56,7 +56,7 @@ EOF
56
56
 
57
57
  desc "Mounts Alchemy into your routes."
58
58
  task :mount do
59
- Alchemy::RoutesInjector.new.inject
59
+ @mountpoint = Alchemy::RoutesInjector.new.inject
60
60
  end
61
61
 
62
62
  end
@@ -39,13 +39,13 @@ module Alchemy
39
39
 
40
40
  describe '#create' do
41
41
 
42
- render_views
42
+ let(:parent) { FactoryGirl.create(:public_page) }
43
43
 
44
44
  context "with paste_from_clipboard in parameters" do
45
+ render_views
45
46
 
46
47
  let(:clipboard) { session[:clipboard] = Clipboard.new }
47
48
  let(:page_in_clipboard) { FactoryGirl.create(:public_page) }
48
- let(:parent) { FactoryGirl.create(:public_page) }
49
49
 
50
50
  before(:each) do
51
51
  clipboard[:pages] = [{:id => page_in_clipboard.id, :action => 'cut'}]
@@ -59,6 +59,18 @@ module Alchemy
59
59
 
60
60
  end
61
61
 
62
+ context "with redirect_to in the parameters" do
63
+
64
+ let(:page_params) do
65
+ {:name => "Foobar", :page_layout => 'standard', :parent_id => parent.id}
66
+ end
67
+
68
+ it "should redirect to given url" do
69
+ post :create, :page => page_params, :redirect_to => admin_users_path
70
+ response.should redirect_to(admin_users_path)
71
+ end
72
+ end
73
+
62
74
  end
63
75
 
64
76
  describe '#copy_language_tree' do
@@ -2,26 +2,21 @@ require 'spec_helper'
2
2
 
3
3
  describe Alchemy::PagesController do
4
4
 
5
- render_views
6
-
7
- before(:each) do
8
- @default_language = Alchemy::Language.get_default
9
- @default_language_root = FactoryGirl.create(:language_root_page, :language => @default_language, :name => 'Home', :public => true)
10
- end
5
+ let(:default_language) { Alchemy::Language.get_default }
6
+ let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home', :public => true) }
11
7
 
12
8
  context "requested for a page containing a feed" do
9
+ render_views
13
10
 
14
- before(:each) do
15
- @page = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :page_layout => 'news', :name => 'News', :language => @default_language, :do_not_autogenerate => false)
16
- end
11
+ let(:page) { FactoryGirl.create(:public_page, :parent_id => default_language_root.id, :page_layout => 'news', :name => 'News', :language => default_language, :do_not_autogenerate => false) }
17
12
 
18
13
  it "should render a rss feed" do
19
- get :show, :urlname => 'news', :format => :rss
14
+ get :show, :urlname => page.urlname, :format => :rss
20
15
  response.content_type.should == 'application/rss+xml'
21
16
  end
22
17
 
23
18
  it "should include content" do
24
- @page.elements.first.content_by_name('news_headline').essence.update_attributes({:body => 'Peters Petshop'})
19
+ page.elements.first.content_by_name('news_headline').essence.update_attributes({:body => 'Peters Petshop'})
25
20
  get :show, :urlname => 'news', :format => :rss
26
21
  response.body.should match /Peters Petshop/
27
22
  end
@@ -31,7 +26,7 @@ describe Alchemy::PagesController do
31
26
  context "requested for a page that does not contain a feed" do
32
27
 
33
28
  it "should render xml 404 error" do
34
- get :show, :urlname => 'home', :format => :rss
29
+ get :show, :urlname => default_language_root.urlname, :format => :rss
35
30
  response.status.should == 404
36
31
  end
37
32
 
@@ -59,11 +54,14 @@ describe Alchemy::PagesController do
59
54
 
60
55
  context "with params layout set to not existing layout" do
61
56
  it "should raise ActionView::MissingTemplate" do
62
- expect { get :show, :urlname => :home, :layout => 'lkuiuk' }.to raise_error(ActionView::MissingTemplate)
57
+ expect {
58
+ get :show, :urlname => default_language_root.urlname, :layout => 'lkuiuk'
59
+ }.to raise_error(ActionView::MissingTemplate)
63
60
  end
64
61
  end
65
62
 
66
63
  context "with param layout set to a custom layout" do
64
+ render_views
67
65
 
68
66
  before do
69
67
  @custom_layout = Rails.root.join('app/views/layouts', 'custom.html.erb')
@@ -73,7 +71,7 @@ describe Alchemy::PagesController do
73
71
  end
74
72
 
75
73
  it "should render the custom layout" do
76
- get :show, :urlname => :home, :layout => 'custom'
74
+ get :show, :urlname => default_language_root.urlname, :layout => 'custom'
77
75
  response.body.should have_content('I am a custom layout')
78
76
  end
79
77
 
@@ -85,11 +83,12 @@ describe Alchemy::PagesController do
85
83
  end
86
84
 
87
85
  describe "url nesting" do
86
+ render_views
88
87
 
89
88
  before(:each) do
90
- @catalog = FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => @default_language_root.id, :language => @default_language)
91
- @products = FactoryGirl.create(:public_page, :name => "Products", :parent_id => @catalog.id, :language => @default_language)
92
- @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language, :do_not_autogenerate => false)
89
+ @catalog = FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => default_language_root.id, :language => default_language)
90
+ @products = FactoryGirl.create(:public_page, :name => "Products", :parent_id => @catalog.id, :language => default_language)
91
+ @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => default_language, :do_not_autogenerate => false)
93
92
  @product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
94
93
  controller.stub!(:configuration) { |arg| arg == :url_nesting ? true : false }
95
94
  end
@@ -164,4 +163,38 @@ describe Alchemy::PagesController do
164
163
  end
165
164
  end
166
165
 
166
+ describe 'Redirecting to legacy page urls' do
167
+ context 'Request a page with legacy url' do
168
+
169
+ # otherwise we are redirected to signup
170
+ before { FactoryGirl.create(:admin_user) }
171
+
172
+ let(:page) { FactoryGirl.create(:public_page, :name => 'New page name') }
173
+ let(:second_page) { FactoryGirl.create(:public_page, :name => 'Second Page') }
174
+ let(:legacy_page) { FactoryGirl.create(:public_page, :name => 'Legacy Url') }
175
+ let(:legacy_url) { Alchemy::LegacyPageUrl.create(:urlname => 'legacy-url', :page => page) }
176
+ let(:legacy_url2) { Alchemy::LegacyPageUrl.create(:urlname => 'legacy-url', :page => second_page) }
177
+
178
+ it "should redirect permanently to page that belongs to legacy page url." do
179
+ get :show, :urlname => legacy_url.urlname
180
+ response.status.should == 301
181
+ response.should redirect_to('/alchemy/new-page-name')
182
+ end
183
+
184
+ it "should only redirect to legacy url if no page was found for urlname" do
185
+ legacy_url
186
+ get :show, :urlname => legacy_page.urlname
187
+ response.status.should == 200
188
+ response.should_not redirect_to('/alchemy/new-page-name')
189
+ end
190
+
191
+ it "should redirect to last page that has that legacy url" do
192
+ legacy_url
193
+ get :show, :urlname => legacy_url2.urlname
194
+ response.should redirect_to('/alchemy/second-page')
195
+ end
196
+
197
+ end
198
+ end
199
+
167
200
  end
@@ -37,7 +37,7 @@ module Dummy
37
37
 
38
38
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
39
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
40
- # config.i18n.default_locale = :de
40
+ config.i18n.default_locale = :en
41
41
 
42
42
  # Configure the default encoding used in templates for Ruby 1.9.
43
43
  config.encoding = "utf-8"