alchemy_cms 2.4.1 → 2.5.0.b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
- data/README.md +18 -17
- data/alchemy_cms.gemspec +5 -10
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/stylesheets/alchemy/archive.scss +27 -0
- data/app/assets/stylesheets/alchemy/base.scss +0 -51
- data/app/assets/stylesheets/alchemy/elements.scss +37 -2
- data/app/assets/stylesheets/alchemy/icons.scss +4 -0
- data/app/assets/stylesheets/alchemy/modules.scss +4 -0
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
- data/app/assets/stylesheets/alchemy/tables.scss +1 -1
- data/app/assets/stylesheets/alchemy/variables.scss +1 -0
- data/app/controllers/alchemy/admin/pages_controller.rb +1 -0
- data/app/controllers/alchemy/admin/pictures_controller.rb +22 -8
- data/app/controllers/alchemy/admin/resources_controller.rb +1 -1
- data/app/controllers/alchemy/admin/sites_controller.rb +6 -0
- data/app/controllers/alchemy/base_controller.rb +8 -0
- data/app/controllers/alchemy/elements_controller.rb +33 -3
- data/app/controllers/alchemy/messages_controller.rb +47 -40
- data/app/controllers/alchemy/pages_controller.rb +8 -31
- data/app/controllers/alchemy/pictures_controller.rb +64 -30
- data/app/helpers/alchemy/admin/base_helper.rb +7 -0
- data/app/helpers/alchemy/admin/pages_helper.rb +12 -0
- data/app/helpers/alchemy/elements_helper.rb +2 -0
- data/app/helpers/alchemy/pages_helper.rb +30 -10
- data/app/helpers/alchemy/url_helper.rb +1 -0
- data/app/models/alchemy/content.rb +1 -2
- data/app/models/alchemy/element.rb +47 -2
- data/app/models/alchemy/language.rb +27 -14
- data/app/models/alchemy/page.rb +1 -1
- data/app/models/alchemy/picture.rb +46 -41
- data/app/models/alchemy/site.rb +44 -0
- data/app/views/alchemy/admin/elements/_element_head.html.erb +1 -0
- data/app/views/alchemy/admin/languages/index.html.erb +23 -0
- data/app/views/alchemy/admin/pages/edit.html.erb +27 -1
- data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -0
- data/app/views/alchemy/admin/pictures/_picture.html.erb +24 -2
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +5 -4
- data/app/views/alchemy/admin/pictures/create.js.erb +1 -9
- data/app/views/alchemy/admin/pictures/info.html.erb +42 -0
- data/app/views/alchemy/admin/resources/_form.html.erb +0 -2
- data/app/views/alchemy/admin/resources/_resource.html.erb +2 -1
- data/app/views/alchemy/admin/resources/index.html.erb +2 -1
- data/app/views/alchemy/elements/show.html.erb +1 -6
- data/app/views/alchemy/elements/show.js.erb +4 -10
- data/app/views/alchemy/essences/_essence_link_view.html.erb +1 -0
- data/app/views/alchemy/search/_form.html.erb +9 -6
- data/app/views/alchemy/search/_result.html.erb +1 -1
- data/bin/alchemy +13 -120
- data/config/alchemy/config.yml +7 -11
- data/config/alchemy/modules.yml +24 -12
- data/config/authorization_rules.rb +6 -2
- data/config/initializers/dragonfly.rb +20 -0
- data/config/locales/alchemy.de.yml +57 -28
- data/config/locales/alchemy.en.yml +18 -4
- data/config/routes.rb +4 -2
- data/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +21 -0
- data/db/migrate/20121205155004_create_alchemy_sites.rb +14 -0
- data/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +6 -0
- data/lib/alchemy/capistrano.rb +7 -2
- data/lib/alchemy/ferret_search.rb +84 -0
- data/lib/alchemy/picture_attributes.rb +29 -0
- data/lib/alchemy/seeder.rb +10 -16
- data/lib/alchemy/upgrader.rb +59 -8
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +7 -4
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +3 -0
- data/lib/rails/generators/alchemy/elements/elements_generator.rb +5 -1
- data/lib/rails/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
- data/lib/rails/generators/alchemy/scaffold/files/{pages.html.erb → application.html.erb} +0 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +11 -20
- data/lib/rails/templates/alchemy.rb +1 -7
- data/lib/tasks/{database.rake → alchemy/db.rake} +1 -1
- data/lib/tasks/{install.rake → alchemy/install.rake} +9 -14
- data/lib/tasks/{upgrade.rake → alchemy/upgrade.rake} +1 -1
- data/spec/controllers/elements_controller_spec.rb +24 -9
- data/spec/controllers/pictures_controller_spec.rb +11 -8
- data/{app → spec/dummy/app}/views/alchemy/elements/_article_editor.html.erb +0 -0
- data/{app → spec/dummy/app}/views/alchemy/elements/_article_view.html.erb +0 -0
- data/{app → spec/dummy/app}/views/alchemy/elements/_headline_view.html.erb +0 -0
- data/{app → spec/dummy/app}/views/alchemy/elements/_news_view.html.erb +0 -0
- data/{app → spec/dummy/app}/views/alchemy/elements/_searchresult_view.html.erb +0 -0
- data/{app → spec/dummy/app}/views/alchemy/page_layouts/_standard.html.erb +0 -0
- data/spec/dummy/config/alchemy/elements.yml +86 -0
- data/spec/dummy/config/alchemy/page_layouts.yml +26 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +21 -0
- data/spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb +14 -0
- data/spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +6 -0
- data/spec/dummy/db/schema.rb +21 -6
- data/spec/factories.rb +6 -2
- data/spec/integration/translation_integration_spec.rb +4 -18
- data/spec/models/element_spec.rb +4 -4
- data/spec/models/picture_spec.rb +37 -20
- data/spec/models/site_spec.rb +69 -0
- data/spec/routing_spec.rb +115 -115
- data/spec/spec_helper.rb +1 -3
- data/spec/support/alchemy/specs_helpers.rb +4 -4
- data/vendor/assets/javascripts/jquery_plugins/jquery.html5uploader.js +1 -1
- metadata +72 -96
- data/app/assets/stylesheets/alchemy/standard_set.css +0 -440
- data/app/views/alchemy/elements/_bild_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_bild_text_editor.html.erb +0 -7
- data/app/views/alchemy/elements/_bild_text_view.html.erb +0 -9
- data/app/views/alchemy/elements/_bild_view.html.erb +0 -9
- data/app/views/alchemy/elements/_claim_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_claim_view.html.erb +0 -1
- data/app/views/alchemy/elements/_contactform_editor.html.erb +0 -4
- data/app/views/alchemy/elements/_contactform_view.html.erb +0 -78
- data/app/views/alchemy/elements/_download_editor.html.erb +0 -4
- data/app/views/alchemy/elements/_download_view.html.erb +0 -7
- data/app/views/alchemy/elements/_footnote_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_footnote_view.html.erb +0 -5
- data/app/views/alchemy/elements/_header_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_header_view.html.erb +0 -1
- data/app/views/alchemy/elements/_headline_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +0 -3
- data/app/views/alchemy/elements/_image_mosaic_view.html.erb +0 -14
- data/app/views/alchemy/elements/_intro_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_intro_image_text_editor.html.erb +0 -3
- data/app/views/alchemy/elements/_intro_image_text_view.html.erb +0 -16
- data/app/views/alchemy/elements/_intro_view.html.erb +0 -3
- data/app/views/alchemy/elements/_news_editor.html.erb +0 -3
- data/app/views/alchemy/elements/_searchresult_editor.html.erb +0 -4
- data/app/views/alchemy/elements/_sitemap_editor.html.erb +0 -3
- data/app/views/alchemy/elements/_sitemap_view.html.erb +0 -38
- data/app/views/alchemy/elements/_sitename_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_sitename_view.html.erb +0 -1
- data/app/views/alchemy/elements/_subheadline_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_subheadline_view.html.erb +0 -5
- data/app/views/alchemy/elements/_text_editor.html.erb +0 -1
- data/app/views/alchemy/elements/_text_view.html.erb +0 -3
- data/app/views/alchemy/page_layouts/_contact.html.erb +0 -14
- data/app/views/alchemy/page_layouts/_external.html.erb +0 -0
- data/app/views/alchemy/page_layouts/_intro.html.erb +0 -14
- data/app/views/alchemy/page_layouts/_layout_footer.html.erb +0 -14
- data/app/views/alchemy/page_layouts/_layout_header.html.erb +0 -14
- data/app/views/alchemy/page_layouts/_news.html.erb +0 -14
- data/app/views/alchemy/page_layouts/_newsletter_layout.html.erb +0 -1
- data/app/views/alchemy/page_layouts/_search.html.erb +0 -14
- data/app/views/alchemy/pictures/show.gif.flexi +0 -19
- data/app/views/alchemy/pictures/show.jpg.flexi +0 -19
- data/app/views/alchemy/pictures/show.png.flexi +0 -19
- data/app/views/alchemy/pictures/thumbnail.png.flexi +0 -13
- data/app/views/alchemy/pictures/zoom.jpg.flexi +0 -3
- data/app/views/alchemy/pictures/zoom.png.flexi +0 -3
- data/app/views/layouts/alchemy/pages.html.erb +0 -51
- data/config/alchemy/elements.yml +0 -274
- data/config/alchemy/page_layouts.yml +0 -75
- data/config/asset_packages.yml +0 -30
- data/config/initializers/localeapp.rb +0 -9
- data/lib/rails/generators/alchemy/plugin/files/translation.pot +0 -3
- data/lib/rails/generators/alchemy/plugin/files/translation_de.po +0 -3
- data/lib/rails/generators/alchemy/plugin/files/translation_en.po +0 -3
- data/lib/rails/generators/alchemy/plugin/plugin_generator.rb +0 -37
- data/lib/rails/generators/alchemy/plugin/templates/authorization_rules.rb +0 -34
- data/lib/rails/generators/alchemy/plugin/templates/config.yml +0 -30
- data/lib/rails/generators/alchemy/plugin/templates/init.rb +0 -1
- data/lib/rails/generators/alchemy/plugin/templates/plugin.rb +0 -0
- data/lib/rails/generators/alchemy/plugin/templates/routes.rb +0 -10
- data/lib/tasks/fleximage.rake +0 -154
- data/spec/dummy/app/views/layouts/.gitkeep +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'rails'
|
|
2
|
-
|
|
3
|
-
module Alchemy
|
|
4
|
-
module Generators
|
|
5
|
-
class PluginGenerator < ::Rails::Generators::Base
|
|
6
|
-
desc "This generator generates a Alchemy plugin skeleton for you."
|
|
7
|
-
argument :plugin_name, :banner => "your_plugin_name"
|
|
8
|
-
source_root File.expand_path('templates', File.dirname(__FILE__))
|
|
9
|
-
|
|
10
|
-
def create_directories
|
|
11
|
-
@plugin_name = plugin_name.underscore
|
|
12
|
-
@plugin_path = Rails.root.join('vendor/plugins', @plugin_name)
|
|
13
|
-
empty_directory "#{@plugin_path}/lib/#{@plugin_name}"
|
|
14
|
-
empty_directory "#{@plugin_path}/rails"
|
|
15
|
-
empty_directory "#{@plugin_path}/app/controllers/admin"
|
|
16
|
-
empty_directory "#{@plugin_path}/app/models"
|
|
17
|
-
empty_directory "#{@plugin_path}/app/views/admin"
|
|
18
|
-
empty_directory "#{@plugin_path}/config/alchemy"
|
|
19
|
-
empty_directory "#{@plugin_path}/config/initializers"
|
|
20
|
-
empty_directory "#{@plugin_path}/locale/de"
|
|
21
|
-
empty_directory "#{@plugin_path}/locale/en"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def create_defaults
|
|
25
|
-
copy_file("#{File.dirname(__FILE__)}/files/translation.pot", "#{@plugin_path}/locale/#{@plugin_name}.pot")
|
|
26
|
-
copy_file("#{File.dirname(__FILE__)}/files/translation_de.po", "#{@plugin_path}/locale/de/#{@plugin_name}.po")
|
|
27
|
-
copy_file("#{File.dirname(__FILE__)}/files/translation_en.po", "#{@plugin_path}/locale/en/#{@plugin_name}.po")
|
|
28
|
-
template("config.yml", "#{@plugin_path}/config/alchemy/config.yml")
|
|
29
|
-
template("authorization_rules.rb", "#{@plugin_path}/config/authorization_rules.rb")
|
|
30
|
-
template("routes.rb", "#{@plugin_path}/config/routes.rb")
|
|
31
|
-
template("plugin.rb", "#{@plugin_path}/lib/#{@plugin_name}.rb")
|
|
32
|
-
template("init.rb", "#{@plugin_path}/rails/init.rb")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Define permissions for your plugin in here.
|
|
2
|
-
# See https://github.com/stffn/declarative_authorization for further informations.
|
|
3
|
-
authorization do
|
|
4
|
-
|
|
5
|
-
role :guest do
|
|
6
|
-
has_permission_on :<%= @plugin_name.tableize %>, :to => [:show]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
role :registered do
|
|
10
|
-
includes :guest
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
role :author do
|
|
14
|
-
includes :registered
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
role :editor do
|
|
18
|
-
includes :author
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
role :admin do
|
|
22
|
-
includes :editor
|
|
23
|
-
has_permission_on :admin_<%= @plugin_name.tableize %>, :to => [:manage]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
privileges do
|
|
29
|
-
|
|
30
|
-
privilege :manage do
|
|
31
|
-
includes :index, :new, :create, :show, :edit, :update, :destroy
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# This is your plugin configuration file.
|
|
2
|
-
# ========================================
|
|
3
|
-
#
|
|
4
|
-
# Options:
|
|
5
|
-
# --------
|
|
6
|
-
#
|
|
7
|
-
# name: # Name of your plugin [String]
|
|
8
|
-
# order: # [Optional] Use this to set the order of plugins in the alchemy navigation, if more then one plugin is loaded. [Integer]
|
|
9
|
-
# settings: # [Optional] Put your own settings in YAML format into here. You can access them with plugin_conf('<%= @plugin_name.underscore %>')['settings'] [YAML]
|
|
10
|
-
# navigation:
|
|
11
|
-
# name: # The name is used in the Alchemy mainnavi. [String]
|
|
12
|
-
# controller: # The name of the controller to be called when clicking the mainnavi button. Example usage: 'admin/controllername' [String]
|
|
13
|
-
# action: # The name of the action from the controller to be called when clicking the mainnavi button [String]
|
|
14
|
-
# icon: # CSS classname for the link in the alchemy mainnavi. [String]
|
|
15
|
-
# sub_navigation: # Your plugins sub navigation. Put as much as sub navi entries as you want into here
|
|
16
|
-
# - name: # [String]
|
|
17
|
-
# controller: # Typically your controller and action you set for mainnavi entry.
|
|
18
|
-
# action: # [String]
|
|
19
|
-
|
|
20
|
-
name: <%= @plugin_name %>
|
|
21
|
-
|
|
22
|
-
navigation:
|
|
23
|
-
name: <%= @plugin_name.camelcase %>
|
|
24
|
-
controller: admin/<%= @plugin_name.tableize %>
|
|
25
|
-
action: index
|
|
26
|
-
image: <%= @plugin_name %>/<%= @plugin_name %>.png
|
|
27
|
-
sub_navigation:
|
|
28
|
-
- name: <%= @plugin_name.camelcase %>
|
|
29
|
-
controller: admin/<%= @plugin_name.tableize %>
|
|
30
|
-
action: index
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'lib/<%= @plugin_name %>')
|
|
File without changes
|
data/lib/tasks/fleximage.rake
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
namespace :fleximage do
|
|
2
|
-
|
|
3
|
-
# Find the model class
|
|
4
|
-
def model_class
|
|
5
|
-
raise 'You must specify a FLEXIMAGE_CLASS=MyClass' unless ENV['FLEXIMAGE_CLASS']
|
|
6
|
-
@model_class ||= ENV['FLEXIMAGE_CLASS'].camelcase.constantize
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
desc "Populate width and height magic columns from the current image store. Useful when migrating from on old installation."
|
|
10
|
-
task :dimensions => :environment do
|
|
11
|
-
model_class.find(:all).each do |obj|
|
|
12
|
-
if obj.has_image?
|
|
13
|
-
img = obj.load_image
|
|
14
|
-
obj.update_column :image_width, img.columns if obj.respond_to?(:image_width=)
|
|
15
|
-
obj.update_column :image_height, img.rows if obj.respond_to?(:image_height=)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
namespace :convert do
|
|
21
|
-
|
|
22
|
-
def convert_directory_format(to_format)
|
|
23
|
-
model_class.find(:all).each do |obj|
|
|
24
|
-
|
|
25
|
-
# Get the creation date
|
|
26
|
-
creation = obj[:created_at] || obj[:created_on] || Date.today
|
|
27
|
-
|
|
28
|
-
# Generate both types of file paths
|
|
29
|
-
flat_path = "#{RAILS_ROOT}/#{model_class.image_directory}/#{obj.id}.#{model_class.image_storage_format}"
|
|
30
|
-
nested_path = "#{RAILS_ROOT}/#{model_class.image_directory}/#{creation.year}/#{creation.month}/#{creation.day}/#{obj.id}.#{model_class.image_storage_format}"
|
|
31
|
-
|
|
32
|
-
# Assign old path and new path based on desired directory format
|
|
33
|
-
if to_format == :nested
|
|
34
|
-
old_path = flat_path
|
|
35
|
-
new_path = nested_path
|
|
36
|
-
else
|
|
37
|
-
old_path = nested_path
|
|
38
|
-
new_path = flat_path
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Move the files
|
|
42
|
-
if old_path != new_path && File.exists?(old_path)
|
|
43
|
-
FileUtils.mkdir_p(File.dirname(new_path))
|
|
44
|
-
FileUtils.move old_path, new_path
|
|
45
|
-
puts "#{old_path} -> #{new_path}"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def convert_image_format(to_format)
|
|
51
|
-
model_class.find(:all).each do |obj|
|
|
52
|
-
|
|
53
|
-
# convert DB stored images
|
|
54
|
-
if model_class.db_store?
|
|
55
|
-
if obj.image_file_data && obj.image_file_data.any?
|
|
56
|
-
begin
|
|
57
|
-
image = Magick::Image.from_blob(obj.image_file_data).first
|
|
58
|
-
image.format = to_format.to_s.upcase
|
|
59
|
-
obj.image_file_data = image.to_blob
|
|
60
|
-
obj.save
|
|
61
|
-
rescue Exception => e
|
|
62
|
-
puts "Could not convert image for #{model_class} with id #{obj.id}\n #{e.class} #{e}\n"
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Convert file system stored images
|
|
67
|
-
else
|
|
68
|
-
# Generate both types of file paths
|
|
69
|
-
png_path = obj.file_path.gsub(/\.jpg$/, '.png')
|
|
70
|
-
jpg_path = obj.file_path.gsub(/\.png$/, '.jpg')
|
|
71
|
-
|
|
72
|
-
# Output stub
|
|
73
|
-
output = (to_format == :jpg) ? 'PNG -> JPG' : 'JPG -> PNG'
|
|
74
|
-
|
|
75
|
-
# Assign old path and new path based on desired image format
|
|
76
|
-
if to_format == :jpg
|
|
77
|
-
old_path = png_path
|
|
78
|
-
new_path = jpg_path
|
|
79
|
-
else
|
|
80
|
-
old_path = jpg_path
|
|
81
|
-
new_path = png_path
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# Perform conversion
|
|
85
|
-
if File.exists?(old_path)
|
|
86
|
-
image = Magick::Image.read(old_path).first
|
|
87
|
-
image.format = to_format.to_s.upcase
|
|
88
|
-
image.write(new_path)
|
|
89
|
-
File.delete(old_path)
|
|
90
|
-
|
|
91
|
-
puts "#{output} : Image #{obj.id}"
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def ensure_db_store
|
|
98
|
-
col = model_class.columns.find { |c| c.name == 'image_file_data' }
|
|
99
|
-
unless col && col.type == :binary
|
|
100
|
-
raise "No image_file_data field of type :binary for this model!"
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
desc "Convert a flat images/123.png style image store to a images/2007/11/12/123.png style. Requires FLEXIMAGE_CLASS=ModelName"
|
|
105
|
-
task :to_nested => :environment do
|
|
106
|
-
convert_directory_format :nested
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
desc "Convert a nested images/2007/11/12/123.png style image store to a images/123.png style. Requires FLEXIMAGE_CLASS=ModelName"
|
|
110
|
-
task :to_flat => :environment do
|
|
111
|
-
convert_directory_format :flat
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
desc "Convert master images stored as JPGs to PNGs"
|
|
115
|
-
task :to_png => :environment do
|
|
116
|
-
convert_image_format :png
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
desc "Convert master images stored as PNGs to JPGs"
|
|
120
|
-
task :to_jpg => :environment do
|
|
121
|
-
convert_image_format :jpg
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
desc "Convert master image storage to use the database. Loads all file-stored images into the database."
|
|
125
|
-
task :to_db => :environment do
|
|
126
|
-
ensure_db_store
|
|
127
|
-
model_class.find(:all).each do |obj|
|
|
128
|
-
if File.exists?(obj.file_path)
|
|
129
|
-
File.open(obj.file_path, 'rb') do |f|
|
|
130
|
-
obj.image_file_data = f.read
|
|
131
|
-
obj.save
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
puts "--- All images successfully moved to the database. Check to make sure the transfer worked cleanly before deleting your file system image store."
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
desc "Convert master image storage to use the file system. Loads all database images into files."
|
|
140
|
-
task :to_filestore => :environment do
|
|
141
|
-
ensure_db_store
|
|
142
|
-
model_class.find(:all).each do |obj|
|
|
143
|
-
if obj.image_file_data && obj.image_file_data.any?
|
|
144
|
-
File.open(obj.file_path, 'wb+') do |f|
|
|
145
|
-
f.write obj.image_file_data
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
puts "--- All images successfully moved to the file system. Remember to remove your image_file_data field from your models database table."
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
end
|
|
154
|
-
end
|
|
File without changes
|