alchemy_cms 2.6.3 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +14 -0
  3. data/.travis.yml +1 -1
  4. data/Gemfile +7 -6
  5. data/README.md +15 -5
  6. data/alchemy_cms.gemspec +3 -2
  7. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +9 -17
  8. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +70 -0
  9. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +80 -0
  10. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +43 -19
  11. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +3 -1
  12. data/app/assets/javascripts/alchemy/alchemy.js +4 -2
  13. data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +1 -1
  14. data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +14 -0
  15. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +96 -0
  16. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +22 -0
  17. data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +28 -17
  18. data/app/assets/stylesheets/alchemy/base.scss +6 -0
  19. data/app/assets/stylesheets/alchemy/elements.scss +2 -28
  20. data/app/assets/stylesheets/alchemy/errors.scss +1 -1
  21. data/app/assets/stylesheets/alchemy/menubar.css.scss +2 -0
  22. data/app/assets/stylesheets/alchemy/sitemap.scss +21 -34
  23. data/app/assets/stylesheets/alchemy/tables.scss +13 -3
  24. data/app/controllers/alchemy/admin/attachments_controller.rb +10 -5
  25. data/app/controllers/alchemy/admin/base_controller.rb +19 -0
  26. data/app/controllers/alchemy/admin/contents_controller.rb +1 -4
  27. data/app/controllers/alchemy/admin/dashboard_controller.rb +2 -1
  28. data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
  29. data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
  30. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +70 -56
  31. data/app/controllers/alchemy/admin/pages_controller.rb +37 -114
  32. data/app/controllers/alchemy/admin/pictures_controller.rb +5 -12
  33. data/app/controllers/alchemy/admin/resources_controller.rb +3 -1
  34. data/app/controllers/alchemy/admin/trash_controller.rb +1 -1
  35. data/app/controllers/alchemy/attachments_controller.rb +1 -1
  36. data/app/controllers/alchemy/base_controller.rb +3 -15
  37. data/app/controllers/alchemy/messages_controller.rb +4 -10
  38. data/app/controllers/alchemy/pages_controller.rb +6 -6
  39. data/app/controllers/alchemy/passwords_controller.rb +1 -1
  40. data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
  41. data/app/helpers/alchemy/admin/base_helper.rb +49 -230
  42. data/app/helpers/alchemy/admin/contents_helper.rb +5 -1
  43. data/app/helpers/alchemy/admin/elements_helper.rb +19 -47
  44. data/app/helpers/alchemy/admin/essences_helper.rb +59 -17
  45. data/app/helpers/alchemy/admin/navigation_helper.rb +204 -0
  46. data/app/helpers/alchemy/admin/pages_helper.rb +22 -79
  47. data/app/helpers/alchemy/admin/pictures_helper.rb +1 -1
  48. data/app/helpers/alchemy/admin/tags_helper.rb +42 -0
  49. data/app/helpers/alchemy/base_helper.rb +0 -11
  50. data/app/helpers/alchemy/elements_helper.rb +48 -25
  51. data/app/helpers/alchemy/essences_helper.rb +0 -20
  52. data/app/helpers/alchemy/pages_helper.rb +18 -14
  53. data/app/helpers/alchemy/url_helper.rb +1 -0
  54. data/app/mailers/alchemy/messages.rb +4 -6
  55. data/app/models/alchemy/attachment.rb +3 -0
  56. data/app/models/alchemy/cell.rb +33 -35
  57. data/app/models/alchemy/content.rb +20 -111
  58. data/app/models/alchemy/content/factory.rb +188 -0
  59. data/app/models/alchemy/element.rb +51 -200
  60. data/app/models/alchemy/element/definitions.rb +52 -0
  61. data/app/models/alchemy/element/presenters.rb +87 -0
  62. data/app/models/alchemy/essence_date.rb +1 -1
  63. data/app/models/alchemy/essence_file.rb +6 -7
  64. data/app/models/alchemy/essence_picture.rb +19 -4
  65. data/app/models/alchemy/message.rb +18 -14
  66. data/app/models/alchemy/page.rb +120 -214
  67. data/app/models/alchemy/page/elements.rb +145 -36
  68. data/app/models/alchemy/page/natures.rb +90 -0
  69. data/app/models/alchemy/page/scopes.rb +93 -0
  70. data/app/models/alchemy/page/users.rb +25 -0
  71. data/app/models/alchemy/picture.rb +15 -0
  72. data/app/models/alchemy/site.rb +15 -1
  73. data/app/models/alchemy/site/layout.rb +38 -0
  74. data/app/models/alchemy/user.rb +13 -3
  75. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +7 -7
  76. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +8 -8
  77. data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -16
  78. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -4
  79. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  80. data/app/views/alchemy/admin/dashboard/index.html.erb +14 -13
  81. data/app/views/alchemy/admin/elements/_element_head.html.erb +7 -7
  82. data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +10 -0
  83. data/app/views/alchemy/admin/elements/create.js.erb +44 -44
  84. data/app/views/alchemy/admin/elements/fold.js.erb +22 -26
  85. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  86. data/app/views/alchemy/admin/elements/update.js.erb +22 -25
  87. data/app/views/alchemy/admin/essence_files/assign.js.erb +8 -3
  88. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +14 -12
  89. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +22 -39
  90. data/app/views/alchemy/admin/pages/_page.html.erb +73 -80
  91. data/app/views/alchemy/admin/pages/destroy.js.erb +2 -2
  92. data/app/views/alchemy/admin/pages/edit.html.erb +21 -18
  93. data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
  94. data/app/views/alchemy/admin/pages/info.html.erb +32 -0
  95. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +11 -13
  96. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +20 -20
  97. data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +8 -0
  98. data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +25 -0
  99. data/app/views/alchemy/admin/partials/_upload_form.html.erb +15 -15
  100. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +39 -39
  101. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +10 -10
  102. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -16
  103. data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
  104. data/app/views/alchemy/base/500.html.erb +1 -1
  105. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  106. data/app/views/alchemy/base/redirect.js.erb +1 -1
  107. data/app/views/alchemy/essences/_essence_link_editor.html.erb +1 -1
  108. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +1 -1
  109. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
  110. data/app/views/alchemy/essences/_essence_text_editor.html.erb +1 -1
  111. data/app/views/alchemy/essences/{_essence_picture_tools.html.erb → shared/_essence_picture_tools.html.erb} +5 -5
  112. data/app/views/alchemy/essences/{_linkable_essence_tools.html.erb → shared/_linkable_essence_tools.html.erb} +0 -0
  113. data/app/views/alchemy/messages/contact_form_mail.de.text.erb +12 -0
  114. data/app/views/alchemy/messages/contact_form_mail.en.text.erb +12 -0
  115. data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
  116. data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +2 -2
  117. data/app/views/alchemy/pages/sitemap.xml.erb +3 -5
  118. data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
  119. data/app/views/layouts/alchemy/admin.html.erb +4 -2
  120. data/app/views/layouts/alchemy/sitemap.xml.erb +1 -1
  121. data/bin/alchemy +7 -13
  122. data/config/alchemy/config.yml +1 -0
  123. data/config/authorization_rules.rb +2 -3
  124. data/config/initializers/dragonfly.rb +2 -0
  125. data/config/locales/alchemy.de.yml +8 -9
  126. data/config/locales/alchemy.en.yml +7 -4
  127. data/config/routes.rb +3 -0
  128. data/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
  129. data/lib/alchemy/auth/engine.rb +9 -0
  130. data/lib/alchemy/capistrano.rb +37 -12
  131. data/lib/alchemy/config.rb +48 -35
  132. data/lib/alchemy/engine.rb +35 -6
  133. data/lib/alchemy/essence.rb +25 -29
  134. data/lib/alchemy/ferret/search.rb +86 -0
  135. data/lib/alchemy/{scoped_pagination_url_helper.rb → kaminari/scoped_pagination_url_helper.rb} +0 -0
  136. data/lib/alchemy/logger.rb +3 -4
  137. data/lib/alchemy/page_layout.rb +124 -55
  138. data/lib/alchemy/resource.rb +0 -10
  139. data/lib/alchemy/resources_helper.rb +0 -5
  140. data/lib/alchemy/seeder.rb +1 -32
  141. data/lib/alchemy/shell.rb +6 -1
  142. data/lib/alchemy/tinymce.rb +41 -32
  143. data/lib/alchemy/upgrader.rb +3 -1
  144. data/lib/alchemy/upgrader/two_point_five.rb +15 -8
  145. data/lib/alchemy/upgrader/two_point_one.rb +10 -10
  146. data/lib/alchemy/upgrader/two_point_two.rb +96 -51
  147. data/lib/alchemy/version.rb +1 -1
  148. data/lib/alchemy_cms.rb +5 -46
  149. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
  150. data/lib/rails/generators/alchemy/devise/devise_generator.rb +9 -4
  151. data/lib/rails/generators/alchemy/essence/essence_generator.rb +7 -6
  152. data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
  153. data/lib/rails/generators/alchemy/scaffold/files/_standard.html.erb +1 -0
  154. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
  155. data/lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb +23 -0
  156. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.erb +1 -0
  157. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.haml +1 -0
  158. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.slim +1 -0
  159. data/lib/rails/templates/alchemy.rb +2 -2
  160. data/lib/tasks/alchemy/db.rake +3 -1
  161. data/lib/tasks/alchemy/tidy.rake +82 -0
  162. data/lib/tasks/alchemy/upgrade.rake +2 -1
  163. data/spec/controllers/admin/attachments_controller_spec.rb +124 -0
  164. data/spec/controllers/admin/base_controller_spec.rb +35 -0
  165. data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
  166. data/spec/controllers/admin/contents_controller_spec.rb +17 -26
  167. data/spec/controllers/admin/dashboard_controller_spec.rb +121 -0
  168. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  169. data/spec/controllers/admin/essence_files_controller_spec.rb +67 -0
  170. data/spec/controllers/admin/essence_pictures_controller_spec.rb +161 -0
  171. data/spec/controllers/admin/languages_controller_spec.rb +1 -1
  172. data/spec/controllers/admin/layoutpages_controller_spec.rb +28 -0
  173. data/spec/controllers/admin/pages_controller_spec.rb +164 -118
  174. data/spec/controllers/admin/pictures_controller_spec.rb +89 -0
  175. data/spec/controllers/admin/trash_controller_spec.rb +21 -31
  176. data/spec/controllers/admin/users_controller_spec.rb +114 -85
  177. data/spec/controllers/attachments_controller_spec.rb +6 -2
  178. data/spec/controllers/base_controller_spec.rb +22 -0
  179. data/spec/controllers/elements_controller_spec.rb +1 -1
  180. data/spec/controllers/messages_controller_spec.rb +200 -0
  181. data/spec/controllers/pictures_controller_spec.rb +1 -1
  182. data/spec/controllers/user_sessions_controller_spec.rb +7 -6
  183. data/spec/controllers/users_controller_spec.rb +2 -2
  184. data/spec/dummy/config/alchemy/cells.yml +2 -0
  185. data/spec/dummy/config/application.rb +19 -8
  186. data/spec/dummy/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
  187. data/spec/dummy/db/schema.rb +1 -1
  188. data/spec/fast_specs.rb +15 -0
  189. data/spec/helpers/admin/base_helper_spec.rb +53 -34
  190. data/spec/helpers/admin/contents_helper_spec.rb +15 -7
  191. data/spec/helpers/admin/elements_helper_spec.rb +79 -34
  192. data/spec/helpers/admin/essences_helper_spec.rb +45 -31
  193. data/spec/helpers/admin/navigation_helper_spec.rb +204 -0
  194. data/spec/helpers/admin/pages_helper_spec.rb +25 -15
  195. data/spec/helpers/admin/tags_helper_spec.rb +62 -2
  196. data/spec/helpers/elements_helper_spec.rb +202 -138
  197. data/spec/helpers/pages_helper_spec.rb +48 -0
  198. data/spec/helpers/url_helper_spec.rb +7 -0
  199. data/spec/libraries/config_spec.rb +110 -3
  200. data/spec/libraries/essence_spec.rb +29 -9
  201. data/spec/libraries/page_layout_spec.rb +134 -0
  202. data/spec/libraries/resource_spec.rb +3 -16
  203. data/spec/libraries/resources_helper_spec.rb +4 -8
  204. data/spec/libraries/shell_spec.rb +1 -0
  205. data/spec/libraries/tinymce_spec.rb +61 -0
  206. data/spec/mailers/messages_spec.rb +23 -0
  207. data/spec/models/attachment_spec.rb +45 -0
  208. data/spec/models/cell_spec.rb +62 -9
  209. data/spec/models/content_spec.rb +110 -28
  210. data/spec/models/element_spec.rb +275 -253
  211. data/spec/models/essence_date_spec.rb +25 -0
  212. data/spec/models/essence_file_spec.rb +23 -0
  213. data/spec/models/essence_html_spec.rb +13 -0
  214. data/spec/models/essence_picture_spec.rb +16 -0
  215. data/spec/models/essence_text_spec.rb +29 -0
  216. data/spec/models/language_spec.rb +34 -0
  217. data/spec/models/message_spec.rb +43 -0
  218. data/spec/models/page_spec.rb +726 -567
  219. data/spec/models/picture_spec.rb +98 -0
  220. data/spec/models/site_spec.rb +60 -2
  221. data/spec/models/tag_spec.rb +31 -0
  222. data/spec/models/user_spec.rb +4 -4
  223. data/spec/spec_helper.rb +49 -58
  224. data/spec/support/alchemy/controller_helpers.rb +35 -0
  225. data/spec/support/alchemy/{specs_helpers.rb → integration_helpers.rb} +4 -8
  226. data/spec/{factories.rb → support/factories.rb} +11 -1
  227. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +2 -8
  228. metadata +166 -106
  229. data/Guardfile +0 -16
  230. data/app/assets/javascripts/alchemy/alchemy.dirty.js +0 -93
  231. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +0 -122
  232. data/app/models/alchemy/tree_node.rb +0 -4
  233. data/app/views/alchemy/admin/pages/_page_infos.html.erb +0 -3
  234. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +0 -8
  235. data/app/views/alchemy/messages/contact_form_mail.text.erb +0 -12
  236. data/config/initializers/kaminari_config.rb +0 -9
  237. data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
  238. data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
  239. data/lib/alchemy/auth_engine.rb +0 -7
  240. data/lib/alchemy/authentication_helpers.rb +0 -9
  241. data/lib/alchemy/ferret_search.rb +0 -84
  242. data/lib/extensions/array.rb +0 -25
  243. data/lib/extensions/hash.rb +0 -34
  244. data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
  245. data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
  246. data/spec/models/page_layout_spec.rb +0 -60
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.6.3"
3
+ VERSION = "2.7.0"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -1,52 +1,11 @@
1
1
  require 'rails'
