fixed path to zoomifyViewer.swf

This commit is contained in:
Donald Ball 2008-11-24 22:18:47 -06:00
parent b9bd5edb17
commit 5443ab9f63
2 changed files with 14 additions and 5 deletions

View File

@ -2,11 +2,14 @@ module Zoomifier
module ViewHelpers
def zoomify_image_tag(source, options = {})
raise ArgumentError unless [:id, :width, :height].all? {|o| options[o] }
if File.file?(path = RAILS_ROOT + '/public/images/' + source)
Zoomifier::zoomify(path)
end
s = content_tag :div, { :id => options[:id] } do
image_tag source, options.merge({ :id => nil })
end
zoomify_path = image_path(source).gsub(/\.[^.]+$/, '')
s += javascript_tag "swfobject.embedSWF('/swf/zoomifyViewer.swf', '#{options[:id]}', '#{options[:width]}', '#{options[:height]}', '9.0.0', false, { zoomifyImagePath: '#{zoomify_path}/' });"
s += javascript_tag "swfobject.embedSWF('/swfs/zoomifyViewer.swf', '#{options[:id]}', '#{options[:width]}', '#{options[:height]}', '9.0.0', false, { zoomifyImagePath: '#{zoomify_path}/' });"
s
end
end

View File

@ -19,9 +19,6 @@ end
describe Zoomifier::ViewHelpers, "when included into ActionView" do
before(:all) do
ActionView::Base.send :include, Zoomifier::ViewHelpers
end
before(:each) do
@view = ActionView::Base.new
end
@ -37,7 +34,16 @@ describe Zoomifier::ViewHelpers, "when included into ActionView" do
@view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar', :width => 800, :height => 500 }).should ==
'<div id="foo"><img alt="Foo Bar" height="500" src="/images/foo.jpg" width="800" /></div>' +
"<script type=\"text/javascript\">\n//<![CDATA[\n" +
"swfobject.embedSWF('/swf/zoomifyViewer.swf', 'foo', '800', '500', '9.0.0', false, { zoomifyImagePath: '/images/foo/' });\n//]]>\n" +
"swfobject.embedSWF('/swfs/zoomifyViewer.swf', 'foo', '800', '500', '9.0.0', false, { zoomifyImagePath: '/images/foo/' });\n//]]>\n" +
'</script>'
end
it "should automatically zoomify an image" do
FileUtils.copy(File.dirname(__FILE__) + '/data/1024x768.jpg', RAILS_ROOT + '/public/images/')
File.directory?(RAILS_ROOT + '/public/images/1024x768/').should be_false
@view.zoomify_image_tag('1024x768.jpg', {:id => 'foo', :alt => 'Foo Bar', :width => 400, :height => 300 })
File.directory?(RAILS_ROOT + '/public/images/1024x768/').should be_true
FileUtils.rm_rf(RAILS_ROOT + '/public/images/1024x768/')
File.delete(RAILS_ROOT + '/public/images/1024x768.jpg')
end
end