forked from AlexJWayne/fleximage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.rb
48 lines (40 loc) · 1.3 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'open-uri'
require 'base64'
# Load RMagick
begin
require 'RMagick'
rescue MissingSourceFile => e
puts %{ERROR :: FlexImage requires the RMagick gem. http://rmagick.rubyforge.org/install-faq.html}
raise e
end
# Load dsl_accessor from lib
require 'dsl_accessor'
# Load Operators
require 'fleximage/operator/base'
Dir.entries("#{File.dirname(__FILE__)}/lib/fleximage/operator").each do |filename|
require "fleximage/operator/#{filename.gsub('.rb', '')}" if filename =~ /\.rb$/
end
# Setup Model
require 'fleximage/model'
ActiveRecord::Base.class_eval { include Fleximage::Model }
# Image Proxy
require 'fleximage/image_proxy'
# Setup View
ActionController::Base.exempt_from_layout :flexi
if defined?(ActionView::Template)
# Rails >= 2.1
require 'fleximage/view'
ActionView::Template.register_template_handler :flexi, Fleximage::View
else
# Rails < 2.1
require 'fleximage/legacy_view'
ActionView::Base.register_template_handler :flexi, Fleximage::LegacyView
end
# Setup Helper
require 'fleximage/helper'
ActionView::Base.class_eval { include Fleximage::Helper }
# Register mime types
Mime::Type.register_alias "image/pjpeg", :jpg # IE6 sends jpg data as "image/pjpeg". Silly IE6.
Mime::Type.register "image/jpeg", :jpg
Mime::Type.register "image/gif", :gif
Mime::Type.register "image/png", :png