2
2
 
3
+ # Instantiate the global Alchemy namespace
4
+ module Alchemy
5
+ end
6
+
3
7
  if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
4
- require 'acts_as_list'
5
- require 'acts-as-taggable-on'
6
- require 'devise'
7
- require 'devise-encryptable'
8
- require 'awesome_nested_set'
9
- require 'dragonfly'
10
- require 'dynamic_form'
11
- require 'jquery-rails'
12
- require 'jquery-ui-rails'
13
- require 'rails3-jquery-autocomplete'
14
- require 'handles_sortable_columns'
15
- require 'kaminari'
16
- require 'userstamp'
17
- require 'yaml'
18
- require 'sass-rails'
19
- require 'compass-rails'
20
- require 'coffee-rails'
21
- require 'sassy-buttons'
22
- require 'declarative_authorization'
23
- require 'extensions/hash'
24
- require 'extensions/array'
25
- require 'extensions/action_view'
26
- require 'alchemy/mount_point'
27
- require 'alchemy/version'
28
- require 'alchemy/auth_engine'
29
8
  require 'alchemy/engine'
30
- require 'alchemy/picture_attributes'
31
- [
32
- 'config',
33
- 'logger',
34
- 'errors',
35
- 'essence',
36
- 'page_layout',
37
- 'modules',
38
- 'tinymce',
39
- 'i18n',
40
- 'scoped_pagination_url_helper',
41
- 'resource',
42
- 'resources_helper',
43
- 'ferret_search',
44
- 'filetypes',
45
- 'name_conversions'
46
- ].each do |class_name|
47
- require File.join(File.dirname(__FILE__), "alchemy", class_name)
48
- end
49
- require File.join(File.dirname(__FILE__), "alchemy", "seeder")
50
9
  else
