Sync with trunk
This commit is contained in:
commit
f785655a59
5 changed files with 24 additions and 12 deletions
|
@ -47,6 +47,11 @@ class Web < ActiveRecord::Base
|
||||||
WikiFile.find_by_file_name(file_name) != nil
|
WikiFile.find_by_file_name(file_name) != nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description(file_name)
|
||||||
|
file = WikiFile.find_by_file_name(file_name)
|
||||||
|
file.description if file
|
||||||
|
end
|
||||||
|
|
||||||
def markup
|
def markup
|
||||||
read_attribute('markup').to_sym
|
read_attribute('markup').to_sym
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{ 'multipart' => true , 'accept-charset' => 'utf-8' }) do %>
|
{ 'multipart' => true , 'accept-charset' => 'utf-8' }) do %>
|
||||||
<div class="inputFieldWithPrompt">
|
<div class="inputFieldWithPrompt">
|
||||||
<%= hidden_field 'file', 'file_name' %>
|
<%= hidden_field 'file', 'file_name' %>
|
||||||
<label for="file_content"><b>Content of <%= h @file_name %> to upload</b> (required):</label>
|
<label for="file_content"><b>Content of <%= h @file_name %> to upload</b>:</label>
|
||||||
<br />
|
<br />
|
||||||
<input type="file" id="file_content" name="file[content]" size="40" />
|
<input type="file" id="file_content" name="file[content]" size="40" />
|
||||||
<br />
|
<br />
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<%= link_to :back %> and edit the wiki page that refers to the file.
|
<%= link_to :back %> and edit the wiki page that refers to the file.
|
||||||
</div>
|
</div>
|
||||||
<div class="inputFieldWithPrompt">
|
<div class="inputFieldWithPrompt">
|
||||||
<label for="file_description"><b>Description</b> (optional):</label>
|
<label for="file_description"><b>Description</b>:</label>
|
||||||
<br/>
|
<br/>
|
||||||
<%= text_field "file", "description", "size" => 40 %>
|
<%= text_field "file", "description", "size" => 40 %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -17,7 +16,14 @@ class AbstractUrlGenerator
|
||||||
known_page = web.has_page?(name)
|
known_page = web.has_page?(name)
|
||||||
else
|
else
|
||||||
known_page = web.has_file?(name)
|
known_page = web.has_file?(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
|
||||||
|
@ -41,7 +47,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class="existingWikiWord" 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
|
||||||
|
@ -49,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" 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
|
||||||
|
@ -57,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" 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
|
||||||
|
|
|
@ -106,14 +106,14 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
link = CGI.escape(name)
|
link = CGI.escape(name)
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_file then %{<a class="existingWikiWord" href="#{link}.html">#{text}</a>}
|
if known_file then %{<a class="existingWikiWord" title="#{title}" href="#{link}.html">#{text}</a>}
|
||||||
else %{<span class="newWikiWord">#{text}</span>} end
|
else %{<span class="newWikiWord">#{text}</span>} end
|
||||||
when :publish
|
when :publish
|
||||||
if known_file then %{<a class="existingWikiWord" href="../published/#{link}">#{text}</a>}
|
if known_file then %{<a class="existingWikiWord" title="#{title}" href="../published/#{link}">#{text}</a>}
|
||||||
else %{<span class=\"newWikiWord\">#{text}</span>} end
|
else %{<span class=\"newWikiWord\">#{text}</span>} end
|
||||||
else
|
else
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class=\"existingWikiWord\" href=\"../file/#{link}\">#{text}</a>}
|
%{<a class=\"existingWikiWord\" title="#{title}" href=\"../file/#{link}\">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class=\"newWikiWord\">#{text}<a href=\"../file/#{link}\">?</a></span>}
|
%{<span class=\"newWikiWord\">#{text}<a href=\"../file/#{link}\">?</a></span>}
|
||||||
end
|
end
|
||||||
|
@ -144,6 +144,7 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
|
|
||||||
def pic_link(mode, name, text, web_name, known_pic)
|
def pic_link(mode, name, text, web_name, known_pic)
|
||||||
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="#{text}" src="#{link}" />}
|
if known_pic then %{<img alt="#{text}" src="#{link}" />}
|
||||||
|
|
|
@ -305,10 +305,10 @@ class PageRendererTest < Test::Unit::TestCase
|
||||||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||||
@web.wiki_files.create(:file_name => 'square.jpg', :description => 'Square', :content => 'never mind')
|
@web.wiki_files.create(:file_name => 'square.jpg', :description => 'Square', :content => 'never mind')
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
'<p><img alt="Blue Square" src="../file/square.jpg" /></p>',
|
||||||
'[[square.jpg|Square:pic]]')
|
'[[square.jpg|Blue Square:pic]]')
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
'<p><img alt="square.jpg" src="../file/square.jpg" /></p>',
|
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
||||||
'[[square.jpg:pic]]')
|
'[[square.jpg:pic]]')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue