alchemy_cms 2.4.1 → 2.5.0.b2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/.travis.yml +1 -1
  2. data/README.md +18 -17
  3. data/alchemy_cms.gemspec +5 -10
  4. data/app/assets/images/alchemy/icons.png +0 -0
  5. data/app/assets/stylesheets/alchemy/archive.scss +27 -0
  6. data/app/assets/stylesheets/alchemy/base.scss +0 -51
  7. data/app/assets/stylesheets/alchemy/elements.scss +37 -2
  8. data/app/assets/stylesheets/alchemy/icons.scss +4 -0
  9. data/app/assets/stylesheets/alchemy/modules.scss +4 -0
  10. data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
  11. data/app/assets/stylesheets/alchemy/tables.scss +1 -1
  12. data/app/assets/stylesheets/alchemy/variables.scss +1 -0
  13. data/app/controllers/alchemy/admin/pages_controller.rb +1 -0
  14. data/app/controllers/alchemy/admin/pictures_controller.rb +22 -8
  15. data/app/controllers/alchemy/admin/resources_controller.rb +1 -1
  16. data/app/controllers/alchemy/admin/sites_controller.rb +6 -0
  17. data/app/controllers/alchemy/base_controller.rb +8 -0
  18. data/app/controllers/alchemy/elements_controller.rb +33 -3
  19. data/app/controllers/alchemy/messages_controller.rb +47 -40
  20. data/app/controllers/alchemy/pages_controller.rb +8 -31
  21. data/app/controllers/alchemy/pictures_controller.rb +64 -30
  22. data/app/helpers/alchemy/admin/base_helper.rb +7 -0
  23. data/app/helpers/alchemy/admin/pages_helper.rb +12 -0
  24. data/app/helpers/alchemy/elements_helper.rb +2 -0
  25. data/app/helpers/alchemy/pages_helper.rb +30 -10
  26. data/app/helpers/alchemy/url_helper.rb +1 -0
  27. data/app/models/alchemy/content.rb +1 -2
  28. data/app/models/alchemy/element.rb +47 -2
  29. data/app/models/alchemy/language.rb +27 -14
  30. data/app/models/alchemy/page.rb +1 -1
  31. data/app/models/alchemy/picture.rb +46 -41
  32. data/app/models/alchemy/site.rb +44 -0
  33. data/app/views/alchemy/admin/elements/_element_head.html.erb +1 -0
  34. data/app/views/alchemy/admin/languages/index.html.erb +23 -0
  35. data/app/views/alchemy/admin/pages/edit.html.erb +27 -1
  36. data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
  37. data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -0
  38. data/app/views/alchemy/admin/pictures/_picture.html.erb +24 -2
  39. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +5 -4
  40. data/app/views/alchemy/admin/pictures/create.js.erb +1 -9
  41. data/app/views/alchemy/admin/pictures/info.html.erb +42 -0
  42. data/app/views/alchemy/admin/resources/_form.html.erb +0 -2
  43. data/app/views/alchemy/admin/resources/_resource.html.erb +2 -1
  44. data/app/views/alchemy/admin/resources/index.html.erb +2 -1
  45. data/app/views/alchemy/elements/show.html.erb +1 -6
  46. data/app/views/alchemy/elements/show.js.erb +4 -10
  47. data/app/views/alchemy/essences/_essence_link_view.html.erb +1 -0
  48. data/app/views/alchemy/search/_form.html.erb +9 -6
  49. data/app/views/alchemy/search/_result.html.erb +1 -1
  50. data/bin/alchemy +13 -120
  51. data/config/alchemy/config.yml +7 -11
  52. data/config/alchemy/modules.yml +24 -12
  53. data/config/authorization_rules.rb +6 -2
  54. data/config/initializers/dragonfly.rb +20 -0
  55. data/config/locales/alchemy.de.yml +57 -28
  56. data/config/locales/alchemy.en.yml +18 -4
  57. data/config/routes.rb +4 -2
  58. data/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +21 -0
  59. data/db/migrate/20121205155004_create_alchemy_sites.rb +14 -0
  60. data/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +6 -0
  61. data/lib/alchemy/capistrano.rb +7 -2
  62. data/lib/alchemy/ferret_search.rb +84 -0
  63. data/lib/alchemy/picture_attributes.rb +29 -0
  64. data/lib/alchemy/seeder.rb +10 -16
  65. data/lib/alchemy/upgrader.rb +59 -8
  66. data/lib/alchemy/version.rb +1 -1
  67. data/lib/alchemy_cms.rb +7 -4
  68. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +3 -0
  69. data/lib/rails/generators/alchemy/elements/elements_generator.rb +5 -1
  70. data/lib/rails/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
  71. data/lib/rails/generators/alchemy/scaffold/files/{pages.html.erb → application.html.erb} +0 -0
  72. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +11 -20
  73. data/lib/rails/templates/alchemy.rb +1 -7
  74. data/lib/tasks/{database.rake → alchemy/db.rake} +1 -1
  75. data/lib/tasks/{install.rake → alchemy/install.rake} +9 -14
  76. data/lib/tasks/{upgrade.rake → alchemy/upgrade.rake} +1 -1
  77. data/spec/controllers/elements_controller_spec.rb +24 -9
  78. data/spec/controllers/pictures_controller_spec.rb +11 -8
  79. data/{app → spec/dummy/app}/views/alchemy/elements/_article_editor.html.erb +0 -0
  80. data/{app → spec/dummy/app}/views/alchemy/elements/_article_view.html.erb +0 -0
  81. data/{app → spec/dummy/app}/views/alchemy/elements/_headline_view.html.erb +0 -0
  82. data/{app → spec/dummy/app}/views/alchemy/elements/_news_view.html.erb +0 -0
  83. data/{app → spec/dummy/app}/views/alchemy/elements/_searchresult_view.html.erb +0 -0
  84. data/{app → spec/dummy/app}/views/alchemy/page_layouts/_standard.html.erb +0 -0
  85. data/spec/dummy/config/alchemy/elements.yml +86 -0
  86. data/spec/dummy/config/alchemy/page_layouts.yml +26 -0
  87. data/spec/dummy/config/application.rb +1 -1
  88. data/spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +21 -0
  89. data/spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb +14 -0
  90. data/spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +6 -0
  91. data/spec/dummy/db/schema.rb +21 -6
  92. data/spec/factories.rb +6 -2
  93. data/spec/integration/translation_integration_spec.rb +4 -18
  94. data/spec/models/element_spec.rb +4 -4
  95. data/spec/models/picture_spec.rb +37 -20
  96. data/spec/models/site_spec.rb +69 -0
  97. data/spec/routing_spec.rb +115 -115
  98. data/spec/spec_helper.rb +1 -3
  99. data/spec/support/alchemy/specs_helpers.rb +4 -4
  100. data/vendor/assets/javascripts/jquery_plugins/jquery.html5uploader.js +1 -1
  101. metadata +72 -96
  102. data/app/assets/stylesheets/alchemy/standard_set.css +0 -440
  103. data/app/views/alchemy/elements/_bild_editor.html.erb +0 -1
  104. data/app/views/alchemy/elements/_bild_text_editor.html.erb +0 -7
  105. data/app/views/alchemy/elements/_bild_text_view.html.erb +0 -9
  106. data/app/views/alchemy/elements/_bild_view.html.erb +0 -9
  107. data/app/views/alchemy/elements/_claim_editor.html.erb +0 -1
  108. data/app/views/alchemy/elements/_claim_view.html.erb +0 -1
  109. data/app/views/alchemy/elements/_contactform_editor.html.erb +0 -4
  110. data/app/views/alchemy/elements/_contactform_view.html.erb +0 -78
  111. data/app/views/alchemy/elements/_download_editor.html.erb +0 -4
  112. data/app/views/alchemy/elements/_download_view.html.erb +0 -7
  113. data/app/views/alchemy/elements/_footnote_editor.html.erb +0 -1
  114. data/app/views/alchemy/elements/_footnote_view.html.erb +0 -5
  115. data/app/views/alchemy/elements/_header_editor.html.erb +0 -1
  116. data/app/views/alchemy/elements/_header_view.html.erb +0 -1
  117. data/app/views/alchemy/elements/_headline_editor.html.erb +0 -1
  118. data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +0 -3
  119. data/app/views/alchemy/elements/_image_mosaic_view.html.erb +0 -14
  120. data/app/views/alchemy/elements/_intro_editor.html.erb +0 -1
  121. data/app/views/alchemy/elements/_intro_image_text_editor.html.erb +0 -3
  122. data/app/views/alchemy/elements/_intro_image_text_view.html.erb +0 -16
  123. data/app/views/alchemy/elements/_intro_view.html.erb +0 -3
  124. data/app/views/alchemy/elements/_news_editor.html.erb +0 -3
  125. data/app/views/alchemy/elements/_searchresult_editor.html.erb +0 -4
  126. data/app/views/alchemy/elements/_sitemap_editor.html.erb +0 -3
  127. data/app/views/alchemy/elements/_sitemap_view.html.erb +0 -38
  128. data/app/views/alchemy/elements/_sitename_editor.html.erb +0 -1
  129. data/app/views/alchemy/elements/_sitename_view.html.erb +0 -1
  130. data/app/views/alchemy/elements/_subheadline_editor.html.erb +0 -1
  131. data/app/views/alchemy/elements/_subheadline_view.html.erb +0 -5
  132. data/app/views/alchemy/elements/_text_editor.html.erb +0 -1
  133. data/app/views/alchemy/elements/_text_view.html.erb +0 -3
  134. data/app/views/alchemy/page_layouts/_contact.html.erb +0 -14
  135. data/app/views/alchemy/page_layouts/_external.html.erb +0 -0
  136. data/app/views/alchemy/page_layouts/_intro.html.erb +0 -14
  137. data/app/views/alchemy/page_layouts/_layout_footer.html.erb +0 -14
  138. data/app/views/alchemy/page_layouts/_layout_header.html.erb +0 -14
  139. data/app/views/alchemy/page_layouts/_news.html.erb +0 -14
  140. data/app/views/alchemy/page_layouts/_newsletter_layout.html.erb +0 -1
  141. data/app/views/alchemy/page_layouts/_search.html.erb +0 -14
  142. data/app/views/alchemy/pictures/show.gif.flexi +0 -19
  143. data/app/views/alchemy/pictures/show.jpg.flexi +0 -19
  144. data/app/views/alchemy/pictures/show.png.flexi +0 -19
  145. data/app/views/alchemy/pictures/thumbnail.png.flexi +0 -13
  146. data/app/views/alchemy/pictures/zoom.jpg.flexi +0 -3
  147. data/app/views/alchemy/pictures/zoom.png.flexi +0 -3
  148. data/app/views/layouts/alchemy/pages.html.erb +0 -51
  149. data/config/alchemy/elements.yml +0 -274
  150. data/config/alchemy/page_layouts.yml +0 -75
  151. data/config/asset_packages.yml +0 -30
  152. data/config/initializers/localeapp.rb +0 -9
  153. data/lib/rails/generators/alchemy/plugin/files/translation.pot +0 -3
  154. data/lib/rails/generators/alchemy/plugin/files/translation_de.po +0 -3
  155. data/lib/rails/generators/alchemy/plugin/files/translation_en.po +0 -3
  156. data/lib/rails/generators/alchemy/plugin/plugin_generator.rb +0 -37
  157. data/lib/rails/generators/alchemy/plugin/templates/authorization_rules.rb +0 -34
  158. data/lib/rails/generators/alchemy/plugin/templates/config.yml +0 -30
  159. data/lib/rails/generators/alchemy/plugin/templates/init.rb +0 -1
  160. data/lib/rails/generators/alchemy/plugin/templates/plugin.rb +0 -0
  161. data/lib/rails/generators/alchemy/plugin/templates/routes.rb +0 -10
  162. data/lib/tasks/fleximage.rake +0 -154
  163. data/spec/dummy/app/views/layouts/.gitkeep +0 -0