51
- raise "Alchemy 2.5 needs Rails 3.2 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
10
+ raise "Alchemy #{Alchemy::VERSION} needs Rails 3.2 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
52
11
  end
@@ -94,7 +94,7 @@ namespace :deploy do
94
94
 
95
95
  desc 'Seeds the database'
96
96
  task :seed, :roles => :app, :except => { :no_release => true } do
97
- run "cd #{release_path} #{rake} && RAILS_ENV=#{rails_env} db:seed"
97
+ run "cd #{release_path} && #{rake} RAILS_ENV=#{rails_env} db:seed"
98
98
  end
99
99
 
100
100
  end
@@ -9,11 +9,16 @@ module Alchemy
9
9
  def copy_devise_config
10
10
  copy_file "devise.rb", "#{Rails.root}/config/initializers/devise.rb"
11
11
  msg = <<-MSG
12
- If your are upgrading from Alchemy < 2.5.0, alter the encryptor to authlogic_sha512
13
- and the stretches value from 10 to 20:
12
+ If your are upgrading from Alchemy < 2.5.0:
14
13
 
15
- config.stretches = Rails.env.test? ? 1 : 20
16
- config.encryptor = :authlogic_sha512
14
+ 1. Add `gem 'devise-encryptable'` into your Gemfile
15
+ 2. Run `bundle install`
16
+ 3. Alter the encryptor and the stretches value in your devise config:
17
+
18
+ # config/initializers/devise.rb
19
+ ...
20
+ config.stretches = Rails.env.test? ? 1 : 20
21
+ config.encryptor = :authlogic_sha512
17
22
 
18
23
  MSG
19
24
  puts msg
@@ -27,17 +27,18 @@ module Alchemy
27
27
  acts_as_essence(
28
28
  # Your options:
29
29
  #
30
- # :ingredient_column => Symbol # Specifies the column name you use for storing the content in the database. [Default] :body
31
- # :validate_column => Symbol # Which column should be validated. [Default] ingredient_column
32
- # :preview_text_column => Symbol # Specifies the column for the preview_text method. [Default] ingredient_column
33
- # :preview_text_method => Symbol # A method called on ingredient to get the preview text.
30
+ # ingredient_column: [String or Symbol] - Specifies the column name you use for storing the content in the database. (Default :body)
31
+ # validate_column: [String or Symbol] - Which column should be validated. (Default: ingredient_column)
32
+ # preview_text_column: [String or Symbol] - Specifies the column for the preview_text method. (Default: ingredient_column)
33
+ # preview_text_method: [String or Symbol] - A method called on ingredient to get the preview text. (Default: ingredient_column)
34
34
  )
35
35
  CLASSMETHOD
36
36
  end
37
37
 
38
38
  def copy_templates
39
- template "view.html.erb", "#{@essence_view_path}/_#{@essence_name}_view.html.erb"
40
- template "editor.html.erb", "#{@essence_view_path}/_#{@essence_name}_editor.html.erb"
39
+ essence_name = @essence_name.classify.demodulize
40
+ template "view.html.erb", "#{@essence_view_path}/_#{essence_name}_view.html.erb"
41
+ template "editor.html.erb", "#{@essence_view_path}/_#{essence_name}_editor.html.erb"
41
42
  end
42
43
 
43
44
  def show_todo
@@ -6,7 +6,7 @@
6
6
  Please consult Alchemy::Content.rb docs for further methods on the content object
7
7
  %>
8
8
  <%% cache(content) do %>
9
- <div class="content_editor <%= @essence_name %>" id="<%%= content_dom_id(content) %>">
9
+ <div class="content_editor <%= @essence_name.classify.demodulize %>" id="<%%= content_dom_id(content) %>">
10
10
  <%%= label_and_remove_link(content) %>
11
11
  <%%= text_field_tag(
12
12
  content.form_field_name,
@@ -31,6 +31,7 @@ module Alchemy
31
31
  copy_file "#{File.dirname(__FILE__)}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
32
32
  template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
33
33
  copy_file "#{File.dirname(__FILE__)}/files/application.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
34
+ copy_file "#{File.dirname(__FILE__)}/files/_standard.html.erb", "#{Rails.root}/app/views/alchemy/page_layouts/_standard.html.erb"
34
35
  end
35
36
 
36
37
  private
@@ -0,0 +1,23 @@
1
+ require File.join(__FILE__, '../../base')
2
+
3
+ module Alchemy
4
+ module Generators
5
+ class SiteLayoutsGenerator < Base
6
+ desc "This generator generates your site layouts view partials."
7
+ source_root File.expand_path('templates', File.dirname(__FILE__))
8
+
9
+ def create_directory
10
+ @site_layouts_dir = "#{Rails.root}/app/views/alchemy/site_layouts"
11
+ empty_directory @site_layouts_dir
12
+ end
13
+
14
+ def create_partials
15
+ @sites = Alchemy::Site.all
16
+ @sites.each do |site|
17
+ @site_name = site.name.parameterize.underscore
18
+ conditional_template "layout.html.#{template_engine}", "#{@site_layouts_dir}/_#{@site_name}.html.#{template_engine}"
19
+ end if @sites
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,8 +1,8 @@
1
1
  # This rails template installs Alchemy and all depending gems.
2
- require 'alchemy/version'
2
+ require File.expand_path('../../../alchemy/version', __FILE__)
3
3
 
4
4
  gem 'alchemy_cms', "~> #{Alchemy::VERSION}"
5
5
 
6
6
  if yes?("\nDo you want to use Capistrano for deployment? (y/N)")
7
- gem 'capistrano', :group => :development
7
+ gem 'capistrano', group: 'development'
8
8
  end
@@ -1,3 +1,5 @@
1
+ require 'alchemy/seeder'
2
+
1
3
  namespace :alchemy do
2
4
  namespace :db do
3
5
 
@@ -10,7 +12,7 @@ namespace :alchemy do
10
12
  task :dump => :environment do
11
13
  db_conf = Rails.configuration.database_configuration.fetch(Rails.env)
12
14
  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)}" : ""
