Uploaded Pictures Should Display in "Published" Mode
This commit is contained in:
parent
5a86d874f7
commit
1f816af24b
|
@ -105,6 +105,8 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
end
|
||||
|
||||
def pic_link(mode, name, text, web_address, known_pic)
|
||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||
:id => name
|
||||
case mode
|
||||
when :export
|
||||
if known_pic
|
||||
|
@ -114,13 +116,11 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
end
|
||||
when :publish
|
||||
if known_pic
|
||||
%{<img alt="#{text}" src="#{CGI.escape(name)}" />}
|
||||
%{<img alt="#{text}" src="#{href}" />}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}</span>}
|
||||
end
|
||||
else
|
||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||
:id => name
|
||||
if known_pic
|
||||
%{<img alt="#{text}" src="#{href}" />}
|
||||
else
|
||||
|
|
|
@ -104,6 +104,13 @@ class FileControllerTest < Test::Unit::TestCase
|
|||
:description => 'Rails, end-to-end'}
|
||||
assert @web.has_file?('rails-e2e.gif')
|
||||
assert_equal(picture, WikiFile.find_by_file_name('rails-e2e.gif').content)
|
||||
PageRenderer.setup_url_generator(StubUrlGenerator.new)
|
||||
@wiki.revise_page('wiki1', 'HomePage', 'Try [[rails-e2e.gif:pic]] again.',
|
||||
Time.now, 'AnonymousBrave', renderer)
|
||||
assert_equal "<p>Try <img alt='Rails, end-to-end' src='../file/rails-e2e.gif'/> again.</p>",
|
||||
renderer.display_content
|
||||
assert_equal "<p>Try <img alt='Rails, end-to-end' src='../file/rails-e2e.gif'/> again.</p>",
|
||||
renderer.display_published
|
||||
end
|
||||
|
||||
def test_import
|
||||
|
|
|
@ -154,7 +154,7 @@ class StubUrlGenerator < AbstractUrlGenerator
|
|||
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||
else %{<img alt="#{text}" src="no image" />} end
|
||||
when :publish
|
||||
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||
if known_pic then %{<img alt="#{text}" src="../file/#{link}" />}
|
||||
else %{<span class="newWikiWord">#{text}</span>} end
|
||||
else
|
||||
if known_pic then %{<img alt="#{text}" src="../file/#{link}" />}
|
||||
|
|
Loading…
Reference in a new issue