alchemy_cms 2.1.beta6 → 2.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +3 -1
  2. data/Gemfile +10 -2
  3. data/Guardfile +16 -0
  4. data/README.md +3 -3
  5. data/Rakefile +0 -5
  6. data/alchemy_cms.gemspec +1 -9
  7. data/app/assets/javascripts/alchemy/alchemy.base.js +5 -4
  8. data/app/assets/javascripts/alchemy/{alchemy.dragndrop.js.erb → alchemy.dragndrop.js} +0 -0
  9. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +96 -0
  10. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +48 -50
  11. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +41 -0
  12. data/app/assets/javascripts/alchemy/alchemy.js +2 -0
  13. data/app/assets/javascripts/alchemy/alchemy.menubar.js +55 -0
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +94 -139
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +98 -0
  16. data/app/assets/javascripts/alchemy/alchemy.windows.js +1 -174
  17. data/app/assets/javascripts/alchemy/menubar.js +2 -0
  18. data/app/assets/javascripts/alchemy/preview.js +2 -1
  19. data/app/assets/stylesheets/alchemy/_defaults.scss +7 -8
  20. data/app/assets/stylesheets/alchemy/base.css.scss +29 -33
  21. data/app/assets/stylesheets/alchemy/elements.css.scss +4 -4
  22. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +1 -1
  23. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  24. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +19 -4
  25. data/app/assets/stylesheets/alchemy/menubar.css.scss +85 -0
  26. data/app/assets/stylesheets/alchemy/standard_set.css +3 -5
  27. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  28. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +1 -1
  29. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -18
  30. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  31. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  32. data/app/controllers/alchemy/admin/essence_files_controller.rb +4 -2
  33. data/app/controllers/alchemy/admin/pictures_controller.rb +6 -20
  34. data/app/controllers/alchemy/admin/resources_controller.rb +7 -5
  35. data/app/controllers/alchemy/base_controller.rb +14 -4
  36. data/app/controllers/alchemy/messages_controller.rb +4 -4
  37. data/app/controllers/alchemy/pages_controller.rb +51 -32
  38. data/app/controllers/alchemy/pictures_controller.rb +0 -3
  39. data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
  40. data/app/helpers/alchemy/admin/base_helper.rb +6 -4
  41. data/app/helpers/alchemy/base_helper.rb +26 -0
  42. data/app/helpers/alchemy/pages_helper.rb +42 -22
  43. data/app/models/alchemy/attachment.rb +10 -2
  44. data/app/models/alchemy/cell.rb +1 -0
  45. data/app/models/alchemy/content.rb +8 -6
  46. data/app/models/alchemy/element.rb +1 -1
  47. data/app/models/alchemy/essence_audio.rb +1 -8
  48. data/app/models/alchemy/essence_date.rb +2 -9
  49. data/app/models/alchemy/essence_file.rb +1 -8
  50. data/app/models/alchemy/essence_flash.rb +0 -7
  51. data/app/models/alchemy/essence_html.rb +1 -8
  52. data/app/models/alchemy/essence_picture.rb +0 -11
  53. data/app/models/alchemy/essence_richtext.rb +4 -12
  54. data/app/models/alchemy/essence_text.rb +1 -13
  55. data/app/models/alchemy/essence_video.rb +1 -8
  56. data/app/models/alchemy/page.rb +28 -22
  57. data/app/models/alchemy/picture.rb +19 -0
  58. data/app/sweepers/alchemy/pages_sweeper.rb +17 -6
  59. data/app/sweepers/alchemy/pictures_sweeper.rb +1 -3
  60. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +2 -2
  61. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  62. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +2 -2
  63. data/app/views/alchemy/admin/attachments/_files_list.html.erb +13 -11
  64. data/app/views/alchemy/admin/attachments/create.js.erb +1 -1
  65. data/app/views/alchemy/admin/attachments/edit.html.erb +2 -2
  66. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -2
  67. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  68. data/app/views/alchemy/admin/essence_files/edit.html.erb +32 -32
  69. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +29 -29
  70. data/app/views/alchemy/admin/essence_pictures/update.js.erb +13 -12
  71. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +4 -1
  72. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  73. data/app/views/alchemy/admin/pages/edit.html.erb +8 -8
  74. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  75. data/app/views/alchemy/admin/pages/new.html.erb +1 -1
  76. data/app/views/alchemy/admin/pages/update.js.erb +19 -12
  77. data/app/views/alchemy/admin/pictures/_picture.html.erb +1 -1
  78. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +8 -6
  79. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +6 -1
  80. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  81. data/app/views/alchemy/admin/users/_table.html.erb +13 -13
  82. data/app/views/alchemy/admin/users/_user.html.erb +1 -1
  83. data/app/views/alchemy/admin/users/index.html.erb +2 -2
  84. data/app/views/alchemy/elements/_contactform_view.html.erb +78 -78
  85. data/app/views/alchemy/elements/_download_editor.html.erb +1 -0
  86. data/app/views/alchemy/elements/_download_view.html.erb +3 -0
  87. data/app/views/alchemy/essences/_essence_date_editor.html.erb +1 -1
  88. data/app/views/alchemy/essences/_essence_file_editor.html.erb +1 -0
  89. data/app/views/alchemy/essences/_essence_file_view.html.erb +6 -2
  90. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -2
  91. data/app/views/alchemy/essences/_essence_picture_view.html.erb +1 -1
  92. data/app/views/alchemy/navigation/_link.html.erb +1 -2
  93. data/app/views/alchemy/notifications/admin_user_created.text.erb +7 -7
  94. data/app/views/alchemy/notifications/registered_user_created.text.erb +5 -5
  95. data/app/views/alchemy/user_sessions/login.html.erb +34 -35
  96. data/app/views/layouts/alchemy/login.html.erb +3 -8
  97. data/app/views/layouts/alchemy/pages.html.erb +1 -0
  98. data/bin/alchemy +43 -75
  99. data/config/alchemy/config.yml +10 -0
  100. data/config/alchemy/elements.yml +5 -0
  101. data/config/alchemy/page_layouts.yml +1 -1
  102. data/config/locales/alchemy.de.yml +21 -8
  103. data/config/locales/alchemy.en.yml +20 -4
  104. data/config/routes.rb +25 -20
  105. data/db/migrate/{20111116125112_namespace_models.rb → 20111116125112_namespace_alchemy_models.rb} +1 -1
  106. data/lib/alchemy/capistrano.rb +4 -17
  107. data/lib/alchemy/engine.rb +2 -0
  108. data/lib/alchemy/essence.rb +29 -41
  109. data/lib/alchemy/i18n.rb +1 -1
  110. data/lib/alchemy/mount_point.rb +10 -0
  111. data/lib/alchemy/page_layout.rb +7 -7
  112. data/lib/alchemy/seeder.rb +85 -47
  113. data/lib/alchemy/upgrader.rb +115 -0
  114. data/lib/alchemy/version.rb +1 -1
  115. data/lib/alchemy_cms.rb +4 -3
  116. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +6 -2
  117. data/lib/tasks/ferret.rake +12 -0
  118. data/lib/tasks/install.rake +16 -105
  119. data/lib/tasks/routes.rake +29 -0
  120. data/lib/tasks/upgrade.rake +5 -67
  121. data/spec/controllers/admin/pages_controller_spec.rb +1 -1
  122. data/spec/controllers/pages_controller_spec.rb +31 -0
  123. data/spec/factories.rb +24 -15
  124. data/spec/helpers/admin/base_helper_spec.rb +0 -7
  125. data/spec/helpers/pages_helper_spec.rb +54 -29
  126. data/spec/helpers/url_helpers_spec.rb +40 -0
  127. data/spec/integration/admin/pages_controller_spec.rb +3 -3
  128. data/spec/integration/pages_controller_spec.rb +80 -6
  129. data/spec/integration/security_spec.rb +2 -2
  130. data/spec/models/content_spec.rb +24 -0
  131. data/spec/models/page_spec.rb +174 -47
  132. data/spec/models/picture_spec.rb +54 -0
  133. data/spec/page_layout_spec.rb +2 -2
  134. data/spec/routing_spec.rb +205 -1
  135. data/spec/spec_helper.rb +53 -32
  136. metadata +51 -46
  137. data/lib/alchemy/file_utilz.rb +0 -73
