Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
89757dccd4
4 changed files with 22 additions and 4 deletions
|
@ -87,6 +87,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_link(mode, name, text, web_address, known_page)
|
def page_link(mode, name, text, web_address, known_page)
|
||||||
|
return %{<span class='wikilink-error'><b>Illegal link (contains a '.'):</b> [[#{text}]]</span>} if text.include?('.')
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_page
|
if known_page
|
||||||
|
|
|
@ -393,6 +393,16 @@ margin:0;
|
||||||
padding:0;
|
padding:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.wikilink-error {
|
||||||
|
border: solid 2px red;
|
||||||
|
background-color: pink;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.wikilink-error b {
|
||||||
|
font-size: 80%;
|
||||||
|
color: #009;
|
||||||
|
}
|
||||||
|
|
||||||
merror {display:inline;font-size:1em;}
|
merror {display:inline;font-size:1em;}
|
||||||
math[display=block] {overflow:auto;}
|
math[display=block] {overflow:auto;}
|
||||||
math { white-space: nowrap }
|
math { white-space: nowrap }
|
||||||
|
|
|
@ -127,6 +127,7 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
|
|
||||||
def page_link(mode, name, text, web_address, known_page)
|
def page_link(mode, name, text, web_address, known_page)
|
||||||
link = CGI.escape(name)
|
link = CGI.escape(name)
|
||||||
|
return %{<span class='wikilink-error'><b>Illegal link (contains a '.'):</b> [[#{text}]]</span>} if text.include?('.')
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_page then %{<a class="existingWikiWord" href="#{link}.html">#{text}</a>}
|
if known_page then %{<a class="existingWikiWord" href="#{link}.html">#{text}</a>}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class PageTest < ActiveSupport::TestCase
|
||||||
def test_revise_changes_references_from_wanted_to_linked_for_redirected_pages
|
def test_revise_changes_references_from_wanted_to_linked_for_redirected_pages
|
||||||
web = Web.find(1)
|
web = Web.find(1)
|
||||||
new_page = Page.new(:web => web, :name => 'NewPage')
|
new_page = Page.new(:web => web, :name => 'NewPage')
|
||||||
new_page.revise('Reference to HappyPage, and to WantedPage2', 'NewPage', Time.now, 'AlexeyVerkhovsky',
|
new_page.revise('Reference to HappyPage, and to WantedPage2', 'NewPage', Time.local(2004, 4, 5, 17, 56), 'AlexeyVerkhovsky',
|
||||||
test_renderer)
|
test_renderer)
|
||||||
|
|
||||||
references = new_page.wiki_references(true)
|
references = new_page.wiki_references(true)
|
||||||
|
@ -156,15 +156,21 @@ class PageTest < ActiveSupport::TestCase
|
||||||
assert_equal 'WantedPage2', references[1].referenced_name
|
assert_equal 'WantedPage2', references[1].referenced_name
|
||||||
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
|
|
||||||
new_page.revise('Reference to HappyPage', 'NewPage', Time.now, 'AlexeyVerkhovsky',
|
new_page.revise('Reference to HappyPage and to WantedPage2.pdf and [[foo.pdf]]', 'NewPage', Time.now, 'AlexeyVerkhovsky',
|
||||||
test_renderer)
|
test_renderer)
|
||||||
references = new_page.wiki_references(true)
|
references = new_page.wiki_references(true)
|
||||||
assert_match( "Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>Happy Page</a>",
|
assert_equal( "<p>Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>Happy Page</a>" +
|
||||||
|
" and to <span class='newWikiWord'>Wanted Page2<a href='../show/WantedPage2'>?</a></span>.pdf " +
|
||||||
|
"and <span class='wikilink-error'><b>Illegal link (contains a '.'):</b> [[foo.pdf]]</span></p>",
|
||||||
test_renderer(new_page.revisions.last).display_content(true) )
|
test_renderer(new_page.revisions.last).display_content(true) )
|
||||||
assert_equal 1, references.size
|
assert_equal 3, references.size
|
||||||
# now it works.
|
# now it works.
|
||||||
assert_equal 'HappyPage', references[0].referenced_name
|
assert_equal 'HappyPage', references[0].referenced_name
|
||||||
assert_equal WikiReference::LINKED_PAGE, references[0].link_type
|
assert_equal WikiReference::LINKED_PAGE, references[0].link_type
|
||||||
|
assert_equal 'WantedPage2', references[1].referenced_name
|
||||||
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
|
assert_equal 'foo.pdf', references[2].referenced_name
|
||||||
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rollback
|
def test_rollback
|
||||||
|
|
Loading…
Reference in a new issue