15
+ dump_store = ENV['DUMP_FILENAME'] ? " > #{ENV['DUMP_FILENAME']}" : ""
14
16
  cmd = "mysqldump --user='#{db_conf['username']}'#{db_conf['password'].present? ? " --password='#{db_conf['password']}'" : nil} #{db_conf['database']}#{dump_store}"
15
17
  system cmd
16
18
  end
@@ -0,0 +1,82 @@
1
+ namespace :alchemy do
2
+ namespace :tidy do
3
+
4
+ desc "Tidy up Alchemy database."
5
+ task :up do
6
+ Rake::Task['alchemy:tidy:cells'].invoke
7
+ Rake::Task['alchemy:tidy:element_positions'].invoke
8
+ end
9
+
10
+ desc "Creates missing cells for pages."
11
+ task :cells => :environment do
12
+ cells = Alchemy::Cell.definitions
13
+ page_layouts = Alchemy::PageLayout.all
14
+ if cells && page_layouts
15
+ Alchemy::Tidy.create_missing_cells(page_layouts, cells)
16
+ else
17
+ puts "No page layouts or cell definitions found."
18
+ end
19
+ end
20
+
21
+ desc "Fixes element positions."
22
+ task :element_positions => [:environment] do
23
+ Alchemy::Tidy.update_element_positions
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ module Alchemy
30
+ class Tidy
31
+ extend Shell
32
+
33
+ def self.create_missing_cells(page_layouts, cells)
34
+ desc "Create missing cells"
35
+ page_layouts.each do |layout|
36
+ next if layout['cells'].blank?
37
+ cells_for_layout = cells.select { |cell| layout['cells'].include? cell['name'] }
38
+ Alchemy::Page.where(page_layout: layout['name']).each do |page|
39
+ cells_for_layout.each do |cell_for_layout|
40
+ cell = Alchemy::Cell.find_or_initialize_by_name_and_page_id(name: cell_for_layout['name'], page_id: page.id)
41
+ cell.elements << page.elements.select { |element| cell_for_layout['elements'].include?(element.name) }
42
+ if cell.new_record?
43
+ cell.save
44
+ log "Creating cell #{cell.name} for page #{page.name}"
45
+ else
46
+ log "Cell #{cell.name} for page #{page.name} already present", :skip
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.update_element_positions
54
+ desc "Update element positions"
55
+ Alchemy::Page.all.each do |page|
56
+ page.elements.group_by(&:cell_id).each do |cell_id, elements|
57
+ elements.each_with_index do |element, idx|
58
+ position = idx + 1
59
+ if element.position != position
60
+ log "Updating position for element ##{element.id} to #{position}"
61
+ element.update_column(:position, position)
62
+ else
63
+ log "Position for element ##{element.id} is already correct", :skip
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ # TODO: implement remove_orphan_cells
71
+ def self.remove_orphan_cells(page_layouts, cells)
72
+ puts "== Remove cell orphans"
73
+ Alchemy::Cell.all.each do |cell|
74
+ if cells.detect { |cell| cell['name'] == cell.name }.nil?
75
+ # move elements to page or into another cell of page
76
+ # remove cell from database
77
+ end
78
+ end
79
+ end
80
+
81
+ end
82
+ end
@@ -1,4 +1,5 @@
1
- require File.join(File.dirname(__FILE__), '../../alchemy/upgrader.rb')
1
+ require 'alchemy/upgrader'
2
+ require 'alchemy/version'
2
3
 