@@ -0,0 +1,10 @@
1
+ module Alchemy
2
+
3
+ # Returns alchemys mount point in current rails app.
4
+ def self.mount_point
5
+ alchemy_routes = Rails.application.routes.named_routes[:alchemy]
6
+ raise "Alchemy not mounted! Please mount Alchemy::Engine in your config/routes.rb file." if alchemy_routes.nil?
7
+ alchemy_routes.path.gsub(/^\/$/, '')
8
+ end
9
+
10
+ end
@@ -17,7 +17,7 @@ module Alchemy
17
17
 
18
18
  # Returns the page_layout.yml file. Tries to first load from config/alchemy and if not found from vendor/plugins/alchemy/config/alchemy.
19
19
  def self.get_layouts
20
- @@definitions = read_layouts_file
20
+ @@definitions ||= read_layouts_file
21
21
  end
22
22
 
23
23
  # Add additional pagelayout definitions. I.E. from your module.
@@ -25,7 +25,7 @@ module Alchemy
25
25
  # You can pass a single layout definition as Hash, or a collection of pagelayouts as Array.
26
26
  # Example Pagelayout definitions can be found in the +page_layouts.yml+ from the standard set.
27
27
  def self.add(page_layout)
28
- @@definitions = read_layouts_file
28
+ @@definitions ||= read_layouts_file
29
29
  if page_layout.is_a?(Array)
