Fix Broken Test
Was not picking up user-supplied alt text in [[filename|Alt text:pic]]. Fixed.
This commit is contained in:
parent
402de89abf
commit
fbdf4c5dfe
|
@ -9,7 +9,6 @@ class AbstractUrlGenerator
|
||||||
# on the render mode in options and whether the page (file) exists
|
# on the render mode in options and whether the page (file) exists
|
||||||
# in the web.
|
# in the web.
|
||||||
def make_link(name, web, text = nil, options = {})
|
def make_link(name, web, text = nil, options = {})
|
||||||
text = CGI.escapeHTML(text || WikiWords.separate(name))
|
|
||||||
mode = (options[:mode] || :show).to_sym
|
mode = (options[:mode] || :show).to_sym
|
||||||
link_type = (options[:link_type] || :show).to_sym
|
link_type = (options[:link_type] || :show).to_sym
|
||||||
|
|
||||||
|
@ -19,14 +18,20 @@ class AbstractUrlGenerator
|
||||||
known_page = web.has_file?(name)
|
known_page = web.has_file?(name)
|
||||||
description = web.description(name)
|
description = web.description(name)
|
||||||
end
|
end
|
||||||
|
if (text == name)
|
||||||
|
text = description || text
|
||||||
|
else
|
||||||
|
text = text || description
|
||||||
|
end
|
||||||
|
text = CGI.escapeHTML(CGI.unescapeHTML(text || WikiWords.separate(name)))
|
||||||
|
|
||||||
case link_type
|
case link_type
|
||||||
when :show
|
when :show
|
||||||
page_link(mode, name, text, web.address, known_page)
|
page_link(mode, name, text, web.address, known_page)
|
||||||
when :file
|
when :file
|
||||||
file_link(mode, name, text, web.address, known_page, description)
|
file_link(mode, name, text, web.address, known_page)
|
||||||
when :pic
|
when :pic
|
||||||
pic_link(mode, name, text, web.address, known_page, description)
|
pic_link(mode, name, text, web.address, known_page)
|
||||||
else
|
else
|
||||||
raise "Unknown link type: #{link_type}"
|
raise "Unknown link type: #{link_type}"
|
||||||
end
|
end
|
||||||
|
@ -38,12 +43,11 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_link(mode, name, text, web_address, known_file, description)
|
def file_link(mode, name, text, web_address, known_file)
|
||||||
title = CGI::escapeHTML(CGI::unescapeHTML( description || text))
|
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class="existingWikiWord" title="#{title}" href="#{CGI.escape(name)}.html">#{text}</a>}
|
%{<a class="existingWikiWord" title="#{text}" href="#{CGI.escape(name)}.html">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}</span>}
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
end
|
end
|
||||||
|
@ -51,7 +55,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
if known_file
|
if known_file
|
||||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||||
:id => name
|
:id => name
|
||||||
%{<a class="existingWikiWord" title="#{title}" href="#{href}">#{text}</a>}
|
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}</span>}
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
end
|
end
|
||||||
|
@ -59,7 +63,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||||
:id => name
|
:id => name
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class="existingWikiWord" title="#{title}" href="#{href}">#{text}</a>}
|
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
||||||
end
|
end
|
||||||
|
@ -95,18 +99,17 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pic_link(mode, name, text, web_address, known_pic, description)
|
def pic_link(mode, name, text, web_address, known_pic)
|
||||||
alt_text = CGI::escapeHTML(CGI::unescapeHTML( description || text))
|
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_pic
|
if known_pic
|
||||||
%{<img alt="#{alt_text}" src="#{CGI.escape(name)}" />}
|
%{<img alt="#{text}" src="#{CGI.escape(name)}" />}
|
||||||
else
|
else
|
||||||
%{<img alt="#{text}" src="no image" />}
|
%{<img alt="#{text}" src="no image" />}
|
||||||
end
|
end
|
||||||
when :publish
|
when :publish
|
||||||
if known_pic
|
if known_pic
|
||||||
%{<img alt="#{alt_text}" src="#{CGI.escape(name)}" />}
|
%{<img alt="#{text}" src="#{CGI.escape(name)}" />}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}</span>}
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
end
|
end
|
||||||
|
@ -114,7 +117,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||||
:id => name
|
:id => name
|
||||||
if known_pic
|
if known_pic
|
||||||
%{<img alt="#{alt_text}" src="#{href}" />}
|
%{<img alt="#{text}" src="#{href}" />}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,8 +102,7 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
super(:doesnt_need_controller)
|
super(:doesnt_need_controller)
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_link(mode, name, text, web_name, known_file, description)
|
def file_link(mode, name, text, web_name, known_file)
|
||||||
title = CGI::escapeHTML(CGI::unescapeHTML( description || text))
|
|
||||||
link = CGI.escape(name)
|
link = CGI.escape(name)
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
|
@ -143,18 +142,18 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pic_link(mode, name, text, web_name, known_pic, description)
|
def pic_link(mode, name, text, web_name, known_pic)
|
||||||
alt_text = CGI::escapeHTML(CGI::unescapeHTML( description || text))
|
|
||||||
link = CGI.escape(name)
|
link = CGI.escape(name)
|
||||||
|
text = CGI.escapeHTML(CGI.unescapeHTML(text || :description))
|
||||||
case mode.to_sym
|
case mode.to_sym
|
||||||
when :export
|
when :export
|
||||||
if known_pic then %{<img alt="#{alt_text}" src="#{link}" />}
|
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||||
else %{<img alt="#{text}" src="no image" />} end
|
else %{<img alt="#{text}" src="no image" />} end
|
||||||
when :publish
|
when :publish
|
||||||
if known_pic then %{<img alt="#{alt_text}" src="#{link}" />}
|
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||||
else %{<span class="newWikiWord">#{text}</span>} end
|
else %{<span class="newWikiWord">#{text}</span>} end
|
||||||
else
|
else
|
||||||
if known_pic then %{<img alt="#{alt_text}" src="../file/#{link}" />}
|
if known_pic then %{<img alt="#{text}" src="../file/#{link}" />}
|
||||||
else %{<span class="newWikiWord">#{text}<a href="../file/#{link}">?</a></span>} end
|
else %{<span class="newWikiWord">#{text}<a href="../file/#{link}">?</a></span>} end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue