Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki

This commit is contained in:
Jacques Distler 2010-01-03 13:23:26 -06:00
commit 0cfea84802
11 changed files with 57 additions and 24 deletions

View file

@ -155,6 +155,7 @@ module WikiChunk
if web_match if web_match
@web_name = normalize_whitespace(web_match[1]) @web_name = normalize_whitespace(web_match[1])
@page_name = web_match[2] @page_name = web_match[2]
@link_text = @page_name if @link_text == web_match[0]
end end
end end

View file

@ -180,7 +180,8 @@ class UrlGenerator < AbstractUrlGenerator
action = web.published? && (web != @web || [:publish, :s5].include?(mode) ) ? 'published' : 'show' action = web.published? && (web != @web || [:publish, :s5].include?(mode) ) ? 'published' : 'show'
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action,
:id => name, :only_path => true :id => name, :only_path => true
%{<a class="existingWikiWord" href="#{href}">#{text}</a>} title = web == @web ? '' : %{ title="#{web_address}"}
%{<a class="existingWikiWord" href="#{href}"#{title}>#{text}</a>}
end end
def html_ext def html_ext

View file

@ -380,6 +380,10 @@ a,li span {
color:#000; color:#000;
} }
a.existingWikiWord[title]{
border: 1px dashed #000;
}
a:hover,a.nav:hover, a:hover math { a:hover,a.nav:hover, a:hover math {
background-color:#000; background-color:#000;
color:#FFF; color:#FFF;

View file

@ -60,4 +60,10 @@ liquor:
updated_at: <%= 40.minutes.ago.to_formatted_s(:db) %> updated_at: <%= 40.minutes.ago.to_formatted_s(:db) %>
web_id: 1 web_id: 1
name: liquor name: liquor
instiki_page:
id: 10
created_at: <%= Time.local(2004, 4, 4, 16, 50).to_formatted_s(:db) %>
updated_at: <%= Time.local(2004, 4, 4, 16, 50).to_formatted_s(:db) %>
web_id: 2
name: HomePage

View file

@ -90,4 +90,14 @@ liquor_first_revision:
page_id: 9 page_id: 9
content: "[[!redirects booze]]\n Drinky-poo. [[Instiki:HomePage|go there]]" content: "[[!redirects booze]]\n Drinky-poo. [[Instiki:HomePage|go there]]"
author: Guest author: Guest
ip: 127.0.0.2 ip: 127.0.0.2
instiki_home_page_first_revision:
id: 11
created_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
updated_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
revised_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
page_id: 10
content: First revision of the HomePage end
author: AnAuthor
ip: 127.0.0.1

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require Rails.root.join('test', 'test_helper')
require 'file_controller' require 'file_controller'
require 'fileutils' require 'fileutils'
require 'stringio' require 'stringio'

View file

@ -4,7 +4,7 @@
# commiting to SVN # commiting to SVN
# $INSTIKI_TEST_PDFLATEX = true # $INSTIKI_TEST_PDFLATEX = true
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require Rails.root.join('test', 'test_helper')
require 'wiki_controller' require 'wiki_controller'
require 'rexml/document' require 'rexml/document'
require 'tempfile' require 'tempfile'
@ -361,13 +361,13 @@ class WikiControllerTest < ActionController::TestCase
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
r = process('show', 'web' => 'wiki1', 'id' => 'liquor') r = process('show', 'web' => 'wiki1', 'id' => 'liquor')
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
Web.find_by_address('instiki').update_attribute(:published, true) Web.find_by_address('instiki').update_attribute(:published, true)
@ -375,13 +375,13 @@ class WikiControllerTest < ActionController::TestCase
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
r = process('show', 'web' => 'wiki1', 'id' => 'liquor') r = process('show', 'web' => 'wiki1', 'id' => 'liquor')
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
set_web_property :published, false set_web_property :published, false
@ -389,7 +389,7 @@ class WikiControllerTest < ActionController::TestCase
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
Web.find_by_address('instiki').update_attribute(:published, false) Web.find_by_address('instiki').update_attribute(:published, false)
@ -397,7 +397,7 @@ class WikiControllerTest < ActionController::TestCase
assert_response(:success) assert_response(:success)
assert_equal @liquor, r.template_objects['page'] assert_equal @liquor, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
end end

View file

@ -2,7 +2,7 @@ ENV['RAILS_ENV'] = 'test'
# Expand the path to environment so that Ruby does not load it multiple times # Expand the path to environment so that Ruby does not load it multiple times
# File.expand_path can be removed if Ruby 1.9 is in use. # File.expand_path can be removed if Ruby 1.9 is in use.
require File.expand_path(File.dirname(__FILE__) + '/../config/environment') require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'test_help' require 'test_help'
require 'wiki_content' require 'wiki_content'
@ -20,7 +20,7 @@ class ActiveSupport::TestCase
self.pre_loaded_fixtures = false self.pre_loaded_fixtures = false
self.use_transactional_fixtures = true self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false self.use_instantiated_fixtures = false
self.fixture_path = File.dirname(__FILE__) + "/fixtures/" self.fixture_path = Rails.root.join('test', 'fixtures', '')
end end
# activate PageObserver # activate PageObserver
@ -28,7 +28,7 @@ PageObserver.instance
class Test::Unit::TestCase class Test::Unit::TestCase
def create_fixtures(*table_names) def create_fixtures(*table_names)
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names) Fixtures.create_fixtures(Rails.root.join('test', 'fixtures'), table_names)
end end
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
@ -128,16 +128,21 @@ 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 (target contains a '.'):</b> #{name}</span>} if name.include?('.') 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 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>}
else %{<span class="newWikiWord">#{text}</span>} end else %{<span class="newWikiWord">#{text}</span>} end
when :publish when :publish
if known_page then %{<a class="existingWikiWord" href="../published/#{link}">#{text}</a>} if known_page then %{<a class="existingWikiWord" href="../published/#{link}"#{title}>#{text}</a>}
else %{<span class="newWikiWord">#{text}</span>} end else %{<span class="newWikiWord">#{text}</span>} end
else else
if known_page if known_page
%{<a class="existingWikiWord" href="../show/#{link}">#{text}</a>} if web_address == 'instiki'
%{<a class="existingWikiWord" href="../../#{web_address}/show/#{link}"#{title}>#{text}</a>}
else
%{<a class="existingWikiWord" href="../show/#{link}"#{title}>#{text}</a>}
end
else else
if web_address == 'instiki' if web_address == 'instiki'
%{<span class="newWikiWord">#{text}<a href="../../#{web_address}/show/#{link}">?</a></span>} %{<span class="newWikiWord">#{text}<a href="../../#{web_address}/show/#{link}">?</a></span>}

View file

@ -1,7 +1,7 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# encoding: UTF-8 # encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require Rails.root.join('test', 'test_helper')
require 'chunks/wiki' require 'chunks/wiki'
class WikiTest < Test::Unit::TestCase class WikiTest < Test::Unit::TestCase
@ -115,7 +115,7 @@ class WikiTest < Test::Unit::TestCase
# empty link type # empty link type
assert_link_parsed_as 'page name', 'link?:', :show, '[[page name|link?:]]' assert_link_parsed_as 'page name', 'link?:', :show, '[[page name|link?:]]'
# unknown link type # unknown link type
assert_link_parsed_as 'create_system', 'page name:create_system', :show, assert_link_parsed_as 'create_system', 'create_system', :show,
'[[page name:create_system]]' '[[page name:create_system]]'
end end

View file

@ -1,7 +1,7 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# encoding: UTF-8 # encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require Rails.root.join('test', 'test_helper')
class PageRendererTest < ActiveSupport::TestCase class PageRendererTest < ActiveSupport::TestCase
fixtures :webs, :pages, :revisions, :system, :wiki_references fixtures :webs, :pages, :revisions, :system, :wiki_references
@ -662,10 +662,16 @@ END_THM
def test_wiki_link_with_colon def test_wiki_link_with_colon
assert_markup_parsed_as( assert_markup_parsed_as(
"<p><span class='newWikiWord'>Instiki:Colon<a href='../../instiki/show/Colon'>?</a></span></p>", "<p><a class='existingWikiWord' href='../show/HomePage'>HomePage</a></p>",
'[[Instiki:Colon]]') '[[wiki1:HomePage]]')
end end
def test_wiki_link_with_colon_interwiki
assert_markup_parsed_as(
"<p><a class='existingWikiWord' href='../../instiki/show/HomePage' title='instiki'>HomePage</a></p>",
'[[instiki:HomePage]]')
end
def test_list_with_tildas def test_list_with_tildas
list_with_tildas = <<-EOL list_with_tildas = <<-EOL
* [a](~b) * [a](~b)

View file

@ -14,7 +14,7 @@ class WebTest < ActiveSupport::TestCase
def test_pages_by_match def test_pages_by_match
add_sample_pages add_sample_pages
assert_equal 2, @web.select { |page| page.content =~ /me/i }.length assert_equal 3, @web.select { |page| page.content =~ /me/i }.length
assert_equal 1, @web.select { |page| page.content =~ /Who/i }.length assert_equal 1, @web.select { |page| page.content =~ /Who/i }.length
assert_equal 0, @web.select { |page| page.content =~ /none/i }.length assert_equal 0, @web.select { |page| page.content =~ /none/i }.length
end end
@ -27,9 +27,9 @@ class WebTest < ActiveSupport::TestCase
def test_delete def test_delete
add_sample_pages add_sample_pages
assert_equal 2, @web.pages.length assert_equal 3, @web.pages.length
@web.remove_pages([ @web.page('EverBeenInLove') ]) @web.remove_pages([ @web.page('EverBeenInLove') ])
assert_equal 1, @web.pages(true).length assert_equal 2, @web.pages(true).length
end end
def test_initialize def test_initialize