30
30
  @@definitions += page_layout
31
31
  elsif page_layout.is_a?(Hash)
@@ -45,10 +45,10 @@ module Alchemy
45
45
  def self.get_all_by_attributes(attributes)
46
46
  return [] if attributes.blank?
47
47
  if attributes.class.name == 'Hash'
48
- all_definitions = read_layouts_file
48
+ @@definitions ||= read_layouts_file
49
49
  layouts = []
50
- attributes.each do |key, value|
51
- result = all_definitions.select{ |a| a[key.to_s].to_s.downcase == value.to_s.downcase if a.has_key?(key.to_s) }
50
+ attributes.stringify_keys.each do |key, value|
51
+ result = @@definitions.select{ |a| a[key].to_s.downcase == value.to_s.downcase if a.has_key?(key) }
52
52
  layouts += result unless result.empty?
53
53
  end
54
54
  return layouts
@@ -71,9 +71,9 @@ module Alchemy
71
71
  @@definitions.select do |layout|
72
72
  used = layout["unique"] && has_a_page_this_layout?(layout["name"], language_id)
73
73
  if layoutpage
74
- layout["layoutpage"] == true && !used && layout["newsletter"] != true
74
+ layout["layoutpage"] == true && !used
75
75
  else
76
- layout["layoutpage"] != true && !used && layout["newsletter"] != true
76
+ layout["layoutpage"] != true && !used
77
77
  end
78
78
  end
79
79
  end
@@ -1,61 +1,99 @@
1
- require 'yaml'
1
+ require 'thor/shell/color'
2
2
 
3
3
  module Alchemy
4
4
  class Seeder
5
5
 
