Pimki 1.3.092 → 1.4.092
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +145 -131
- data/README-PIMKI +15 -5
- data/app/controllers/wiki.rb +167 -54
- data/app/models/author.rb +3 -3
- data/app/models/chunks/chunk.rb +3 -3
- data/app/models/chunks/engines.rb +18 -21
- data/app/models/chunks/include.rb +29 -29
- data/app/models/chunks/literal.rb +20 -20
- data/app/models/chunks/match.rb +19 -19
- data/app/models/chunks/nowiki.rb +31 -31
- data/app/models/chunks/nowiki_test.rb +14 -14
- data/app/models/chunks/test.rb +18 -18
- data/app/models/chunks/todo.rb +44 -23
- data/app/models/chunks/uri.rb +97 -97
- data/app/models/chunks/uri_test.rb +92 -92
- data/app/models/chunks/wiki.rb +4 -4
- data/app/models/chunks/wiki_symbols.rb +22 -22
- data/app/models/chunks/wiki_test.rb +36 -36
- data/app/models/page.rb +39 -7
- data/app/models/page_lock.rb +23 -23
- data/app/models/page_set.rb +72 -72
- data/app/models/page_test.rb +75 -75
- data/app/models/revision.rb +1 -1
- data/app/models/revision_test.rb +251 -251
- data/app/models/web.rb +19 -6
- data/app/models/web_test.rb +52 -52
- data/app/models/wiki_content.rb +131 -119
- data/app/models/wiki_service.rb +31 -16
- data/app/models/wiki_service_test.rb +15 -15
- data/app/models/wiki_words.rb +1 -1
- data/app/models/wiki_words_test.rb +12 -12
- data/app/views/bottom.rhtml +3 -3
- data/app/views/markdown_help.rhtml +15 -15
- data/app/views/menu.rhtml +20 -20
- data/app/views/navigation.rhtml +26 -26
- data/app/views/rdoc_help.rhtml +15 -15
- data/app/views/static_style_sheet.rhtml +237 -237
- data/app/views/style.rhtml +178 -178
- data/app/views/textile_help.rhtml +27 -27
- data/app/views/top.rhtml +7 -2
- data/app/views/wiki/authors.rhtml +15 -15
- data/app/views/wiki/bliki.rhtml +101 -101
- data/app/views/wiki/bliki_edit.rhtml +3 -0
- data/app/views/wiki/bliki_new.rhtml +3 -0
- data/app/views/wiki/bliki_revision.rhtml +90 -90
- data/app/views/wiki/edit.rhtml +12 -3
- data/app/views/wiki/edit_menu.rhtml +64 -47
- data/app/views/wiki/edit_web.rhtml +65 -18
- data/app/views/wiki/export.rhtml +14 -14
- data/app/views/wiki/feeds.rhtml +10 -10
- data/app/views/wiki/list.rhtml +17 -15
- data/app/views/wiki/locked.rhtml +13 -13
- data/app/views/wiki/login.rhtml +10 -10
- data/app/views/wiki/mind.rhtml +0 -1
- data/app/views/wiki/new.rhtml +8 -3
- data/app/views/wiki/new_system.rhtml +77 -77
- data/app/views/wiki/new_web.rhtml +63 -63
- data/app/views/wiki/page.rhtml +88 -82
- data/app/views/wiki/print.rhtml +15 -15
- data/app/views/wiki/published.rhtml +2 -1
- data/app/views/wiki/recently_revised.rhtml +31 -31
- data/app/views/wiki/revision.rhtml +1 -7
- data/app/views/wiki/rollback.rhtml +31 -0
- data/app/views/wiki/rss_feed.rhtml +21 -21
- data/app/views/wiki/search.rhtml +48 -48
- data/app/views/wiki/tex.rhtml +22 -22
- data/app/views/wiki/tex_web.rhtml +34 -34
- data/app/views/wiki/todo.rhtml +90 -67
- data/app/views/wiki/web_list.rhtml +12 -12
- data/app/views/wiki_words_help.rhtml +1 -1
- data/favicon.png +0 -0
- data/libraries/action_controller_servlet.rb +17 -2
- data/libraries/bluecloth.rb +1127 -1127
- data/libraries/diff/diff.rb +474 -474
- data/libraries/diff/diff_test.rb +79 -79
- data/libraries/erb.rb +490 -490
- data/libraries/madeleine/automatic.rb +418 -357
- data/libraries/madeleine/clock.rb +94 -94
- data/libraries/madeleine/files.rb +19 -0
- data/libraries/madeleine/zmarshal.rb +60 -0
- data/libraries/madeleine_service.rb +14 -15
- data/libraries/rdocsupport.rb +155 -155
- data/libraries/redcloth_for_tex.rb +869 -869
- data/libraries/redcloth_for_tex_test.rb +40 -40
- data/libraries/view_helper.rb +32 -32
- data/libraries/web_controller_server.rb +96 -94
- data/pimki.rb +47 -6
- metadata +18 -4
data/app/models/page_set.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
# Container for a set of pages with methods for manipulation.
|
2
|
-
class PageSet < Array
|
3
|
-
attr_reader :web
|
4
|
-
|
5
|
-
def initialize(web, pages, accept_proc)
|
6
|
-
@web = web
|
7
|
-
if accept_proc.nil? then
|
8
|
-
super(pages)
|
9
|
-
else
|
10
|
-
super(pages.select { |page| accept_proc[page] })
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def most_recent_revision
|
15
|
-
self.sort_by { |page| [page.created_at] }.reverse.first.created_at
|
16
|
-
end
|
17
|
-
|
18
|
-
def by_name
|
19
|
-
self.sort_by { |page| [page.name] }
|
20
|
-
end
|
21
|
-
|
22
|
-
def by_revision
|
23
|
-
self.sort_by { |page| [page.created_at] }.reverse
|
24
|
-
end
|
25
|
-
|
26
|
-
def by_last_visited #{{{
|
27
|
-
self.sort_by { |page| [page.last_visited] }.reverse
|
28
|
-
end #}}}
|
29
|
-
|
30
|
-
def by_most_viewed #{{{
|
31
|
-
self.sort_by { |page| [page.viewed] }.reverse
|
32
|
-
end #}}}
|
33
|
-
|
34
|
-
|
35
|
-
def pages_that_reference(page_name)
|
36
|
-
self.select { |page| page.wiki_words.include?(page_name) }
|
37
|
-
end
|
38
|
-
|
39
|
-
def pages_authored_by(author)
|
40
|
-
self.select { |page| page.authors.include?(author) }
|
41
|
-
end
|
42
|
-
|
43
|
-
def characters
|
44
|
-
self.inject(0) { |chars,page| chars += page.content.size }
|
45
|
-
end
|
46
|
-
|
47
|
-
# Returns all the orphaned pages in this page set. That is,
|
48
|
-
# pages in this set for which there is no reference in the web.
|
49
|
-
# The HomePage and author pages are always assumed to have
|
50
|
-
# references and so cannot be orphans
|
51
|
-
def orphaned_pages
|
52
|
-
references = web.select.wiki_words + ["HomePage"] + web.select.authors
|
53
|
-
self.reject { |page| references.include?(page.name) }
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns all the wiki words in this page set for which
|
57
|
-
# there are no pages in this page set's web
|
58
|
-
def wanted_pages
|
59
|
-
wiki_words - web.select.names
|
60
|
-
end
|
61
|
-
|
62
|
-
def names
|
63
|
-
self.map { |page| page.name }
|
64
|
-
end
|
65
|
-
|
66
|
-
def wiki_words
|
67
|
-
self.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
|
68
|
-
end
|
69
|
-
|
70
|
-
def authors
|
71
|
-
self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
|
72
|
-
end
|
1
|
+
# Container for a set of pages with methods for manipulation.
|
2
|
+
class PageSet < Array
|
3
|
+
attr_reader :web
|
4
|
+
|
5
|
+
def initialize(web, pages, accept_proc)
|
6
|
+
@web = web
|
7
|
+
if accept_proc.nil? then
|
8
|
+
super(pages)
|
9
|
+
else
|
10
|
+
super(pages.select { |page| accept_proc[page] })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def most_recent_revision
|
15
|
+
self.sort_by { |page| [page.created_at] }.reverse.first.created_at
|
16
|
+
end
|
17
|
+
|
18
|
+
def by_name
|
19
|
+
self.sort_by { |page| [page.name] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def by_revision
|
23
|
+
self.sort_by { |page| [page.created_at] }.reverse
|
24
|
+
end
|
25
|
+
|
26
|
+
def by_last_visited #{{{
|
27
|
+
self.sort_by { |page| [page.last_visited] }.reverse
|
28
|
+
end #}}}
|
29
|
+
|
30
|
+
def by_most_viewed #{{{
|
31
|
+
self.sort_by { |page| [page.viewed] }.reverse
|
32
|
+
end #}}}
|
33
|
+
|
34
|
+
|
35
|
+
def pages_that_reference(page_name)
|
36
|
+
self.select { |page| page.wiki_words.include?(page_name) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def pages_authored_by(author)
|
40
|
+
self.select { |page| page.authors.include?(author) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def characters
|
44
|
+
self.inject(0) { |chars,page| chars += page.content.size }
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns all the orphaned pages in this page set. That is,
|
48
|
+
# pages in this set for which there is no reference in the web.
|
49
|
+
# The HomePage and author pages are always assumed to have
|
50
|
+
# references and so cannot be orphans
|
51
|
+
def orphaned_pages
|
52
|
+
references = web.select.wiki_words + ["HomePage"] + web.select.authors
|
53
|
+
self.reject { |page| references.include?(page.name) }
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns all the wiki words in this page set for which
|
57
|
+
# there are no pages in this page set's web
|
58
|
+
def wanted_pages
|
59
|
+
wiki_words - web.select.names
|
60
|
+
end
|
61
|
+
|
62
|
+
def names
|
63
|
+
self.map { |page| page.name }
|
64
|
+
end
|
65
|
+
|
66
|
+
def wiki_words
|
67
|
+
self.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
|
68
|
+
end
|
69
|
+
|
70
|
+
def authors
|
71
|
+
self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
|
72
|
+
end
|
73
73
|
end
|
data/app/models/page_test.rb
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "web"
|
3
|
-
require "page"
|
4
|
-
|
5
|
-
class MockWeb < Web
|
6
|
-
def initialize() super('test','test') end
|
7
|
-
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
8
|
-
def refresh_pages_with_references(name) end
|
9
|
-
end
|
10
|
-
|
11
|
-
class PageTest < Test::Unit::TestCase
|
12
|
-
def setup
|
13
|
-
@page = Page.new(
|
14
|
-
MockWeb.new,
|
15
|
-
"FirstPage",
|
16
|
-
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
17
|
-
Time.local(2004, 4, 4, 16, 50),
|
18
|
-
"DavidHeinemeierHansson"
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_basics
|
23
|
-
assert_equal "First Page", @page.plain_name
|
24
|
-
assert_equal "April 4, 2004", @page.pretty_revised_on
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_locking
|
28
|
-
assert !@page.locked?(Time.local(2004, 4, 4, 16, 50))
|
29
|
-
|
30
|
-
@page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson")
|
31
|
-
|
32
|
-
assert @page.locked?(Time.local(2004, 4, 4, 16, 50))
|
33
|
-
assert !@page.locked?(Time.local(2004, 4, 4, 17, 1))
|
34
|
-
|
35
|
-
@page.unlock
|
36
|
-
|
37
|
-
assert !@page.locked?(Time.local(2004, 4, 4, 16, 50))
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_locking_duration
|
41
|
-
@page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson")
|
42
|
-
|
43
|
-
assert_equal 15, @page.lock_duration(Time.local(2004, 4, 4, 16, 45))
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_revision
|
47
|
-
@page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler")
|
48
|
-
assert_equal 2, @page.revisions.length, "Should have two revisions"
|
49
|
-
assert_equal "MarianneSyhler", @page.author, "Mary should be the author now"
|
50
|
-
assert_equal "DavidHeinemeierHansson", @page.revisions.first.author, "David was the first author"
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_rollback
|
54
|
-
@page.revise("spot two", Time.now, "David")
|
55
|
-
@page.revise("spot three", Time.now + 2000, "David")
|
56
|
-
assert_equal 3, @page.revisions.length, "Should have three revisions"
|
57
|
-
@page.rollback(1, Time.now)
|
58
|
-
assert_equal "spot two", @page.content
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_continous_revision
|
62
|
-
@page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler")
|
63
|
-
assert_equal 2, @page.revisions.length
|
64
|
-
|
65
|
-
@page.revise("HisWay would be MyWay in kinda update", Time.local(2004, 4, 4, 16, 57), "MarianneSyhler")
|
66
|
-
assert_equal 2, @page.revisions.length
|
67
|
-
assert_equal "HisWay would be MyWay in kinda update", @page.revisions.last.content
|
68
|
-
|
69
|
-
@page.revise("HisWay would be MyWay in the house", Time.local(2004, 4, 4, 16, 58), "DavidHeinemeierHansson")
|
70
|
-
assert_equal 3, @page.revisions.length
|
71
|
-
assert_equal "HisWay would be MyWay in the house", @page.revisions.last.content
|
72
|
-
|
73
|
-
@page.revise("HisWay would be MyWay in my way", Time.local(2004, 4, 4, 17, 30), "DavidHeinemeierHansson")
|
74
|
-
assert_equal 4, @page.revisions.length
|
75
|
-
end
|
1
|
+
require "test/unit"
|
2
|
+
require "web"
|
3
|
+
require "page"
|
4
|
+
|
5
|
+
class MockWeb < Web
|
6
|
+
def initialize() super('test','test') end
|
7
|
+
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
8
|
+
def refresh_pages_with_references(name) end
|
9
|
+
end
|
10
|
+
|
11
|
+
class PageTest < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@page = Page.new(
|
14
|
+
MockWeb.new,
|
15
|
+
"FirstPage",
|
16
|
+
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
17
|
+
Time.local(2004, 4, 4, 16, 50),
|
18
|
+
"DavidHeinemeierHansson"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_basics
|
23
|
+
assert_equal "First Page", @page.plain_name
|
24
|
+
assert_equal "April 4, 2004", @page.pretty_revised_on
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_locking
|
28
|
+
assert !@page.locked?(Time.local(2004, 4, 4, 16, 50))
|
29
|
+
|
30
|
+
@page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson")
|
31
|
+
|
32
|
+
assert @page.locked?(Time.local(2004, 4, 4, 16, 50))
|
33
|
+
assert !@page.locked?(Time.local(2004, 4, 4, 17, 1))
|
34
|
+
|
35
|
+
@page.unlock
|
36
|
+
|
37
|
+
assert !@page.locked?(Time.local(2004, 4, 4, 16, 50))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_locking_duration
|
41
|
+
@page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson")
|
42
|
+
|
43
|
+
assert_equal 15, @page.lock_duration(Time.local(2004, 4, 4, 16, 45))
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_revision
|
47
|
+
@page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler")
|
48
|
+
assert_equal 2, @page.revisions.length, "Should have two revisions"
|
49
|
+
assert_equal "MarianneSyhler", @page.author, "Mary should be the author now"
|
50
|
+
assert_equal "DavidHeinemeierHansson", @page.revisions.first.author, "David was the first author"
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_rollback
|
54
|
+
@page.revise("spot two", Time.now, "David")
|
55
|
+
@page.revise("spot three", Time.now + 2000, "David")
|
56
|
+
assert_equal 3, @page.revisions.length, "Should have three revisions"
|
57
|
+
@page.rollback(1, Time.now)
|
58
|
+
assert_equal "spot two", @page.content
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_continous_revision
|
62
|
+
@page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler")
|
63
|
+
assert_equal 2, @page.revisions.length
|
64
|
+
|
65
|
+
@page.revise("HisWay would be MyWay in kinda update", Time.local(2004, 4, 4, 16, 57), "MarianneSyhler")
|
66
|
+
assert_equal 2, @page.revisions.length
|
67
|
+
assert_equal "HisWay would be MyWay in kinda update", @page.revisions.last.content
|
68
|
+
|
69
|
+
@page.revise("HisWay would be MyWay in the house", Time.local(2004, 4, 4, 16, 58), "DavidHeinemeierHansson")
|
70
|
+
assert_equal 3, @page.revisions.length
|
71
|
+
assert_equal "HisWay would be MyWay in the house", @page.revisions.last.content
|
72
|
+
|
73
|
+
@page.revise("HisWay would be MyWay in my way", Time.local(2004, 4, 4, 17, 30), "DavidHeinemeierHansson")
|
74
|
+
assert_equal 4, @page.revisions.length
|
75
|
+
end
|
76
76
|
end
|
data/app/models/revision.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
|
2
3
|
require "diff/diff"
|
3
4
|
|
4
5
|
require "wiki_content"
|
@@ -65,7 +66,6 @@ class Revision
|
|
65
66
|
# Ensures new version works with older snapshots.
|
66
67
|
def display_content
|
67
68
|
unless @display_cache && @display_cache.respond_to?(:find_chunks)
|
68
|
-
#$stderr << "Rendering: #{page.name}\n"
|
69
69
|
@display_cache = WikiContent.new(self)
|
70
70
|
end
|
71
71
|
@display_cache
|
data/app/models/revision_test.rb
CHANGED
@@ -1,252 +1,252 @@
|
|
1
|
-
require "web"
|
2
|
-
require "test/unit"
|
3
|
-
require "revision"
|
4
|
-
|
5
|
-
class MockWeb < Web;
|
6
|
-
attr_accessor :markup
|
7
|
-
def pages() MockPages.new end
|
8
|
-
def safe_mode() false end
|
9
|
-
end
|
10
|
-
class MockPages
|
11
|
-
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
12
|
-
end
|
13
|
-
class MockPage
|
14
|
-
attr_accessor :web, :revisions
|
15
|
-
def name() "page" end
|
16
|
-
end
|
17
|
-
|
18
|
-
class RevisionTest < Test::Unit::TestCase
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@mock_page = MockPage.new
|
22
|
-
@mock_web = MockWeb.new
|
23
|
-
@mock_page.web = @mock_web
|
24
|
-
|
25
|
-
@mock_web.markup = :textile
|
26
|
-
|
27
|
-
@revision = Revision.new(
|
28
|
-
@mock_page,
|
29
|
-
1,
|
30
|
-
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
31
|
-
Time.local(2004, 4, 4, 16, 50),
|
32
|
-
"DavidHeinemeierHansson"
|
33
|
-
)
|
34
|
-
|
35
|
-
@revision_with_auto_links = Revision.new(
|
36
|
-
@mock_page,
|
37
|
-
1,
|
38
|
-
"http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com",
|
39
|
-
Time.local(2004, 4, 4, 16, 50),
|
40
|
-
"DavidHeinemeierHansson"
|
41
|
-
)
|
42
|
-
|
43
|
-
@revision_with_aliased_links = Revision.new(
|
44
|
-
@mock_page,
|
45
|
-
1,
|
46
|
-
"Would a [[SmartEngine|clever motor]] go by any other name?",
|
47
|
-
Time.local(2004, 4, 4, 16, 50),
|
48
|
-
"MarkReid"
|
49
|
-
)
|
50
|
-
|
51
|
-
@revision_with_wiki_word_in_em = Revision.new(
|
52
|
-
@mock_page,
|
53
|
-
1,
|
54
|
-
"_should we go ThatWay or ThisWay _",
|
55
|
-
Time.local(2004, 4, 4, 16, 50),
|
56
|
-
"MarkReid"
|
57
|
-
)
|
58
|
-
|
59
|
-
@revision_with_pre_blocks = Revision.new(
|
60
|
-
@mock_page,
|
61
|
-
1,
|
62
|
-
"A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>",
|
63
|
-
Time.local(2004, 4, 4, 16, 50),
|
64
|
-
"MarkReid"
|
65
|
-
)
|
66
|
-
|
67
|
-
@revision_with_wikiword_in_tag = Revision.new(
|
68
|
-
@mock_page,
|
69
|
-
1,
|
70
|
-
"That is some <em style=\"WikiWord\">Stylish Emphasis</em>",
|
71
|
-
Time.local(2004, 4, 4, 16, 50),
|
72
|
-
"MarkReid"
|
73
|
-
)
|
74
|
-
|
75
|
-
@revision_with_autolink_in_parentheses = Revision.new(
|
76
|
-
@mock_page,
|
77
|
-
1,
|
78
|
-
'The W3C body (http://www.w3c.org) sets web standards',
|
79
|
-
Time.local(2004, 4, 4, 16, 50),
|
80
|
-
"MarkReid"
|
81
|
-
)
|
82
|
-
|
83
|
-
@revision_with_link_in_parentheses = Revision.new(
|
84
|
-
@mock_page,
|
85
|
-
1,
|
86
|
-
'Instiki is a "Wiki Clone":http://www.c2.com/cgi/wiki?WikiWikiClones ("What is a wiki?":http://wiki.org/wiki.cgi?WhatIsWiki) that\'s so easy to setup',
|
87
|
-
Time.local(2004, 4, 4, 16, 50),
|
88
|
-
"MarkReid"
|
89
|
-
)
|
90
|
-
|
91
|
-
@revision_with_image_link = Revision.new(
|
92
|
-
@mock_page,
|
93
|
-
1,
|
94
|
-
'This !http://hobix.com/sample.jpg! is a Textile image link.',
|
95
|
-
Time.local(2004, 4, 4, 16, 50),
|
96
|
-
"MarkReid"
|
97
|
-
)
|
98
|
-
|
99
|
-
@revision_with_nowiki_text = Revision.new(
|
100
|
-
@mock_page,
|
101
|
-
1,
|
102
|
-
'Do not mark up <nowiki>[[this text]]</nowiki> or <nowiki>http://www.thislink.com</nowiki>.',
|
103
|
-
Time.local(2004, 4, 4, 16, 50),
|
104
|
-
"MarkReid"
|
105
|
-
)
|
106
|
-
|
107
|
-
@revision_with_bracketted_wiki_word = Revision.new(
|
108
|
-
@mock_page,
|
109
|
-
1,
|
110
|
-
'This is a WikiWord and a tricky name [[Sperberg-McQueen]].',
|
111
|
-
Time.local(2004, 4, 4, 16, 50),
|
112
|
-
"MarkReid"
|
113
|
-
)
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_wiki_words
|
118
|
-
assert_equal %w( HisWay MyWay SmartEngine SmartEngineGUI ThatWay ), @revision.wiki_words.sort
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_existing_pages
|
122
|
-
assert_equal %w( MyWay SmartEngine ThatWay ), @revision.existing_pages.sort
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_unexisting_pages
|
126
|
-
assert_equal %w( HisWay SmartEngineGUI ), @revision.unexisting_pages.sort
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_content_with_wiki_links
|
130
|
-
assert_equal "<p><span class=\"newWikiWord\">His Way<a href=\"../show/HisWay\">?</a></span> would be <a class=\"existingWikiWord\" href=\"../show/MyWay\">My Way</a> in kinda <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> in <span class=\"newWikiWord\">His Way<a href=\"../show/HisWay\">?</a></span> though <a class=\"existingWikiWord\" href=\"../show/MyWay\">My Way</a> OverThere—see <a class=\"existingWikiWord\" href=\"../show/SmartEngine\">Smart Engine</a> in that <span class=\"newWikiWord\">Smart Engine <span class=\"caps\">GUI</span><a href=\"../show/SmartEngineGUI\">?</a></span></p>", @revision.display_content
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_bluecloth
|
134
|
-
@mock_web.markup = :
|
135
|
-
|
136
|
-
@revision = Revision.new(
|
137
|
-
@mock_page,
|
138
|
-
1,
|
139
|
-
"My Headline\n===========\n\n that SmartEngineGUI",
|
140
|
-
Time.local(2004, 4, 4, 16, 50),
|
141
|
-
"DavidHeinemeierHansson"
|
142
|
-
)
|
143
|
-
|
144
|
-
@revision_with_code_block = Revision.new(
|
145
|
-
@mock_page,
|
146
|
-
1,
|
147
|
-
"This is a code block:\n def a_method(arg)\n return ThatWay\n\nNice!",
|
148
|
-
Time.local(2004, 4, 4, 16, 50),
|
149
|
-
"MarkReid"
|
150
|
-
)
|
151
|
-
|
152
|
-
assert_equal "<h1>My Headline</h1>\n\n<p>that <span class=\"newWikiWord\">Smart Engine GUI<a href=\"../show/SmartEngineGUI\">?</a></span></p>", @revision.display_content
|
153
|
-
|
154
|
-
assert_equal "<p>This is a code block:</p>\n\n<pre><code>def a_method(arg)\nreturn ThatWay\n</code></pre>\n\n<p>Nice!</p>", @revision_with_code_block.display_content
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_rdoc
|
158
|
-
@mock_web.markup = :rdoc
|
159
|
-
|
160
|
-
@revision = Revision.new(
|
161
|
-
@mock_page,
|
162
|
-
1,
|
163
|
-
"+hello+ that SmartEngineGUI",
|
164
|
-
Time.local(2004, 4, 4, 16, 50),
|
165
|
-
"DavidHeinemeierHansson"
|
166
|
-
)
|
167
|
-
|
168
|
-
assert_equal "<tt>hello</tt> that <span class=\"newWikiWord\">Smart Engine GUI<a href=\"../show/SmartEngineGUI\">?</a></span>\n\n", @revision.display_content
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_content_with_auto_links
|
172
|
-
assert_equal "<p><a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a> points to <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> from <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a></p>", @revision_with_auto_links.display_content
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_content_with_aliased_links
|
176
|
-
assert_equal "<p>Would a <a class=\"existingWikiWord\" href=\"../show/SmartEngine\">clever motor</a> go by any other name?</p>", @revision_with_aliased_links.display_content
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_content_with_wikiword_in_em
|
180
|
-
assert_equal "<p><em>should we go <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> or <span class=\"newWikiWord\">This Way<a href=\"../show/ThisWay\">?</a></span> </em></p>", @revision_with_wiki_word_in_em.display_content
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_content_with_wikiword_in_tag
|
184
|
-
assert_equal "<p>That is some <em style=\"WikiWord\">Stylish Emphasis</em></p>", @revision_with_wikiword_in_tag.display_content
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_content_with_pre_blocks
|
188
|
-
assert_equal "A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>", @revision_with_pre_blocks.display_content
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_content_with_autolink_in_parentheses
|
192
|
-
assert_equal '<p>The <span class="caps">W3C</span> body (<a href="http://www.w3c.org">http://www.w3c.org</a>) sets web standards</p>', @revision_with_autolink_in_parentheses.display_content
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_content_with_link_in_parentheses
|
196
|
-
assert_equal '<p>Instiki is a <a href="http://www.c2.com/cgi/wiki?WikiWikiClones">Wiki Clone</a> (<a href="http://wiki.org/wiki.cgi?WhatIsWiki">What is a wiki?</a>) that’s so easy to setup</p>', @revision_with_link_in_parentheses.display_content
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_content_with_image_link
|
200
|
-
assert_equal '<p>This <img src="http://hobix.com/sample.jpg" alt="" /> is a Textile image link.</p>', @revision_with_image_link.display_content
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_content_with_nowiki_text
|
204
|
-
assert_equal '<p>Do not mark up [[this text]] or http://www.thislink.com.</p>', @revision_with_nowiki_text.display_content
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_content_with_bracketted_wiki_word
|
208
|
-
@mock_web.brackets_only = true
|
209
|
-
assert_equal '<p>This is a WikiWord and a tricky name <span class="newWikiWord">Sperberg-McQueen<a href="../show/Sperberg-McQueen">?</a></span>.</p>', @revision_with_bracketted_wiki_word.display_content
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_content_for_export
|
213
|
-
assert_equal "<p><span class=\"newWikiWord\">His Way</span> would be <a class=\"existingWikiWord\" href=\"MyWay.html\">My Way</a> in kinda <a class=\"existingWikiWord\" href=\"ThatWay.html\">That Way</a> in <span class=\"newWikiWord\">His Way</span> though <a class=\"existingWikiWord\" href=\"MyWay.html\">My Way</a> OverThere—see <a class=\"existingWikiWord\" href=\"SmartEngine.html\">Smart Engine</a> in that <span class=\"newWikiWord\">Smart Engine <span class=\"caps\">GUI</span></span></p>", @revision.display_content_for_export
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_double_replacing
|
217
|
-
@revision.content = "VersionHistory\r\n\r\ncry VersionHistory"
|
218
|
-
assert_equal(
|
219
|
-
"<p><span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>\n\n\t<p>cry <span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>",
|
220
|
-
@revision.display_content
|
221
|
-
)
|
222
|
-
|
223
|
-
@revision.clear_display_cache
|
224
|
-
|
225
|
-
@revision.content = "f\r\nVersionHistory\r\n\r\ncry VersionHistory"
|
226
|
-
assert_equal(
|
227
|
-
"<p>f<br />\n<span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>\n\n\t<p>cry <span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>",
|
228
|
-
@revision.display_content
|
229
|
-
)
|
230
|
-
end
|
231
|
-
|
232
|
-
def test_difficult_wiki_words
|
233
|
-
@revision.content = "[[It's just awesome GUI!]]"
|
234
|
-
assert_equal(
|
235
|
-
"<p><span class=\"newWikiWord\">It’s just awesome <span class=\"caps\">GUI</span>!<a href=\"../show/It%27s+just+awesome+GUI%21\">?</a></span></p>",
|
236
|
-
@revision.display_content
|
237
|
-
)
|
238
|
-
end
|
239
|
-
|
240
|
-
def test_revisions_diff
|
241
|
-
page = MockPage.new
|
242
|
-
web = MockWeb.new
|
243
|
-
web.markup = :textile
|
244
|
-
page.web = web
|
245
|
-
|
246
|
-
page.revisions = [ 0 ]
|
247
|
-
page.revisions << Revision.new(page, 1, "What a blue and lovely morning", Time.local(2004, 4, 4, 16, 50), "DavidHeinemeierHansson")
|
248
|
-
page.revisions << Revision.new(page, 2, "What a red and lovely morning today", Time.local(2004, 4, 4, 16, 50), "DavidHeinemeierHansson")
|
249
|
-
|
250
|
-
assert_equal "<p>What a <del class=\"diffmod\">blue </del><ins class=\"diffmod\">red </ins>and lovely <del class=\"diffmod\">morning</del><ins class=\"diffmod\">morning today</ins></p>", page.revisions.last.display_diff
|
251
|
-
end
|
1
|
+
require "web"
|
2
|
+
require "test/unit"
|
3
|
+
require "revision"
|
4
|
+
|
5
|
+
class MockWeb < Web;
|
6
|
+
attr_accessor :markup
|
7
|
+
def pages() MockPages.new end
|
8
|
+
def safe_mode() false end
|
9
|
+
end
|
10
|
+
class MockPages
|
11
|
+
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
12
|
+
end
|
13
|
+
class MockPage
|
14
|
+
attr_accessor :web, :revisions
|
15
|
+
def name() "page" end
|
16
|
+
end
|
17
|
+
|
18
|
+
class RevisionTest < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@mock_page = MockPage.new
|
22
|
+
@mock_web = MockWeb.new
|
23
|
+
@mock_page.web = @mock_web
|
24
|
+
|
25
|
+
@mock_web.markup = :textile
|
26
|
+
|
27
|
+
@revision = Revision.new(
|
28
|
+
@mock_page,
|
29
|
+
1,
|
30
|
+
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
31
|
+
Time.local(2004, 4, 4, 16, 50),
|
32
|
+
"DavidHeinemeierHansson"
|
33
|
+
)
|
34
|
+
|
35
|
+
@revision_with_auto_links = Revision.new(
|
36
|
+
@mock_page,
|
37
|
+
1,
|
38
|
+
"http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com",
|
39
|
+
Time.local(2004, 4, 4, 16, 50),
|
40
|
+
"DavidHeinemeierHansson"
|
41
|
+
)
|
42
|
+
|
43
|
+
@revision_with_aliased_links = Revision.new(
|
44
|
+
@mock_page,
|
45
|
+
1,
|
46
|
+
"Would a [[SmartEngine|clever motor]] go by any other name?",
|
47
|
+
Time.local(2004, 4, 4, 16, 50),
|
48
|
+
"MarkReid"
|
49
|
+
)
|
50
|
+
|
51
|
+
@revision_with_wiki_word_in_em = Revision.new(
|
52
|
+
@mock_page,
|
53
|
+
1,
|
54
|
+
"_should we go ThatWay or ThisWay _",
|
55
|
+
Time.local(2004, 4, 4, 16, 50),
|
56
|
+
"MarkReid"
|
57
|
+
)
|
58
|
+
|
59
|
+
@revision_with_pre_blocks = Revision.new(
|
60
|
+
@mock_page,
|
61
|
+
1,
|
62
|
+
"A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>",
|
63
|
+
Time.local(2004, 4, 4, 16, 50),
|
64
|
+
"MarkReid"
|
65
|
+
)
|
66
|
+
|
67
|
+
@revision_with_wikiword_in_tag = Revision.new(
|
68
|
+
@mock_page,
|
69
|
+
1,
|
70
|
+
"That is some <em style=\"WikiWord\">Stylish Emphasis</em>",
|
71
|
+
Time.local(2004, 4, 4, 16, 50),
|
72
|
+
"MarkReid"
|
73
|
+
)
|
74
|
+
|
75
|
+
@revision_with_autolink_in_parentheses = Revision.new(
|
76
|
+
@mock_page,
|
77
|
+
1,
|
78
|
+
'The W3C body (http://www.w3c.org) sets web standards',
|
79
|
+
Time.local(2004, 4, 4, 16, 50),
|
80
|
+
"MarkReid"
|
81
|
+
)
|
82
|
+
|
83
|
+
@revision_with_link_in_parentheses = Revision.new(
|
84
|
+
@mock_page,
|
85
|
+
1,
|
86
|
+
'Instiki is a "Wiki Clone":http://www.c2.com/cgi/wiki?WikiWikiClones ("What is a wiki?":http://wiki.org/wiki.cgi?WhatIsWiki) that\'s so easy to setup',
|
87
|
+
Time.local(2004, 4, 4, 16, 50),
|
88
|
+
"MarkReid"
|
89
|
+
)
|
90
|
+
|
91
|
+
@revision_with_image_link = Revision.new(
|
92
|
+
@mock_page,
|
93
|
+
1,
|
94
|
+
'This !http://hobix.com/sample.jpg! is a Textile image link.',
|
95
|
+
Time.local(2004, 4, 4, 16, 50),
|
96
|
+
"MarkReid"
|
97
|
+
)
|
98
|
+
|
99
|
+
@revision_with_nowiki_text = Revision.new(
|
100
|
+
@mock_page,
|
101
|
+
1,
|
102
|
+
'Do not mark up <nowiki>[[this text]]</nowiki> or <nowiki>http://www.thislink.com</nowiki>.',
|
103
|
+
Time.local(2004, 4, 4, 16, 50),
|
104
|
+
"MarkReid"
|
105
|
+
)
|
106
|
+
|
107
|
+
@revision_with_bracketted_wiki_word = Revision.new(
|
108
|
+
@mock_page,
|
109
|
+
1,
|
110
|
+
'This is a WikiWord and a tricky name [[Sperberg-McQueen]].',
|
111
|
+
Time.local(2004, 4, 4, 16, 50),
|
112
|
+
"MarkReid"
|
113
|
+
)
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_wiki_words
|
118
|
+
assert_equal %w( HisWay MyWay SmartEngine SmartEngineGUI ThatWay ), @revision.wiki_words.sort
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_existing_pages
|
122
|
+
assert_equal %w( MyWay SmartEngine ThatWay ), @revision.existing_pages.sort
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_unexisting_pages
|
126
|
+
assert_equal %w( HisWay SmartEngineGUI ), @revision.unexisting_pages.sort
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_content_with_wiki_links
|
130
|
+
assert_equal "<p><span class=\"newWikiWord\">His Way<a href=\"../show/HisWay\">?</a></span> would be <a class=\"existingWikiWord\" href=\"../show/MyWay\">My Way</a> in kinda <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> in <span class=\"newWikiWord\">His Way<a href=\"../show/HisWay\">?</a></span> though <a class=\"existingWikiWord\" href=\"../show/MyWay\">My Way</a> OverThere—see <a class=\"existingWikiWord\" href=\"../show/SmartEngine\">Smart Engine</a> in that <span class=\"newWikiWord\">Smart Engine <span class=\"caps\">GUI</span><a href=\"../show/SmartEngineGUI\">?</a></span></p>", @revision.display_content
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_bluecloth
|
134
|
+
@mock_web.markup = :blue_markdown
|
135
|
+
|
136
|
+
@revision = Revision.new(
|
137
|
+
@mock_page,
|
138
|
+
1,
|
139
|
+
"My Headline\n===========\n\n that SmartEngineGUI",
|
140
|
+
Time.local(2004, 4, 4, 16, 50),
|
141
|
+
"DavidHeinemeierHansson"
|
142
|
+
)
|
143
|
+
|
144
|
+
@revision_with_code_block = Revision.new(
|
145
|
+
@mock_page,
|
146
|
+
1,
|
147
|
+
"This is a code block:\n def a_method(arg)\n return ThatWay\n\nNice!",
|
148
|
+
Time.local(2004, 4, 4, 16, 50),
|
149
|
+
"MarkReid"
|
150
|
+
)
|
151
|
+
|
152
|
+
assert_equal "<h1>My Headline</h1>\n\n<p>that <span class=\"newWikiWord\">Smart Engine GUI<a href=\"../show/SmartEngineGUI\">?</a></span></p>", @revision.display_content
|
153
|
+
|
154
|
+
assert_equal "<p>This is a code block:</p>\n\n<pre><code>def a_method(arg)\nreturn ThatWay\n</code></pre>\n\n<p>Nice!</p>", @revision_with_code_block.display_content
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_rdoc
|
158
|
+
@mock_web.markup = :rdoc
|
159
|
+
|
160
|
+
@revision = Revision.new(
|
161
|
+
@mock_page,
|
162
|
+
1,
|
163
|
+
"+hello+ that SmartEngineGUI",
|
164
|
+
Time.local(2004, 4, 4, 16, 50),
|
165
|
+
"DavidHeinemeierHansson"
|
166
|
+
)
|
167
|
+
|
168
|
+
assert_equal "<tt>hello</tt> that <span class=\"newWikiWord\">Smart Engine GUI<a href=\"../show/SmartEngineGUI\">?</a></span>\n\n", @revision.display_content
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_content_with_auto_links
|
172
|
+
assert_equal "<p><a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a> points to <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> from <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a></p>", @revision_with_auto_links.display_content
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_content_with_aliased_links
|
176
|
+
assert_equal "<p>Would a <a class=\"existingWikiWord\" href=\"../show/SmartEngine\">clever motor</a> go by any other name?</p>", @revision_with_aliased_links.display_content
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_content_with_wikiword_in_em
|
180
|
+
assert_equal "<p><em>should we go <a class=\"existingWikiWord\" href=\"../show/ThatWay\">That Way</a> or <span class=\"newWikiWord\">This Way<a href=\"../show/ThisWay\">?</a></span> </em></p>", @revision_with_wiki_word_in_em.display_content
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_content_with_wikiword_in_tag
|
184
|
+
assert_equal "<p>That is some <em style=\"WikiWord\">Stylish Emphasis</em></p>", @revision_with_wikiword_in_tag.display_content
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_content_with_pre_blocks
|
188
|
+
assert_equal "A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>", @revision_with_pre_blocks.display_content
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_content_with_autolink_in_parentheses
|
192
|
+
assert_equal '<p>The <span class="caps">W3C</span> body (<a href="http://www.w3c.org">http://www.w3c.org</a>) sets web standards</p>', @revision_with_autolink_in_parentheses.display_content
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_content_with_link_in_parentheses
|
196
|
+
assert_equal '<p>Instiki is a <a href="http://www.c2.com/cgi/wiki?WikiWikiClones">Wiki Clone</a> (<a href="http://wiki.org/wiki.cgi?WhatIsWiki">What is a wiki?</a>) that’s so easy to setup</p>', @revision_with_link_in_parentheses.display_content
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_content_with_image_link
|
200
|
+
assert_equal '<p>This <img src="http://hobix.com/sample.jpg" alt="" /> is a Textile image link.</p>', @revision_with_image_link.display_content
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_content_with_nowiki_text
|
204
|
+
assert_equal '<p>Do not mark up [[this text]] or http://www.thislink.com.</p>', @revision_with_nowiki_text.display_content
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_content_with_bracketted_wiki_word
|
208
|
+
@mock_web.brackets_only = true
|
209
|
+
assert_equal '<p>This is a WikiWord and a tricky name <span class="newWikiWord">Sperberg-McQueen<a href="../show/Sperberg-McQueen">?</a></span>.</p>', @revision_with_bracketted_wiki_word.display_content
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_content_for_export
|
213
|
+
assert_equal "<p><span class=\"newWikiWord\">His Way</span> would be <a class=\"existingWikiWord\" href=\"MyWay.html\">My Way</a> in kinda <a class=\"existingWikiWord\" href=\"ThatWay.html\">That Way</a> in <span class=\"newWikiWord\">His Way</span> though <a class=\"existingWikiWord\" href=\"MyWay.html\">My Way</a> OverThere—see <a class=\"existingWikiWord\" href=\"SmartEngine.html\">Smart Engine</a> in that <span class=\"newWikiWord\">Smart Engine <span class=\"caps\">GUI</span></span></p>", @revision.display_content_for_export
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_double_replacing
|
217
|
+
@revision.content = "VersionHistory\r\n\r\ncry VersionHistory"
|
218
|
+
assert_equal(
|
219
|
+
"<p><span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>\n\n\t<p>cry <span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>",
|
220
|
+
@revision.display_content
|
221
|
+
)
|
222
|
+
|
223
|
+
@revision.clear_display_cache
|
224
|
+
|
225
|
+
@revision.content = "f\r\nVersionHistory\r\n\r\ncry VersionHistory"
|
226
|
+
assert_equal(
|
227
|
+
"<p>f<br />\n<span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>\n\n\t<p>cry <span class=\"newWikiWord\">Version History<a href=\"../show/VersionHistory\">?</a></span></p>",
|
228
|
+
@revision.display_content
|
229
|
+
)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_difficult_wiki_words
|
233
|
+
@revision.content = "[[It's just awesome GUI!]]"
|
234
|
+
assert_equal(
|
235
|
+
"<p><span class=\"newWikiWord\">It’s just awesome <span class=\"caps\">GUI</span>!<a href=\"../show/It%27s+just+awesome+GUI%21\">?</a></span></p>",
|
236
|
+
@revision.display_content
|
237
|
+
)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_revisions_diff
|
241
|
+
page = MockPage.new
|
242
|
+
web = MockWeb.new
|
243
|
+
web.markup = :textile
|
244
|
+
page.web = web
|
245
|
+
|
246
|
+
page.revisions = [ 0 ]
|
247
|
+
page.revisions << Revision.new(page, 1, "What a blue and lovely morning", Time.local(2004, 4, 4, 16, 50), "DavidHeinemeierHansson")
|
248
|
+
page.revisions << Revision.new(page, 2, "What a red and lovely morning today", Time.local(2004, 4, 4, 16, 50), "DavidHeinemeierHansson")
|
249
|
+
|
250
|
+
assert_equal "<p>What a <del class=\"diffmod\">blue </del><ins class=\"diffmod\">red </ins>and lovely <del class=\"diffmod\">morning</del><ins class=\"diffmod\">morning today</ins></p>", page.revisions.last.display_diff
|
251
|
+
end
|
252
252
|
end
|