fixed path to zoomifyViewer.swf
This commit is contained in:
parent
b9bd5edb17
commit
5443ab9f63
@ -2,11 +2,14 @@ module Zoomifier
|
|||||||
module ViewHelpers
|
module ViewHelpers
|
||||||
def zoomify_image_tag(source, options = {})
|
def zoomify_image_tag(source, options = {})
|
||||||
raise ArgumentError unless [:id, :width, :height].all? {|o| options[o] }
|
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
|
s = content_tag :div, { :id => options[:id] } do
|
||||||
image_tag source, options.merge({ :id => nil })
|
image_tag source, options.merge({ :id => nil })
|
||||||
end
|
end
|
||||||
zoomify_path = image_path(source).gsub(/\.[^.]+$/, '')
|
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
|
s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,9 +19,6 @@ end
|
|||||||
describe Zoomifier::ViewHelpers, "when included into ActionView" do
|
describe Zoomifier::ViewHelpers, "when included into ActionView" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
ActionView::Base.send :include, Zoomifier::ViewHelpers
|
ActionView::Base.send :include, Zoomifier::ViewHelpers
|
||||||
end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
@view = ActionView::Base.new
|
@view = ActionView::Base.new
|
||||||
end
|
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 ==
|
@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>' +
|
'<div id="foo"><img alt="Foo Bar" height="500" src="/images/foo.jpg" width="800" /></div>' +
|
||||||
"<script type=\"text/javascript\">\n//<![CDATA[\n" +
|
"<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>'
|
'</script>'
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user