6
- # This seed builds the necessary page structure for alchemy in your db.
7
- # Put Alchemy::Seeder.seed! inside your db/seeds.rb file and run it with rake db:seed.
8
- def self.seed!
9
- errors = []
10
- notices = []
11
-
12
- default_language = Alchemy::Config.get(:default_language)
13
-
14
- lang = Language.find_or_initialize_by_code(
15
- :name => default_language['name'],
16
- :code => default_language['code'],
17
- :frontpage_name => default_language['frontpage_name'],
18
- :page_layout => default_language['page_layout'],
19
- :public => true,
20
- :default => true
21
- )
22
- if lang.new_record?
23
- if lang.save
24
- puts "== Created language #{lang.name}"
6
+ class << self
7
+
8
+ # This seed builds the necessary page structure for alchemy in your database.
9
+ # Run the alchemy:db:seed rake task to seed your database.
10
+ def seed!
11
+ desc "Seeding your database"
12
+ errors = []
13
+ notices = []
14
+
15
+ default_language = Alchemy::Config.get(:default_language)
16
+
17
+ lang = Alchemy::Language.find_or_initialize_by_code(
18
+ :name => default_language['name'],
19
+ :code => default_language['code'],
20
+ :frontpage_name => default_language['frontpage_name'],
21
+ :page_layout => default_language['page_layout'],
22
+ :public => true,
23
+ :default => true
24
+ )
25
+ if lang.new_record?
26
+ if lang.save
27
+ log "Created language #{lang.name}."
28
+ else
29
+ errors << "Errors while creating language #{lang.name}: #{lang.errors.full_messages}"
30
+ end
31
+ else
32
+ notices << "Language #{lang.name} was already present."
33
+ end
34
+
35
+ root = Alchemy::Page.find_or_initialize_by_name(
36
+ :name => 'Root',
37
+ :do_not_sweep => true
38
+ )
39
+ if root.new_record?
40
+ if root.save
41
+ log "Created page #{root.name}."
42
+ else
43
+ errors << "Errors while creating page #{root.name}: #{root.errors.full_messages}"
44
+ end
25
45
  else
26
- errors << "Errors creating language #{lang.name}: #{lang.errors.full_messages}"
46
+ notices << "Page #{root.name} was already present."
47
+ end
48
+
49
+ if errors.blank?
50
+ log "Successfully seeded your database!" if notices.blank?
51
+ notices.each do |note|
52
+ log(note, :skip)
53
+ end
54
+ else
55
+ log("Some pages could not be created:", :error)
56
+ errors.each do |error|
57
+ log(error, :error)
58
+ end
27
59
  end
28
- else
29
- notices << "== Skipping! Language #{lang.name} was already present"
30
60
  end
31
-
32
- root = Page.find_or_initialize_by_name(
33
- :name => 'Root',
34
- :page_layout => "rootpage",
35
- :do_not_autogenerate => true,
36
- :do_not_sweep => true,
37
- :language => lang
38
- )
39
- if root.new_record?
40
- if root.save
41
- # We have to remove the language, because active record validates its presence on create.
42
- root.language = nil
43
- root.save
44
- puts "== Created page #{root.name}"
61
+
62
+ private
63
+
64
+ def color(name)
65
+ case name
66
+ when :green
67
+ Thor::Shell::Color::GREEN
68
+ when :red
69
+ Thor::Shell::Color::RED
70
+ when :yellow
71
+ Thor::Shell::Color::YELLOW
72
+ when :black
73
+ Thor::Shell::Color::BLACK
74
+ when :clear
75
+ Thor::Shell::Color::CLEAR
45
76
  else
46
- errors << "Errors creating page #{root.name}: #{root.errors.full_messages}"
77
+ ""
47
78
  end
48
- else
49
- notices << "== Skipping! Page #{root.name} was already present"
50
79
  end
51
-
52
- if errors.blank?
53
- puts "Success!"
54
- notices.map{ |note| puts note }
55
- else
56
- puts "WARNING! Some pages could not be created:"
57
- errors.map{ |error| puts error }
80
+
81
+ def log(message, type=nil)
82
+ case type
83
+ when :skip
84
+ puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
85
+ when :error
86
+ puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
87
+ else
88
+ puts "#{color(:green)}== #{message}#{color(:clear)}"
89
+ end
58
90
  end
91
+
92
+ def desc(message)
93
+ puts "\n#{message}"
94
+ puts "#{'-' * message.length}\n"
95
+ end
96
+
59
97
  end
60
98
 
61
99
  end
