Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
3a9d1596d2
8 changed files with 11 additions and 40 deletions
|
@ -292,13 +292,11 @@ EOL
|
|||
the_content = params['content'].purify
|
||||
prev_content = ''
|
||||
filter_spam(the_content)
|
||||
raise Instiki::ValidationError.new('Your name cannot contain a "."') if author_name.include? '.'
|
||||
cookies['author'] = { :value => author_name.dup.as_bytes, :expires => Time.utc(2030) }
|
||||
if @page
|
||||
new_name = params['new_name'] ? params['new_name'].purify : @page_name
|
||||
new_name = @page_name if new_name.empty?
|
||||
prev_content = @page.current_revision.content
|
||||
raise Instiki::ValidationError.new('Your new title cannot contain a "."') if new_name.include? '.'
|
||||
raise Instiki::ValidationError.new('A page named "' + new_name.escapeHTML + '" already exists.') if
|
||||
@page_name != new_name && @web.has_page?(new_name)
|
||||
wiki.revise_page(@web_name, @page_name, new_name, the_content, Time.now,
|
||||
|
|
|
@ -30,7 +30,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
connect_to_web map, ':web/revision/:id/:rev', :controller => 'wiki', :action => 'revision', :requirements => { :rev => /\d*/}
|
||||
connect_to_web map, ':web/list/:category', :controller => 'wiki', :action => 'list', :requirements => { :category => /.*/}, :category => nil
|
||||
connect_to_web map, ':web/recently_revised/:category', :controller => 'wiki', :action => 'recently_revised', :requirements => { :category => /.*/}, :category => nil
|
||||
connect_to_web map, ':web/:action/:id', :controller => 'wiki'
|
||||
connect_to_web map, ':web/:action/:id', :controller => 'wiki', :requirements => {:id => /.*/}
|
||||
connect_to_web map, ':web/:action', :controller => 'wiki'
|
||||
connect_to_web map, ':web', :controller => 'wiki', :action => 'index'
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
end
|
||||
|
||||
def page_link(mode, name, text, web_address, known_page)
|
||||
return %{<span class='wikilink-error'><b>Illegal link (target contains a '.'):</b> #{name}</span>} if name.include?('.')
|
||||
case mode
|
||||
when :export
|
||||
if known_page
|
||||
|
|
|
@ -412,16 +412,6 @@ margin:0;
|
|||
padding:0;
|
||||
}
|
||||
|
||||
span.wikilink-error {
|
||||
border: solid 2px red;
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
span.wikilink-error b {
|
||||
font-size: 80%;
|
||||
color: #009;
|
||||
}
|
||||
|
||||
textarea#content {
|
||||
font-size: 1em;
|
||||
line-height: 1.125;
|
||||
|
|
|
@ -12,7 +12,10 @@ class RoutesTest < ActionController::TestCase
|
|||
assert_routing('x/y', :controller => 'wiki', :web => 'x', :action => 'y')
|
||||
assert_routing('x/y/z', :controller => 'wiki', :web => 'x', :action => 'y', :id => 'z')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y'}, 'x/y/')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z'}, 'x/y/z/')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z'}, 'x/y/z')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z/'}, 'x/y/z/')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z/'}, 'x/y/z%2F')
|
||||
assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z.w'}, 'x/y/z.w')
|
||||
end
|
||||
|
||||
def test_parse_uri_interestng_cases
|
||||
|
|
|
@ -833,37 +833,19 @@ class WikiControllerTest < ActionController::TestCase
|
|||
assert_equal 'AnonymousCoward', another_page.author
|
||||
end
|
||||
|
||||
def test_save_revised_content_invalid_author_name
|
||||
def test_save_revised_content_author_name_with_period
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'Contents of a very new page',
|
||||
'author' => 'foo.bar'
|
||||
assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage',
|
||||
:content => 'Contents of a very new page'
|
||||
assert r.flash[:error].to_s == 'Your name cannot contain a "."'
|
||||
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'a'*10184,
|
||||
'author' => 'foo.bar'
|
||||
assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage'
|
||||
assert r.flash[:error].to_s == 'Your name cannot contain a "."'
|
||||
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page',
|
||||
'author' => 'foo.bar'
|
||||
assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage',
|
||||
:content => 'Contents of a new page'
|
||||
assert r.flash[:error].to_s == 'Your name cannot contain a "."'
|
||||
assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage'
|
||||
assert_equal 'foo.bar', @wiki.read_page('wiki1', 'HomePage').author
|
||||
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'a'*10184,
|
||||
'author' => 'foo.bar'
|
||||
assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage'
|
||||
assert r.flash[:error].to_s == 'Your name cannot contain a "."'
|
||||
assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage'
|
||||
assert_equal 'foo.bar', @wiki.read_page('wiki1', 'NewPage').author
|
||||
end
|
||||
|
||||
def test_save_invalid_author_name
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page',
|
||||
'author' => 'foo.bar'
|
||||
assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage',
|
||||
:content => 'Contents of a new page'
|
||||
assert r.flash[:error].to_s == 'Your name cannot contain a "."'
|
||||
|
||||
r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page',
|
||||
'author' => "Fu\000Manchu"
|
||||
|
||||
|
|
|
@ -131,7 +131,6 @@ class StubUrlGenerator < AbstractUrlGenerator
|
|||
|
||||
def page_link(mode, name, text, web_address, known_page)
|
||||
link = CGI.escape(name)
|
||||
return %{<span class='wikilink-error'><b>Illegal link (target contains a '.'):</b> #{name}</span>} if name.include?('.')
|
||||
title = web_address == 'wiki1' ? '' : " title='#{web_address}'"
|
||||
case mode
|
||||
when :export
|
||||
|
|
|
@ -172,7 +172,7 @@ class PageTest < ActiveSupport::TestCase
|
|||
"<p>Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>H\303\241ppy Page</a>"
|
||||
assert_equal( s +
|
||||
" and to <span class='newWikiWord'>Wanted Page2<a href='../show/WantedPage2'>?</a></span>.pdf " +
|
||||
"and <span class='wikilink-error'><b>Illegal link (target contains a '.'):</b> foo.pdf</span></p>",
|
||||
"and <span class='newWikiWord'>foo.pdf<a href='../show/foo.pdf'>?</a></span></p>",
|
||||
x_test_renderer(new_page.revisions.last).display_content(true) )
|
||||
assert_equal 3, references.size
|
||||
# now it works.
|
||||
|
|
Loading…
Reference in a new issue