@@ -26,7 +26,7 @@ Alchemy::Engine.routes.draw do
26
26
  match '/attachment/:id/show' => 'attachments#show',
27
27
  :as => :show_attachment
28
28
 
29
- match "/pictures/:id/show(/:size)(/:crop)(/:crop_from/:crop_size)/:name.:format" => 'pictures#show',
29
+ match "/pictures/:id/show(/:size)(/:crop)(/:crop_from/:crop_size)(/:quality)/:name.:format" => 'pictures#show',
30
30
  :as => :show_picture
31
31
  match '/pictures/:id/zoom/:name.:format' => 'pictures#zoom',
32
32
  :as => :zoom_picture
@@ -90,7 +90,7 @@ Alchemy::Engine.routes.draw do
90
90
  get :edit_multiple
91
91
  end
92
92
  member do
93
- get :show_in_window
93
+ get :show_in_window, :info
94
94
  delete :remove
95
95
  end
96
96
  end
@@ -140,6 +140,8 @@ Alchemy::Engine.routes.draw do
140
140
  end
141
141
  end
142
142
 
143
+ resources :sites
144
+
143
145
  end
144
146
 
145
147
  match '/:lang' => 'pages#show',
@@ -0,0 +1,21 @@
1
+ class SwitchFromFleximageToDragonfly < ActiveRecord::Migration
2
+ def up
3
+ change_table :alchemy_pictures do |t|
4
+ t.string :image_file_uid
5
+ t.integer :image_file_size
6
+ t.rename :image_width, :image_file_width
7
+ t.rename :image_height, :image_file_height
8
+ t.rename :image_filename, :image_file_name
9
+ end
10
+ end
11
+
12
+ def down
13
+ change_table :alchemy_pictures do |t|
14
+ t.remove :image_file_uid
15
+ t.remove :image_file_size
16
+ t.rename :image_file_width, :image_width
17
+ t.rename :image_file_height, :image_height
18
+ t.rename :image_file_name, :image_filename
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class CreateAlchemySites < ActiveRecord::Migration
2
+ def change
3
+ create_table "alchemy_sites" do |t|
4
+ t.string :host
5
+ t.string :name
6
+ t.timestamps
7
+ end
8
+ add_index :alchemy_sites, :host, uniq: true
9
+
10
+ # add Language#site_id
11
+ add_column :alchemy_languages, :site_id, :integer
12
+ add_index :alchemy_languages, :site_id
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class AddPublicToAlchemySites < ActiveRecord::Migration
2
+ def change
3
+ add_column :alchemy_sites, :public, :boolean, :default => false
4
+ add_index :alchemy_sites, [:host, :public], :name => 'alchemy_sites_public_hosts_idx'
5
+ end
6
+ end
@@ -77,10 +77,15 @@ EOF
77
77
  namespace :db do
78
78
 
79
79
  desc "Seeds the database with essential data."
80
- task :seed, :roles => :app do
80
+ task :seed, :roles => :db do
81
81
  run "cd #{current_path} && RAILS_ENV=#{fetch(:rails_env, 'production')} #{rake} alchemy:db:seed"
82
82
  end
83
83
 
84
+ desc "Dumps the database into 'db/dumps'"
85
+ task :dump, :roles => :db do
86
+ run "cd #{current_path} && RAILS_ENV=#{fetch(:rails_env, 'production')} #{rake} alchemy:db:dump"
87
+ end
88
+
84
89
  end
85
90
 
86
91
  namespace :import do
@@ -125,7 +130,7 @@ EOF
125
130
 
126
131
  def timestamp
127
132
  timestamp ||= Time.now.strftime('%Y-%m-%d-%H-%M')
128
- end
133
+ end
129
134
 
130
135
  def unzip_files(type, filename)
131
136
  FileUtils.rm_rf "./uploads/#{type}"
@@ -0,0 +1,84 @@
1
+ module Alchemy
2
+ # Provides full text search methods in your controller
3
+ #
4
+ # === Usage
5
+ #
6
+ # include Alchemy::FerretSearch
7
+ #
8
+ module FerretSearch
9
+
10
+ # Adds a +before_filter+ to your controller
11
+ #
12
+ def self.included(controller)
13
+ controller.send(:before_filter, :perform_search, :only => :show)
14
+ controller.send(:helper_method, :find_search_result_page)
15
+ end
16
+
17
+ # Performs a full text search with +Ferret+.
18
+ #
19
+ # Gets invoked everytime 'query' is given in params.
20
+ #
21
+ # This method only sets the +@search_results+ instance variable.
22
+ #
23
+ # You have to redirect to the search result page within a search form.
24
+ #
25
+ # === Alchemy provides a handy helper for rendering the search form:
26
+ #
27
+ # render_search_form
28
+ #
29
+ # === Note
30
+ #
31
+ # If in preview mode a fake search value "lorem" will be set.
32
+ #
33
+ # @see Alchemy::PagesHelper#render_search_form
34
+ #
35
+ def perform_search
36
+ if @preview_mode && params[:query].blank?
37
+ params[:query] = 'lorem'
38
+ end
39
+ return if params[:query].blank?
40
+ @search_results = get_search_results
41
+ end
42
+
43
+ # Finds what is provided in "query" param with Ferret on EssenceText and EssenceRichtext
44
+ #
45
+ # @return [Array]
46
+ #
47
+ def get_search_results
48
+ search_results = []
49
+ %w(Alchemy::EssenceText Alchemy::EssenceRichtext).each do |e|
50
+ search_results += e.constantize.includes(:contents => {:element => :page}).find_with_ferret(
51
+ "*#{params[:query]}*",
52
+ {:limit => :all},
53
+ {:conditions => [
54
+ 'alchemy_pages.public = ? AND alchemy_pages.layoutpage = ? AND alchemy_pages.restricted = ? AND alchemy_pages.language_id = ?',
55
+ true, false, false, session[:language_id]
56
+ ]}
57
+ )
58
+ end
59
+ if search_results.any?
60
+ search_results.sort { |y, x| x.ferret_score <=> y.ferret_score }
61
+ end
62
+ end
63
+
64
+ # A view helper that loads the search result page.
65
+ #
66
+ # === Raises a ActiveRecord::RecordNotFound error, if the page could not be found or is not published.
67
+ #
68
+ # @return [Alchemy::Page]
69
+ #
70
+ def find_search_result_page
71
+ if searchresult_page_layout = PageLayout.get_all_by_attributes(:searchresults => true).first
72
+ search_result_page = Page.published.where(
73
+ :page_layout => searchresult_page_layout["name"],
74
+ :language_id => session[:language_id]
75
+ ).limit(1).first
76
+ end
77
+ if search_result_page.nil?
78
+ logger.warn "\n++++++\nNo published search result page found. Please create one or publish your search result page.\n++++++\n"
79
+ end
80
+ search_result_page
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,29 @@
1
+ module Alchemy
2
+ # Provides methods to secure your picture attributes against DOS attacks.
3
+ #
4
+ class PictureAttributes
5
+
6
+ SECURE_ATTRIBUTES = %w(id size crop crop_from crop_size quality).freeze
7
+
8
+ class << self
9
+
10
+ # Secures given attributes
11
+ #
12
+ # @param attributes [Hash]
13
+ # @return [String]
14
+ #
15
+ def secure(attributes)
16
+ Digest::SHA1.hexdigest(joined_attributes(attributes))[0..15]
17
+ end
18
+
19
+ private
20
+
21
+ # Takes attributes and joins them with the +security_token+ of your rails app.
22
+ #
23
+ def joined_attributes(attributes)
24
+ attributes.stringify_keys.values_at(*SECURE_ATTRIBUTES, Rails.configuration.secret_token).join('-')
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -8,7 +8,7 @@ module Alchemy
8
8
  # This seed builds the necessary page structure for alchemy in your database.
9
9
  # Run the alchemy:db:seed rake task to seed your database.
10
10
  def seed!
11
- create_default_language
11
+ create_default_site
12
12
  create_root_page
13
13
  end
14
14
 
@@ -74,23 +74,17 @@ module Alchemy
74
74
 
75
75
  protected
76
76
 
77
- def create_default_language
78
- desc "Creating default language"
79
- default_language = Alchemy::Config.get(:default_language)
80
- lang = Alchemy::Language.find_or_initialize_by_language_code(
81
- :name => default_language['name'],
82
- :language_code => default_language['code'],
83
- :frontpage_name => default_language['frontpage_name'],
84
- :page_layout => default_language['page_layout'],
85
- :public => true,
86
- :default => true
77
+ def create_default_site
78
+ desc "Creating default site"
79
+ site = Alchemy::Site.find_or_initialize_by_host(
80
+ :name => 'Default Site',
81
+ :host => '*'
87
82
  )
88
- if lang.new_record?
89
- if lang.save!
90
- log "Created language #{lang.name}."
91
- end
83
+ if site.new_record?
84
+ site.save!
85
+ log "Created default site with default language."
92
86
  else
93
- log "Language #{lang.name} was already present.", :skip
87
+ log "Default site was already present.", :skip
94
88
  end
95
89
  end
96
90
 
@@ -19,12 +19,29 @@ module Alchemy
19
19
  convert_essence_texts_displayed_as_checkbox_into_essence_booleans
20
20
  copy_new_config_file
21
21
  removed_richmedia_essences_notice
22
+ convert_picture_storage
23
+ upgrade_to_sites
24
+ removed_standard_set_notice
22
25
 
23
26
  display_todos
24
27
  end
25
28
 
26
29
  private
27
30
 
31
+ def upgrade_to_sites
32
+ desc "Creating default site and migrating existing languages to it"
33
+ if Site.count == 0
34
+ Alchemy::Site.transaction do
35
+ site = Alchemy::Site.new(host: '*', name: 'Default Site')
36
+ site.languages << Alchemy::Language.all
37
+ site.save!
38
+ log "Done."
39
+ end
40
+ else
41
+ log "Site(s) already present.", :skip
42
+ end
43
+ end
44
+
28
45
  # Creates Language model if it does not exist (Alchemy CMS prior v1.5)
29
46
  # Also creates missing associations between pages and languages
30
47
  def upgrade_to_language
@@ -182,15 +199,17 @@ module Alchemy
182
199
  end
183
200
 
184
201
  def copy_new_config_file
185
- desc "Copy config file"
186
- old_config_file = Rails.root.join('config/alchemy/config.yml')
187
- if File.exist?(old_config_file)
188
- FileUtils.mv old_config_file, Rails.root.join('config/alchemy/config.yml.old')
189
- log "Backed up old config file"
202
+ desc "Copy configuration file."
203
+ config_file = Rails.root.join('config/alchemy/config.yml')
204
+ default_config = File.join(File.dirname(__FILE__), '../../config/alchemy/config.yml')
205
+ if FileUtils.identical? default_config, config_file
206
+ log "Configuration file already present.", :skip
207
+ else
208
+ log "Custom configuration file found."
209
+ FileUtils.cp default_config, Rails.root.join('config/alchemy/config.yml.defaults')
210
+ log "Copied new default configuration file."
211
+ todo "Check the default configuration file (./config/alchemy/config.yml.defaults) for new configuration options and insert them into your config file."
190
212
  end
191
- FileUtils.cp File.join(File.dirname(__FILE__), '../../config/alchemy/config.yml'), old_config_file
192
- log "Copied new config file"
193
- todo "Check the config/alchemy/config.yml.old file for custom configuration options and insert them into the new config file."
194
213
  end
195
214
 
196
215
  def removed_richmedia_essences_notice
@@ -205,6 +224,38 @@ We left the tables in your database, you can simply drop them if you don't use t
205
224
  drop_table :alchemy_essence_audios
206
225
  drop_table :alchemy_essence_flashes
207
226
  drop_table :alchemy_essence_videos
227
+ WARN
228
+ todo warn
229
+ end
230
+
231
+ def convert_picture_storage
232
+ desc "Convert the picture storage"
233
+ converted_images = []
234
+ images = Dir.glob Rails.root.join 'uploads/pictures/**/*.*'
235
+ if images.blank?
236
+ log "No pictures found", :skip
237
+ else
238
+ images.each do |image|
239
+ image_uid = image.gsub(/#{Rails.root.to_s}\/uploads\/pictures\//, '')
240
+ image_id = image_uid.split('/').last.split('.').first
241
+ picture = Alchemy::Picture.find_by_id(image_id)
242
+ if picture && picture.image_file_uid.blank?
243
+ picture.image_file_uid = image_uid
244
+ picture.image_file_size = File.new(image).size
245
+ if picture.save!
246
+ log "Converted #{image_uid}"
247
+ end
248
+ else
249
+ log "Picture with id #{image_id} not found or already converted.", :skip
250
+ end
251
+ end
252
+ end
253
+ end
254
+
255
+ def removed_standard_set_notice
256
+ warn = <<-WARN
257
+ We removed the standard set from Alchemy core!
258
+ In order to get the standard set back, install the `alchemy-demo_kit` gem.
208
259
  WARN
209
260
  todo warn
210
261
  end
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.4.1"
3
+ VERSION = "2.5.0.b2"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -1,11 +1,13 @@
1
- if defined?(Rails) && Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
1
+ require 'rails'
2
+
3
+ if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
2
4
  require 'acts_as_list'
3
5
  require 'acts-as-taggable-on'
4
6
  require 'attachment_magic'
5
7
  require 'authlogic'
6
8
  require 'awesome_nested_set'
9
+ require 'dragonfly'
7
10
  require 'dynamic_form'
8
- require 'fleximage'
9
11
  require 'jquery-rails'
10
12
  require 'rails3-jquery-autocomplete'
11
13
  require 'kaminari'
@@ -23,12 +25,13 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
23
25
  require 'alchemy/version'
24
26
  require 'alchemy/auth_engine'
25
27
  require 'alchemy/engine'
26
- %w(config essence page_layout modules tinymce i18n scoped_pagination_url_helper resource resources_helper).each do |class_name|
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|
27
30
  require File.join(File.dirname(__FILE__), "alchemy", class_name)
28
31
  end
29
32
  require File.join(File.dirname(__FILE__), "alchemy", "seeder")
30
33
  else
31
- raise "Alchemy 2.3 needs Rails 3.2 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
34
+ raise "Alchemy 2.5 needs Rails 3.2 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
32
35
  end
33
36
 
34
37
  module Alchemy
@@ -55,6 +55,9 @@ set :rails_env, "production"
55
55
 
56
56
  # before hooks
57
57
  before "deploy:start", "deploy:seed"
58
+ <%- if @database_type == "mysql" -%>
59
+ before "deploy:migrate", "alchemy:db:dump"
60
+ <%- end -%>
58
61
  before "deploy:create_symlink", "deploy:migrate"
59
62
 
60
63
  # after hooks
@@ -21,7 +21,11 @@ module Alchemy
21
21
  else
22
22
  @contents = (element["contents"] or [])
23
23
  end
24
- @element_name = element["name"].underscore
24
+ if element["name"] =~ /\A[a-z0-9_-]+\z/
25
+ @element_name = element["name"].underscore
26
+ else
27
+ raise "Element name '#{element['name']}' has wrong format. Only lowercase and non whitespace characters allowed."
28
+ end
25
29
 
26
30
  conditional_template "editor.html.#{template_engine}", "#{@elements_dir}/_#{@element_name}_editor.html.#{template_engine}"
27
31
  conditional_template "view.html.#{template_engine}", "#{@elements_dir}/_#{@element_name}_view.html.#{template_engine}"
@@ -14,6 +14,7 @@ module Alchemy
14
14
  def create_partials
15
15
  @page_layouts = load_alchemy_yaml('page_layouts.yml')
16
16
  @page_layouts.each do |page_layout|
17
+ next if page_layout['redirects_to_external']
17
18
  @page_layout_name = page_layout["name"].underscore
18
19
  conditional_template "layout.html.#{template_engine}", "#{@page_layouts_dir}/_#{@page_layout_name}.html.#{template_engine}"
19
20
  end if @page_layouts
@@ -3,8 +3,7 @@ require 'rails'
3
3
  module Alchemy
4
4
  module Generators
5
5
  class ScaffoldGenerator < ::Rails::Generators::Base
6
- desc "This generator generates the Alchemy scaffold. Pass --with-standard-set to copy Alchemys Standardset files into your app."
7
- class_option 'with-standard-set', :type => :boolean, :desc => "Copy standard set files."
6
+ desc "This generator generates the Alchemy scaffold."
8
7
  source_root File.expand_path('templates', File.dirname(__FILE__))
9
8
 
10
9
  def create_config_dir
@@ -17,27 +16,19 @@ module Alchemy
17
16
  end
18
17
 
19
18
  def copy_config
20
- @config_path = File.expand_path('../../../../../config/alchemy', File.dirname(__FILE__))
21
- copy_file "#{@config_path}/config.yml", "#{Rails.root}/config/alchemy/config.yml"
19
+ copy_file "#{config_path}/config.yml", "#{Rails.root}/config/alchemy/config.yml"
22
20
  end
23
21
 
24
22
  def copy_files
25
- if options['with-standard-set']
26
- layouts_path = File.expand_path('../../../../../app/views/layouts/alchemy', File.dirname(__FILE__))
27
- elements_path = File.expand_path('../../../../../app/views/alchemy/elements', File.dirname(__FILE__))
28
- page_layouts_path = File.expand_path('../../../../../app/views/alchemy/page_layouts', File.dirname(__FILE__))
29
- copy_file "#{@config_path}/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
30
- copy_file "#{@config_path}/page_layouts.yml", "#{Rails.root}/config/alchemy/page_layouts.yml"
31
- copy_file "#{layouts_path}/pages.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
32
- Dir.glob("#{elements_path}/*").reject { |file_path| !(File.basename(file_path) =~ /(.+)_(view|editor).html.erb/) }.each do |file_path|
33
- copy_file file_path, "#{Rails.root}/app/views/alchemy/elements/#{File.basename(file_path)}"
34
- end
35
- directory "#{page_layouts_path}/", "#{Rails.root}/app/views/alchemy/page_layouts/"
36
- else
37
- copy_file "#{File.dirname(__FILE__)}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
38
- template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
39
- copy_file "#{File.dirname(__FILE__)}/files/pages.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
40
- end
23
+ copy_file "#{File.dirname(__FILE__)}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
24
+ template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
25
+ copy_file "#{File.dirname(__FILE__)}/files/application.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
26
+ end
27
+
28
+ private
29
+
30
+ def config_path
31
+ @config_path ||= File.expand_path('../../../../../config/alchemy', File.dirname(__FILE__))
41
32
  end
42
33
 
43
34
  end