@@ -0,0 +1,115 @@
1
+ module Alchemy
2
+ class Upgrader < Alchemy::Seeder
3
+
4
+ class << self
5
+
6
+ # Runs all ugrades
7
+ def run!
8
+ Rake::Task['alchemy:install:migrations'].invoke
9
+ strip_alchemy_from_schema_version_table
10
+ Rake::Task['db:migrate'].invoke
11
+ upgrade_to_language
12
+ upgrade_layoutpages
13
+ upgrade_essence_link_target_default
14
+ upgrade_to_namespaced_essence_type
15
+ end
16
+
17
+ private
18
+
19
+ # Creates Language model if it does not exist (Alchemy CMS prior v1.5)
20
+ # Also creates missing associations between pages and languages
21
+ def upgrade_to_language
22
+ desc "Creating languages for pages"
23
+ Alchemy::Page.all.each do |page|
24
+ if !page.language_code.blank? && page.language.nil?
25
+ root = page.get_language_root
26
+ lang = Alchemy::Language.find_or_create_by_code(
27
+ :name => page.language_code.capitalize,
28
+ :code => page.language_code,
29
+ :frontpage_name => root.name,
30
+ :page_layout => root.page_layout,
31
+ :public => true
32
+ )
33
+ page.language = lang
34
+ if page.save(:validate => false)
35
+ log "Set language for page #{page.name} to #{lang.name}."
36
+ end
37
+ else
38
+ log("Language for page #{page.name} already set.", :skip)
39
+ end
40
+ end
41
+ end
42
+
43
+ def upgrade_layoutpages
44
+ desc "Setting language of layoutpages"
45
+ default_language = Alchemy::Language.get_default
46
+ layoutpages = Alchemy::Page.layoutpages
47
+ if layoutpages.any?
48
+ layoutpages.each do |page|
49
+ if page.language.class == String || page.language.nil?
50
+ page.language = default_language
51
+ if page.save(:validate => false)
52
+ log "Set language for page #{page.name} to #{default_language.name}."
53
+ end
54
+ else
55
+ log "Language for page #{page.name} already set.", :skip
56
+ end
57
+ end
58
+ else
59
+ log "No layoutpages found.", :skip
60
+ end
61
+ end
62
+
63
+ def upgrade_essence_link_target_default
64
+ desc "Setting new link_target default"
65
+ essences = (Alchemy::EssencePicture.all + Alchemy::EssenceText.all)
66
+ if essences.any?
67
+ essences.each do |essence|
68
+ case essence.link_target
69
+ when '1'
70
+ if essence.update_attribute(:link_target, 'blank')
71
+ log("Updated #{essence.preview_text} link target to #{essence.link_target}.")
72
+ end
73
+ when '0'
74
+ essence.update_attribute(:link_target, nil)
75
+ log("Updated #{essence.preview_text} link target to #{essence.link_target.inspect}.")
76
+ else
77
+ log("#{essence.preview_text} already upgraded.", :skip)
78
+ end
79
+ end
80
+ else
81
+ log("No essences to upgrade found.", :skip)
82
+ end
83
+ end
84
+
85
+ # Updates all essence_type of Content if not already namespaced.
86
+ def upgrade_to_namespaced_essence_type
87
+ desc "Namespacing essence_type columns"
88
+ depricated_contents = Alchemy::Content.where("essence_type LIKE ?", "Essence%")
89
+ if depricated_contents.any?
90
+ success = 0
91
+ errors = []
92
+ depricated_contents.each do |c|
93
+ if c.update_attribute(:essence_type, c.essence_type.gsub(/^Essence/, 'Alchemy::Essence'))
94
+ success += 1
95
+ else
96
+ errors << c.errors.full_messages
97
+ end
98
+ end
99
+ log("Namespaced #{success} essence_type columns.") if success > 0
100
+ log("#{errors.count} errors while namespacing essence_type columns.\n#{errors.join('\n')}", :error) if errors.count > 0
101
+ else
102
+ log "No essence_type columns to be namespaced found.", :skip
103
+ end
104
+ end
105
+
106
+ def strip_alchemy_from_schema_version_table
107
+ database_yml = YAML.load_file(Rails.root.join("config", "database.yml"))
108
+ connection = Mysql2::Client.new(database_yml.fetch(Rails.env.to_s).symbolize_keys)
109
+ connection.query "UPDATE schema_migrations SET `schema_migrations`.`version` = REPLACE(`schema_migrations`.`version`,'-alchemy','')"
110
+ end
111
+
112
+ end
113
+
114
+ end
115
+ end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.1.beta6"
3
+ VERSION = "2.1.rc2"
4
4
 