3
4
  namespace :alchemy do
4
5
 
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ module Alchemy
4
+ describe Admin::AttachmentsController do
5
+
6
+ let(:attachment) { mock_model('Attachment', file_name: 'testfile', file_mime_type: 'image/png', file: mock('File', data: nil)) }
7
+
8
+ before do
9
+ sign_in(admin_user)
10
+ end
11
+
12
+ describe "#index" do
13
+
14
+ it "should always paginate the records" do
15
+ Attachment.should_receive(:find_paginated)
16
+ get :index
17
+ end
18
+
19
+ context "when params[:tagged_with] is set" do
20
+ it "should filter the records by tags" do
21
+ Attachment.should_receive(:tagged_with).and_return(Attachment.scoped)
22
+ get :index, tagged_with: "pdf"
23
+ end
24
+ end
25
+
26
+ context "when params[:content_id]" do
27
+ render_views
28
+
29
+ context "is set" do
30
+ it "should render the archive_overlay partial" do
31
+ Content.stub!(:find).with('1', {:select => 'id'}).and_return(mock_model(Content))
32
+ get :index, {content_id: 1, format: :html}
33
+ expect(response).to render_template(partial: '_archive_overlay')
34
+ end
35
+ end
36
+
37
+ context "is not set" do
38
+ it "should render the default index view" do
39
+ get :index
40
+ expect(response).to render_template(:index)
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ describe "#new" do
49
+
50
+ context "in overlay" do
51
+
52
+ before do
53
+ controller.stub!(:in_overlay?).and_return(true)
54
+ Content.stub(:find).and_return(mock_model('Content'))
55
+ end
56
+
57
+ it "should set @while_assigning to true" do
58
+ get :new
59
+ assigns(:while_assigning).should eq(true)
60
+ end
61
+
62
+ it "should set @swap to params[:swap]" do
63
+ get :new, swap: 'true'
64
+ assigns(:swap).should eq('true')
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ describe "#show" do
71
+ before do
72
+ Attachment.stub!(:find).with("#{attachment.id}").and_return(attachment)
73
+ end
74
+
75
+ it "should assign @attachment with Attachment found by id" do
76
+ get :edit, id: attachment.id
77
+ expect(assigns(:attachment)).to eq(attachment)
78
+ end
79
+
80
+ context "if xhr request" do
81
+ it "should render no layout" do
82
+ xhr :get, :edit, id: attachment.id
83
+ expect(@layouts).to be_empty
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "#edit" do
89
+ before do
90
+ Attachment.stub!(:find).with("#{attachment.id}").and_return(attachment)
91
+ end
92
+
93
+ it "should assign @attachment with Attachment found by id" do
94
+ get :edit, id: attachment.id
95
+ expect(assigns(:attachment)).to eq(attachment)
96
+ end
97
+
98
+ context "if xhr request" do
99
+ it "should render no layout" do
100
+ xhr :get, :edit, id: attachment.id
101
+ expect(@layouts).to be_empty
102
+ end
103
+ end
104
+ end
105
+
106
+ describe "#download" do
107
+ before do
108
+ Attachment.stub!(:find).with("#{attachment.id}").and_return(attachment)
109
+ controller.stub!(:render).and_return(nil)
110
+ end
111
+
112
+ it "should assign @attachment with Attachment found by id" do
113
+ get :download, id: attachment.id
114
+ expect(assigns(:attachment)).to eq(attachment)
115
+ end
116
+
117
+ it "should send the data to the browser" do
118
+ controller.should_receive(:send_data)
119
+ get :download, id: attachment.id
120
+ end
121
+ end
122
+
123
+ end
124
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Alchemy::Admin::BaseController do
4
+
5
+ describe '#options_from_params' do
6
+ subject { controller.send(:options_from_params) }
7
+
8
+ context "params[:options] is a JSON string" do
9
+ before { controller.stub(:params).and_return(options: '{"hallo":"World"}') }
10
+
11
+ it "parses the string into an object" do
12
+ expect(subject).to be_an_instance_of(Hash)
13
+ expect(subject).to eq({hallo: 'World'})
14
+ end
15
+ end
16
+
17
+ context "params[:options] is already an object" do
18
+ before { controller.stub(:params).and_return(options: {hallo: "World"}) }
19
+
20
+ it "parses the string into an object" do
21
+ expect(subject).to be_an_instance_of(Hash)
22
+ end
23
+ end
24
+
25
+ context "params[:options] is not present" do
26
+ before { controller.stub(:params).and_return({}) }
27
+
28
+ it "returns ampty object" do
29
+ expect(subject).to be_an_instance_of(Hash)
30
+ expect(subject).to eq({})
31
+ end
32
+ end
33
+ end
34
+
35
+ end