5
5
  end
@@ -14,6 +14,7 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3
14
14
  require 'extensions/hash'
15
15
  require 'extensions/array'
16
16
  require 'extensions/action_view'
17
+ require 'alchemy/mount_point'
17
18
  require 'alchemy/version'
18
19
  require 'alchemy/auth_engine'
19
20
  require 'alchemy/engine'
@@ -22,11 +23,11 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3
22
23
  end
23
24
  require File.join(File.dirname(__FILE__), "alchemy", "seeder")
24
25
  else
25
- raise "Alchemy 2.0 needs Rails 3.0 or higher. You are currently using Rails #{Rails::VERSION::MAJOR}"
26
+ raise "Alchemy 2.1 needs Rails 3.1 or higher. You are currently using Rails #{Rails::VERSION::STRING}"
26
27
  end
27
28
 
28
29
  module Alchemy
29
-
30
+
30
31
  class EssenceError < StandardError; end
31
-
32
+
32
33
  end
@@ -24,11 +24,15 @@ module Alchemy
24
24
  def copy_files
25
25
  if options['with-standard-set']
26
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__))
27
29
  copy_file "#{@config_path}/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
28
30
  copy_file "#{@config_path}/page_layouts.yml", "#{Rails.root}/config/alchemy/page_layouts.yml"
29
31
  copy_file "#{layouts_path}/pages.html.erb", "#{Rails.root}/app/views/layouts/alchemy/pages.html.erb"
30
- Rails::Generators.invoke("alchemy:elements")
31
- Rails::Generators.invoke("alchemy:page_layouts")
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/"
32
36
  else
33
37
  copy_file "#{File.dirname(__FILE__)}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
34
38
  copy_file "#{File.dirname(__FILE__)}/files/page_layouts.yml", "#{Rails.root}/config/alchemy/page_layouts.yml"
@@ -0,0 +1,12 @@
1
+ namespace :ferret do
2
+
3
+ desc "Updates the ferret index for the application."
4
+ task :rebuild_index => :environment do
5
+ puts "Rebuilding Ferret Index for EssenceText"
6
+ Alchemy::EssenceText.rebuild_index
7
+ puts "Rebuilding Ferret Index for EssenceRichtext"
8
+ Alchemy::EssenceRichtext.rebuild_index
9
+ puts "Completed Ferret Index Rebuild"
10
+ end
11
+
12
+ end
@@ -1,110 +1,21 @@
1
- # encoding: UTF-8
2
- require File.join(File.dirname(__FILE__), '../alchemy/file_utilz.rb')
3
-
4
1
  namespace :alchemy do
5
-
6
- desc "Migrates the database, inserts essential data into the database and copies all assets."
7
- task :prepare do
8
- Rake::Task['alchemy:install:migrations'].invoke
9
- Rake::Task['alchemy:seeder:copy'].invoke
10
- Rake::Task['alchemy:assets:copy:all'].invoke
11
- end
12
-
13
- namespace 'seeder' do
14
- desc "Copy a line of code into the seeds.rb file"
15
- task :copy do
16
- File.open("./db/seeds.rb", "a") do |f|
17
- f.puts "\n# Seeding Alchemy data"
18
- f.puts "Alchemy::Seeder.seed!\n"
19
- end
20
- end
21
- end
22
2
 
23
- namespace 'assets' do
24
- namespace 'copy' do
25
-
26
- desc "Copy all assets for Alchemy into apps public folder"
27
- task :all do
28
- Rake::Task['alchemy:assets:copy:javascripts'].invoke
29
- Rake::Task['alchemy:assets:copy:stylesheets'].invoke
30
- Rake::Task['alchemy:assets:copy:images'].invoke
31
- end
32
-
33
- desc "Copy javascripts for Alchemy into apps public folder"
34
- task :javascripts do
35
- system "rm -rf #{Rails.root.to_s}/public/javascripts/alchemy"
36
- system "mkdir -p #{Rails.root.to_s}/public/javascripts/alchemy"
37
- system "rsync -r #{File.join(File.dirname(__FILE__), '..', '..', 'assets', 'javascripts', '*')} #{Rails.root.to_s}/public/javascripts/alchemy/"
38
- end
39
-
40
- desc "Copy stylesheets for Alchemy into apps public folder"
41
- task :stylesheets do
42
- system "rm -rf #{Rails.root.to_s}/public/stylesheets/alchemy"
43
- system "mkdir -p #{Rails.root.to_s}/public/stylesheets/alchemy"
44
- system "rsync -r #{File.join(File.dirname(__FILE__), '..', '..', 'assets', 'stylesheets', '*')} #{Rails.root.to_s}/public/stylesheets/alchemy/"
45
- end
46
-
47
- desc "Copy images for Alchemy into apps public folder"
48
- task :images do
49
- system "rm -rf #{Rails.root.to_s}/public/images/alchemy"
50
- system "mkdir -p #{Rails.root.to_s}/public/images/alchemy"
51
- system "rsync -r #{File.join(File.dirname(__FILE__), '..', '..', 'assets', 'images', '*')} #{Rails.root.to_s}/public/images/alchemy/"
52
- end
53
-
54
- end
55
- end
56
-
57
- namespace :standard_set do
58
-
59
- desc "Install Alchemys standard set."
60
- task :install do
61
- system("rails g alchemy:scaffold --with_standard_set")
62
- Rake::Task['alchemy:assets:copy:all'].invoke
63
- end
64
-
65
- end
3
+ namespace :db do
66
4
 
67
- namespace :cells do
68
-
69
- desc "Creates all cells for all pages"
70
- task :create => :environment do
71
- cell_yml = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'config', 'alchemy', 'cells.yml')
72
- page_layouts = Alchemy::PageLayout.get_layouts
73
- if File.exist?(cell_yml) && page_layouts
74
- cells = YAML.load_file(cell_yml)
75
- page_layouts.each do |layout|
76
- unless layout['cells'].blank?
77
- cells_for_layout = cells.select { |cell| layout['cells'].include? cell['name'] }
78
- Alchemy::Page.find_all_by_page_layout(layout['name']).each do |page|
79
- cells_for_layout.each do |cell_for_layout|
80
- cell = Cell.find_or_initialize_by_name_and_page_id({:name => cell_for_layout['name'], :page_id => page.id})
81
- cell.elements << page.elements.select { |element| cell_for_layout['elements'].include?(element.name) }
82
- if cell.new_record?
83
- cell.save
84
- puts "== Creating cell '#{cell.name}' for page '#{page.name}'"
85
- else
86
- puts "== Skipping! Cell '#{cell.name}' for page '#{page.name}' was already present"
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
93
- end
94
-
95
- end
96
-
97
- end
5
+ desc "Seeds the database with essential data for Alchemy."
6
+ task :seed => :environment do
7
+ Alchemy::Seeder.seed!
8
+ end
9
+
10
+ end
11
+
12
+ namespace :standard_set do
13
+
14
+ desc "Install Alchemys standard set."
15
+ task :install do
16
+ system("rails g alchemy:scaffold --with-standard-set")
17
+ end
18
+
19
+ end
98
20
 
99
- namespace :ferret do
100
-
101
- desc "Updates the ferret index for the application."
102
- task :rebuild_index => :environment do
103
- puts "Rebuilding Ferret Index for EssenceText"
104
- Alchemy::EssenceText.rebuild_index
105
- puts "Rebuilding Ferret Index for EssenceRichtext"
106
- Alchemy::EssenceRichtext.rebuild_index
107
- puts "Completed Ferret Index Rebuild"
108
- end
109
-
110
21
  end