motiro 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +15 -0
- data/README +2 -2
- data/README.en +1 -2
- data/README.pt-br +1 -2
- data/app/controllers/account_controller.rb +1 -1
- data/app/controllers/application.rb +13 -12
- data/app/controllers/javascript_controller.rb +1 -1
- data/app/controllers/report_controller.rb +1 -1
- data/app/controllers/wiki_controller.rb +3 -5
- data/app/core/cache_reporter.rb +1 -1
- data/app/core/cache_reporter_fetcher.rb +1 -1
- data/app/core/chief_editor.rb +1 -1
- data/app/core/reporter.rb +1 -1
- data/app/core/reporter_driver.rb +1 -1
- data/app/core/reporter_fetcher.rb +1 -1
- data/app/core/settings.rb +1 -1
- data/app/core/version.rb +1 -1
- data/app/core/wiki_reporter.rb +1 -1
- data/app/helpers/application_helper.rb +5 -1
- data/app/helpers/default_page_provider.rb +6 -2
- data/app/helpers/report_helper.rb +14 -1
- data/app/models/change.rb +1 -1
- data/app/models/chunk.rb +1 -1
- data/app/models/feed_observer.rb +1 -1
- data/app/models/headline.rb +1 -1
- data/app/models/page.rb +38 -4
- data/app/models/revision.rb +1 -1
- data/app/models/user.rb +1 -1
- data/app/models/wiki_reference.rb +21 -0
- data/app/models/wiki_sweeper.rb +17 -2
- data/app/ports/chdir_runner.rb +1 -1
- data/app/ports/runner.rb +1 -1
- data/app/reporters/darcs_connection.rb +1 -1
- data/app/reporters/darcs_reporter.rb +1 -1
- data/app/reporters/darcs_temp_repo.rb +1 -1
- data/app/reporters/events_reporter.rb +1 -1
- data/app/reporters/features_reporter.rb +1 -1
- data/app/reporters/subversion_reporter.rb +1 -1
- data/app/reporters/svn_connection.rb +1 -1
- data/app/reporters/svn_settings.rb +1 -1
- data/app/views/report/list.rhtml +6 -7
- data/app/views/report/older.rhtml +1 -2
- data/app/views/report/rss.rxml +1 -1
- data/app/views/report/show.rhtml +2 -2
- data/app/views/wiki/_edit_event.rhtml +2 -0
- data/app/views/wiki/_edit_feature.rhtml +2 -0
- data/app/views/wiki/_properties_edit.rhtml +3 -5
- data/app/views/wiki/_properties_show.rhtml +4 -5
- data/app/views/wiki/_show_event.rhtml +3 -0
- data/app/views/wiki/_show_feature.rhtml +2 -0
- data/app/views/wiki/show.rhtml +1 -1
- data/bin/motiro +3 -3
- data/config/routes.rb +1 -1
- data/db/migrate/024_add_feature_status.rb +11 -0
- data/db/migrate/025_add_page_references.rb +12 -0
- data/db/migrate/026_convert_link_syntax.rb +12 -0
- data/db/migrate/027_register_page_references.rb +12 -0
- data/db/motirodb.sqlite.initial +0 -0
- data/db/schema_version +1 -1
- data/db/translation/pt-BR.rb +7 -1
- data/lib/array_extensions.rb +1 -1
- data/lib/diff_chunk_builder.rb +1 -1
- data/lib/differ.rb +1 -1
- data/lib/string_extensions.rb +13 -6
- data/lib/stub_hash.rb +1 -1
- data/lib/tasks/packaging.rake +10 -12
- data/lib/tasks/testing.rake +1 -1
- data/lib/tick_daemon.rb +1 -1
- data/lib/{wiki_url_generator.rb → wiki_link_handler.rb} +13 -3
- data/lib/wiki_renderer.rb +63 -34
- data/public/images/done.png +0 -0
- data/public/images/not-done.png +0 -0
- data/public/stylesheets/motiro.css +8 -0
- data/script/ticker +1 -1
- data/test/acceptance/account_test.rb +1 -1
- data/test/acceptance/darcs_test.rb +1 -1
- data/test/acceptance/events_test.rb +1 -1
- data/test/acceptance/main_page_test.rb +1 -1
- data/test/acceptance/subversion_test.rb +1 -1
- data/test/acceptance/ts_all_suites.rb +1 -1
- data/test/acceptance/wiki_test.rb +3 -3
- data/test/contract/darcs_test.rb +1 -1
- data/test/contract/remote_darcs_test.rb +1 -1
- data/test/contract/svn_test.rb +1 -1
- data/test/fixtures/pages.yml +20 -1
- data/test/fixtures/revisions.yml +40 -1
- data/test/fixtures/wiki_references.yml +5 -0
- data/test/functional/report_controller_test.rb +1 -1
- data/test/functional/report_features_test.rb +8 -1
- data/test/functional/report_subversion_test.rb +1 -1
- data/test/functional/root_controller_test.rb +1 -1
- data/test/functional/wiki_controller_test.rb +67 -2
- data/test/lib/acceptance_test_case.rb +1 -1
- data/test/lib/darcs_excerpts.rb +1 -1
- data/test/lib/darcs_repo.rb +1 -1
- data/test/lib/hash_extensions.rb +22 -0
- data/test/lib/live_mode_test.rb +1 -1
- data/test/lib/netutils.rb +1 -1
- data/test/lib/platform_thread.rb +1 -1
- data/test/lib/selenium_extensions.rb +1 -1
- data/test/lib/stubio.rb +1 -1
- data/test/lib/webserver.rb +1 -1
- data/test/meta/darcs_repo_test.rb +1 -1
- data/test/meta/local_svn_test.rb +1 -1
- data/test/meta/platform_thread_test.rb +1 -1
- data/test/meta/stubio_test.rb +1 -1
- data/test/stubs/{url_generator.rb → wiki_link_handler.rb} +8 -4
- data/test/test_helper.rb +3 -1
- data/test/unit/array_extensions_test.rb +1 -1
- data/test/unit/cache_reporter_fetcher_test.rb +1 -1
- data/test/unit/cache_reporter_test.rb +1 -1
- data/test/unit/change_test.rb +1 -1
- data/test/unit/chdir_runner_test.rb +1 -1
- data/test/unit/chief_editor_test.rb +1 -1
- data/test/unit/darcs_connection_test.rb +1 -1
- data/test/unit/darcs_reporter_test.rb +4 -4
- data/test/unit/darcs_temp_repo_test.rb +1 -1
- data/test/unit/default_page_provider_test.rb +23 -13
- data/test/unit/diff_chunk_builder_test.rb +1 -1
- data/test/unit/page_test.rb +67 -4
- data/test/unit/reporter_driver_test.rb +1 -1
- data/test/unit/reporter_test.rb +1 -1
- data/test/unit/revision_test.rb +1 -1
- data/test/unit/runner_test.rb +1 -1
- data/test/unit/string_extensions_test.rb +15 -3
- data/test/unit/svn_connection_test.rb +1 -1
- data/test/unit/svn_reporter_interaction_test.rb +1 -1
- data/test/unit/svn_reporter_test.rb +1 -1
- data/test/unit/svn_settings_test.rb +1 -1
- data/test/unit/user_test.rb +1 -1
- data/test/unit/{wiki_url_generator_test.rb → wiki_link_handler_test.rb} +3 -3
- data/test/unit/wiki_renderer_test.rb +75 -20
- data/test/unit/wiki_reporter_test.rb +1 -1
- data/vendor/mediacloth-trunk/MIT-LICENSE +20 -0
- data/vendor/mediacloth-trunk/README +32 -0
- data/vendor/mediacloth-trunk/Rakefile +33 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiast.rb +122 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikihtmlgenerator.rb +252 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikilexer.rb +821 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikilinkhandler.rb +68 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparams.rb +33 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparser.rb +1218 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparser.y +493 -0
- data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiwalker.rb +146 -0
- data/vendor/mediacloth-trunk/lib/mediacloth.rb +29 -0
- data/vendor/mediacloth-trunk/mediacloth.gemspec +24 -0
- data/vendor/mediacloth-trunk/mediacloth.kdevelop +117 -0
- data/vendor/mediacloth-trunk/setup.rb +1585 -0
- data/vendor/mediacloth-trunk/test/data/html1 +26 -0
- data/vendor/mediacloth-trunk/test/data/html10 +130 -0
- data/vendor/mediacloth-trunk/test/data/html11 +17 -0
- data/vendor/mediacloth-trunk/test/data/html12 +12 -0
- data/vendor/mediacloth-trunk/test/data/html13 +11 -0
- data/vendor/mediacloth-trunk/test/data/html2 +2 -0
- data/vendor/mediacloth-trunk/test/data/html3 +1 -0
- data/vendor/mediacloth-trunk/test/data/html4 +47 -0
- data/vendor/mediacloth-trunk/test/data/html5 +57 -0
- data/vendor/mediacloth-trunk/test/data/html6 +8 -0
- data/vendor/mediacloth-trunk/test/data/html7 +45 -0
- data/vendor/mediacloth-trunk/test/data/html8 +1 -0
- data/vendor/mediacloth-trunk/test/data/html9 +14 -0
- data/vendor/mediacloth-trunk/test/data/input1 +34 -0
- data/vendor/mediacloth-trunk/test/data/input10 +124 -0
- data/vendor/mediacloth-trunk/test/data/input11 +17 -0
- data/vendor/mediacloth-trunk/test/data/input12 +15 -0
- data/vendor/mediacloth-trunk/test/data/input13 +10 -0
- data/vendor/mediacloth-trunk/test/data/input2 +2 -0
- data/vendor/mediacloth-trunk/test/data/input3 +2 -0
- data/vendor/mediacloth-trunk/test/data/input4 +50 -0
- data/vendor/mediacloth-trunk/test/data/input5 +63 -0
- data/vendor/mediacloth-trunk/test/data/input6 +8 -0
- data/vendor/mediacloth-trunk/test/data/input7 +45 -0
- data/vendor/mediacloth-trunk/test/data/input8 +1 -0
- data/vendor/mediacloth-trunk/test/data/input9 +14 -0
- data/vendor/mediacloth-trunk/test/data/lex1 +26 -0
- data/vendor/mediacloth-trunk/test/data/lex10 +85 -0
- data/vendor/mediacloth-trunk/test/data/lex11 +17 -0
- data/vendor/mediacloth-trunk/test/data/lex12 +15 -0
- data/vendor/mediacloth-trunk/test/data/lex13 +3 -0
- data/vendor/mediacloth-trunk/test/data/lex2 +2 -0
- data/vendor/mediacloth-trunk/test/data/lex3 +1 -0
- data/vendor/mediacloth-trunk/test/data/lex4 +47 -0
- data/vendor/mediacloth-trunk/test/data/lex5 +57 -0
- data/vendor/mediacloth-trunk/test/data/lex6 +8 -0
- data/vendor/mediacloth-trunk/test/data/lex7 +45 -0
- data/vendor/mediacloth-trunk/test/data/lex8 +1 -0
- data/vendor/mediacloth-trunk/test/data/lex9 +14 -0
- data/vendor/mediacloth-trunk/test/data/result1 +48 -0
- data/vendor/mediacloth-trunk/test/dataproducers/html.rb +18 -0
- data/vendor/mediacloth-trunk/test/dataproducers/lex.rb +15 -0
- data/vendor/mediacloth-trunk/test/debugwalker.rb +68 -0
- data/vendor/mediacloth-trunk/test/htmlgenerator.rb +97 -0
- data/vendor/mediacloth-trunk/test/lexer.rb +542 -0
- data/vendor/mediacloth-trunk/test/linkhandler.rb +39 -0
- data/vendor/mediacloth-trunk/test/parser.rb +22 -0
- data/vendor/mediacloth-trunk/test/testhelper.rb +27 -0
- data/vendor/mediacloth.rb +3 -0
- data/vendor/motiro-installer.rb +1 -1
- data/vendor/plugins/cache_test-0.2/CHANGELOG +14 -0
- data/vendor/plugins/cache_test-0.2/MIT-LICENSE +20 -0
- data/vendor/plugins/cache_test-0.2/README +124 -0
- data/vendor/plugins/cache_test-0.2/init.rb +8 -0
- data/vendor/plugins/cache_test-0.2/lib/fragment_cache_test.rb +205 -0
- data/vendor/plugins/cache_test-0.2/lib/page_cache_test.rb +140 -0
- data/vendor/plugins/global_routing/init.rb +1 -1
- metadata +517 -455
data/test/unit/reporter_test.rb
CHANGED
data/test/unit/revision_test.rb
CHANGED
data/test/unit/runner_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Motiro - A project tracking tool
|
2
|
-
# Copyright (C) 2006-
|
2
|
+
# Copyright (C) 2006-2008 Thiago Arrais
|
3
3
|
#
|
4
4
|
# This program is free software; you can redistribute it and/or modify
|
5
5
|
# it under the terms of the GNU General Public License as published by
|
@@ -21,7 +21,8 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_medialize
|
23
23
|
str = "= Motiro =\n\nAnother paragraph"
|
24
|
-
assert_equal
|
24
|
+
assert_equal "<h1><a name='Motiro'></a> Motiro </h1><p>\n\n</p><p>Another paragraph</p>",
|
25
|
+
str.medialize
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_xml_splits_simple_elements
|
@@ -46,4 +47,15 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
46
47
|
assert_equal ['<h2>Level 2 title</h2>', '<p>Paragraph</p>'], str.xml_split
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
def test_xml_splits_nested_identical_tags
|
51
|
+
str = '<ul><li>a b</li><li>c <ul><li>d e f</li><li>g h</li></ul></li></ul>'+
|
52
|
+
'<p>paragraph</p>'
|
53
|
+
assert_equal ['<ul><li>a b</li><li>c <ul><li>d e f</li><li>g h</li></ul></li></ul>',
|
54
|
+
'<p>paragraph</p>'], str.xml_split
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_xml_splits_empty_element
|
58
|
+
assert_equal ["<a name='Sub_title'/>", 'Sub', 'title'],
|
59
|
+
"<a name='Sub_title'/> Sub title ".xml_split
|
60
|
+
end
|
61
|
+
end
|
data/test/unit/user_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Motiro - A project tracking tool
|
2
|
-
# Copyright (C) 2006-
|
2
|
+
# Copyright (C) 2006-2008 Thiago Arrais
|
3
3
|
#
|
4
4
|
# This program is free software; you can redistribute it and/or modify
|
5
5
|
# it under the terms of the GNU General Public License as published by
|
@@ -17,14 +17,14 @@
|
|
17
17
|
|
18
18
|
require File.dirname(__FILE__) + '/../test_helper'
|
19
19
|
|
20
|
-
class
|
20
|
+
class WikiLinkHandlerTest < Test::Unit::TestCase
|
21
21
|
|
22
22
|
def test_delegates_generation_to_controller
|
23
23
|
FlexMock.use do |cont|
|
24
24
|
cont.should_receive(:server_url_for).once.returns('a').
|
25
25
|
with(:controller => 'wiki', :action => 'show', :page_name => 'MyPage')
|
26
26
|
|
27
|
-
assert_equal 'a',
|
27
|
+
assert_equal 'a', WikiLinkHandler.new(cont).url_for('MyPage')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Motiro - A project tracking tool
|
2
|
-
# Copyright (C) 2006-
|
2
|
+
# Copyright (C) 2006-2008 Thiago Arrais
|
3
3
|
#
|
4
4
|
# This program is free software; you can redistribute it and/or modify
|
5
5
|
# it under the terms of the GNU General Public License as published by
|
@@ -17,10 +17,11 @@
|
|
17
17
|
|
18
18
|
require File.dirname(__FILE__) + '/../test_helper'
|
19
19
|
|
20
|
-
require 'stubs/
|
20
|
+
require 'stubs/wiki_link_handler'
|
21
21
|
|
22
22
|
class WikiRendererTest < Test::Unit::TestCase
|
23
23
|
|
24
|
+
fixtures :pages, :revisions
|
24
25
|
attr_reader :renderer
|
25
26
|
|
26
27
|
def setup
|
@@ -28,20 +29,20 @@ class WikiRendererTest < Test::Unit::TestCase
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_renders_title
|
31
|
-
assert_equal "<h1>Motiro</h1>", renderer.render_wiki_text('= Motiro =')
|
32
|
+
assert_equal "<h1><a name='Motiro'></a> Motiro </h1>", renderer.render_wiki_text('= Motiro =')
|
32
33
|
end
|
33
34
|
|
34
35
|
def test_breaks_paragraphs_on_linebreak_and_return_feed
|
35
36
|
line_break_only_text = "= Motiro =\n\nThis is project Motiro"
|
36
37
|
feed_return_text = "= Motiro =\r\n\r\nThis is project Motiro"
|
37
|
-
expected_text =
|
38
|
+
expected_text = "<h1><a name='Motiro'></a> Motiro </h1><p>This is project Motiro</p>"
|
38
39
|
|
39
40
|
assert_equal expected_text, renderer.render_wiki_text(line_break_only_text)
|
40
41
|
assert_equal expected_text, renderer.render_wiki_text(feed_return_text)
|
41
42
|
end
|
42
43
|
|
43
44
|
def test_render_external_links
|
44
|
-
expected = "<p><a href=\"http://nowhere.com\"
|
45
|
+
expected = "<p><a href=\"http://nowhere.com\">Nowhere</a></p>"
|
45
46
|
assert_equal expected, renderer.render_wiki_text('[http://nowhere.com Nowhere]')
|
46
47
|
end
|
47
48
|
|
@@ -55,14 +56,14 @@ class WikiRendererTest < Test::Unit::TestCase
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def test_renders_internal_link
|
58
|
-
|
59
|
-
|
59
|
+
assert_equal "<p><a href=\"http://test.host/wiki/show/AnotherPage\">go somewhere else</a></p>",
|
60
|
+
renderer.render_wiki_text('[[AnotherPage|go somewhere else]]')
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_renders_multiple_internal_links
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
assert_equal "<p><a href=\"http://test.host/wiki/show/InternalPage\">go there</a> <a href=\"http://test.host/wiki/show/OtherInternalPage\">and there</a></p>",
|
65
|
+
renderer.render_wiki_text("[[InternalPage|go there]] " +
|
66
|
+
"[[OtherInternalPage|and there]]")
|
66
67
|
end
|
67
68
|
|
68
69
|
def test_do_not_expand_links_when_there_is_a_break_inside_the_brackets
|
@@ -71,13 +72,13 @@ class WikiRendererTest < Test::Unit::TestCase
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def test_expands_internal_links_with_address_only
|
74
|
-
expected = "<p><a href=\"http://test.host/wiki/show/AnotherPage\"
|
75
|
-
assert_equal expected, renderer.render_wiki_text("[AnotherPage]")
|
75
|
+
expected = "<p><a href=\"http://test.host/wiki/show/AnotherPage\">AnotherPage</a></p>"
|
76
|
+
assert_equal expected, renderer.render_wiki_text("[[AnotherPage]]")
|
76
77
|
end
|
77
78
|
|
78
79
|
def test_recover_from_unmatched_opening_bracket_inside_link_text
|
79
|
-
assert_equal "<p><a href=\"http://test.host/wiki/show/SomeoneMistankenly\"
|
80
|
-
renderer.render_wiki_text("[SomeoneMistankenly
|
80
|
+
assert_equal "<p><a href=\"http://test.host/wiki/show/SomeoneMistankenly\">placed an opening bracket [ inside the link text, but Motiro managed to recover correctly</a></p>",
|
81
|
+
renderer.render_wiki_text("[[SomeoneMistankenly|placed an opening bracket [ inside the link text, but Motiro managed to recover correctly]]")
|
81
82
|
end
|
82
83
|
|
83
84
|
def test_emphasizes_diffs_inside_pure_text_change
|
@@ -135,11 +136,34 @@ class WikiRendererTest < Test::Unit::TestCase
|
|
135
136
|
previous = "Here is a [http://www.motiro.org link]"
|
136
137
|
current = "Here is a [http://www.motiro.com link]"
|
137
138
|
|
138
|
-
assert_equal '<p>Here is a <a href="http://www.motiro.org"
|
139
|
-
'<a href="http://www.motiro.com"
|
139
|
+
assert_equal '<p>Here is a <a href="http://www.motiro.org"><span style="background: #ffb8b8">link</span></a>' +
|
140
|
+
'<a href="http://www.motiro.com"><span style="background: #b8ffb8">link</span></a></p>',
|
141
|
+
renderer.render_wiki_diff(previous, current)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_emphasizes_changes_to_text_before_changed_tags
|
145
|
+
previous = "Here is my [http://www.motiro.org link]"
|
146
|
+
current = "Here is another [http://www.motiro.com link]"
|
147
|
+
|
148
|
+
assert_equal '<p>Here is <span style="background: #ffb8b8">my</span>' +
|
149
|
+
'<span style="background: #b8ffb8">another</span> ' +
|
150
|
+
'<a href="http://www.motiro.org"><span style="background: #ffb8b8">link</span></a>' +
|
151
|
+
'<a href="http://www.motiro.com"><span style="background: #b8ffb8">link</span></a></p>',
|
140
152
|
renderer.render_wiki_diff(previous, current)
|
141
153
|
end
|
142
154
|
|
155
|
+
def test_emphasizes_changes_to_text_after_changed_tags
|
156
|
+
previous = "This is a [[SomePage|very good]] page"
|
157
|
+
current = "This is a [[OtherPage|very good]] text"
|
158
|
+
|
159
|
+
assert_equal '<p>This is a ' +
|
160
|
+
'<a href="http://test.host/wiki/show/SomePage"><span style="background: #ffb8b8">very good</span></a>' +
|
161
|
+
'<a href="http://test.host/wiki/show/OtherPage"><span style="background: #b8ffb8">very good</span></a> ' +
|
162
|
+
'<span style="background: #ffb8b8">page</span>' +
|
163
|
+
'<span style="background: #b8ffb8">text</span></p>',
|
164
|
+
renderer.render_wiki_diff(previous, current)
|
165
|
+
end
|
166
|
+
|
143
167
|
def test_emphasizes_changed_html_tags_after_changed_text
|
144
168
|
previous = "Here is my ''long text''"
|
145
169
|
current = "Here is your ''long article''"
|
@@ -212,15 +236,46 @@ class WikiRendererTest < Test::Unit::TestCase
|
|
212
236
|
def test_emphasize_change_inside_title_tag
|
213
237
|
previous = "== Sub title ==\n\nParagraph"
|
214
238
|
current = "== Super title ==\n\nParagraph"
|
215
|
-
|
216
|
-
assert_equal '<h2><span style="background: #ffb8b8"
|
239
|
+
|
240
|
+
assert_equal '<h2><a name=\'Sub_title\'><span style="background: #ffb8b8"></span></a>' +
|
241
|
+
'<a name=\'Super_title\'><span style="background: #b8ffb8"></span></a> ' +
|
242
|
+
'<span style="background: #ffb8b8">Sub</span>' +
|
217
243
|
'<span style="background: #b8ffb8">Super</span> title</h2> ' +
|
218
244
|
'<p>Paragraph</p>',
|
219
245
|
renderer.render_wiki_diff(previous, current)
|
220
246
|
end
|
221
247
|
|
248
|
+
def test_emphasize_change_inside_composite_tag
|
249
|
+
previous = "* This is a list\n" +
|
250
|
+
"* With three items\n" +
|
251
|
+
"** One of them is a nested list\n" +
|
252
|
+
"** With two items"
|
253
|
+
current = "* This is a list\n" +
|
254
|
+
"* With three items\n" +
|
255
|
+
"** One of them is another list\n" +
|
256
|
+
"** With two changed items"
|
257
|
+
|
258
|
+
assert_equal '<ul>' +
|
259
|
+
"<li> This is a list</li> " +
|
260
|
+
'<li>With three items ' +
|
261
|
+
'<ul>' +
|
262
|
+
'<li>One of them is ' +
|
263
|
+
'<span style="background: #ffb8b8">a nested</span>' +
|
264
|
+
'<span style="background: #b8ffb8">another</span> list</li> ' +
|
265
|
+
'<li>With two <span style="background: #b8ffb8">changed</span> items</li>' +
|
266
|
+
'</ul></li>' +
|
267
|
+
'</ul>',
|
268
|
+
renderer.render_wiki_diff(previous, current)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_marks_references_to_finished_features
|
272
|
+
name = pages('finished_feature').name
|
273
|
+
assert_equal "<p>Yada yada yada <a #{{:href => 'http://test.host/wiki/show/' + name, :class => 'done'}.to_att}>#{name}</a></p>",
|
274
|
+
renderer.render_wiki_text('Yada yada yada [[FinishedFeature]]')
|
275
|
+
end
|
276
|
+
|
222
277
|
private
|
223
278
|
|
224
|
-
def url_generator;
|
279
|
+
def url_generator; TestingWikiLinkHandler.new; end
|
225
280
|
|
226
|
-
end
|
281
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2006 Pluron Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
MediaCloth is the first MediaWiki parser and html generator written in ruby.
|
2
|
+
It's small, fast and aims to recognize the complete MediaWiki language.
|
3
|
+
|
4
|
+
= INSTALLATION
|
5
|
+
To install the library run:
|
6
|
+
ruby setup.rb
|
7
|
+
|
8
|
+
|
9
|
+
= USAGE
|
10
|
+
The quickest way to parse your input and produce html formatted text is:
|
11
|
+
require 'mediacloth'
|
12
|
+
puts MediaCloth::wiki_to_html("'''Hello'''''World''!")
|
13
|
+
|
14
|
+
You can also provide a hash with custom options if you want to use another
|
15
|
+
generator or link handler:
|
16
|
+
require 'mediacloth'
|
17
|
+
puts MediaCloth::wiki_to_html("'''Hello'''''World''!",
|
18
|
+
:link_handler => MyLinkHandler.new)
|
19
|
+
|
20
|
+
Both examples should produce
|
21
|
+
<b>Hello</b><i>World</i>!
|
22
|
+
|
23
|
+
= API DOCS
|
24
|
+
To generate API documentation run:
|
25
|
+
rake rdoc
|
26
|
+
|
27
|
+
= DEVELOPMENT
|
28
|
+
If you want to modify mediacloth sources you will need:
|
29
|
+
1. Download and install RACC parser generator (http://i.loveruby.net/en/projects/racc/)
|
30
|
+
2. Execute "rake parser" to update your parser from .y definition
|
31
|
+
To run tests execute
|
32
|
+
rake test
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
task :default => [:parser]
|
6
|
+
|
7
|
+
|
8
|
+
desc 'Regenerate the parser with racc'
|
9
|
+
racc_flags=""
|
10
|
+
#racc_flags="-g -v"
|
11
|
+
file "lib/mediacloth/mediawikiparser.rb" => ["lib/mediacloth/mediawikiparser.y"] do |t|
|
12
|
+
sh "cd lib/mediacloth && racc #{racc_flags} mediawikiparser.y -o mediawikiparser.rb && cd .. && cd .."
|
13
|
+
end
|
14
|
+
task :parser => "lib/mediacloth/mediawikiparser.rb"
|
15
|
+
|
16
|
+
|
17
|
+
desc 'Test'
|
18
|
+
Rake::TestTask.new(:test => [:parser]) do |t|
|
19
|
+
t.libs << 'lib'
|
20
|
+
t.libs << 'test'
|
21
|
+
t.pattern = 'test/*.rb'
|
22
|
+
t.verbose = true
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
desc 'Generate documentation.'
|
27
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
28
|
+
rdoc.rdoc_dir = 'rdoc'
|
29
|
+
rdoc.title = 'Mediacloth'
|
30
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
31
|
+
rdoc.rdoc_files.include('README')
|
32
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#AST Node
|
2
|
+
class AST
|
3
|
+
attr_accessor :contents
|
4
|
+
attr_accessor :parent
|
5
|
+
attr_accessor :children
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@children = []
|
9
|
+
@parent = nil
|
10
|
+
@contents = ""
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
#The root node for all wiki parse trees
|
15
|
+
class WikiAST < AST
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
#The node to represent paragraph with text inside
|
20
|
+
class ParagraphAST < AST
|
21
|
+
end
|
22
|
+
|
23
|
+
#The node to represent a simple or formatted text
|
24
|
+
#with more AST nodes inside.
|
25
|
+
class FormattedAST < AST
|
26
|
+
#Currently recognized formatting: :Bold, :Italic, :Link, :InternalLink, :HLine
|
27
|
+
attr_accessor :formatting
|
28
|
+
end
|
29
|
+
|
30
|
+
#The node to represent a simple or formatted text
|
31
|
+
class TextAST < FormattedAST
|
32
|
+
#Currently recognized formatting: :Link, :InternalLink, :HLine
|
33
|
+
end
|
34
|
+
|
35
|
+
#The node to represent a simple Mediawiki link.
|
36
|
+
class LinkAST < AST
|
37
|
+
#The link's URL
|
38
|
+
attr_accessor :url
|
39
|
+
end
|
40
|
+
|
41
|
+
#The node to represent a Mediawiki internal link
|
42
|
+
class InternalLinkAST < AST
|
43
|
+
#Holds the link locator, which is composed of a resource name only (e.g. the
|
44
|
+
#name of a wiki page)
|
45
|
+
attr_accessor :locator
|
46
|
+
end
|
47
|
+
|
48
|
+
#The node to represent a MediaWiki resource reference (embedded images, videos,
|
49
|
+
#etc.)
|
50
|
+
class ResourceLinkAST < AST
|
51
|
+
#The resource prefix that indicates the type of resource (e.g. an image
|
52
|
+
#resource is prefixed by "Image")
|
53
|
+
attr_accessor :prefix
|
54
|
+
#The resource locator
|
55
|
+
attr_accessor :locator
|
56
|
+
end
|
57
|
+
|
58
|
+
class InternalLinkItemAST < AST
|
59
|
+
end
|
60
|
+
|
61
|
+
#The node to represent a table
|
62
|
+
class TableAST < AST
|
63
|
+
attr_accessor :options
|
64
|
+
end
|
65
|
+
|
66
|
+
#The node to represent a table
|
67
|
+
class TableRowAST < AST
|
68
|
+
attr_accessor :options
|
69
|
+
end
|
70
|
+
|
71
|
+
#The node to represent a table
|
72
|
+
class TableCellAST < AST
|
73
|
+
#the type of cell, :head or :body
|
74
|
+
attr_accessor :type
|
75
|
+
end
|
76
|
+
|
77
|
+
#The node to represent a list
|
78
|
+
class ListAST < AST
|
79
|
+
#Currently recognized types: :Bulleted, :Numbered
|
80
|
+
attr_accessor :list_type
|
81
|
+
end
|
82
|
+
|
83
|
+
#The node to represent a list item
|
84
|
+
class ListItemAST < AST
|
85
|
+
end
|
86
|
+
|
87
|
+
# The node to represent a leading term in a dictionary list
|
88
|
+
class ListTermAST < AST
|
89
|
+
end
|
90
|
+
|
91
|
+
# The node to represent a definition in a dictionary list
|
92
|
+
class ListDefinitionAST < AST
|
93
|
+
end
|
94
|
+
|
95
|
+
#The node to represent a section
|
96
|
+
class SectionAST < AST
|
97
|
+
#The level of the section (1,2,3...) that would correspond to
|
98
|
+
#<h1>, <h2>, <h3>, etc.
|
99
|
+
attr_accessor :level
|
100
|
+
end
|
101
|
+
|
102
|
+
#The node to represent a preformatted contents
|
103
|
+
class PreformattedAST < AST
|
104
|
+
end
|
105
|
+
|
106
|
+
#The node to represent an XHTML element and its contents
|
107
|
+
class ElementAST < AST
|
108
|
+
attr_accessor :name, :attributes
|
109
|
+
end
|
110
|
+
|
111
|
+
# The node to represent special Mediawiki keywords, such as __TOC__. The text
|
112
|
+
# attribute contains the entire string inbetween '__' and '__'.
|
113
|
+
class KeywordAST < AST
|
114
|
+
attr_accessor :text
|
115
|
+
end
|
116
|
+
|
117
|
+
# The node to represent pre-defined (or user-defined) variables, such as
|
118
|
+
# {{Date}}. The text attributes contains the entire string inbetween '{{'
|
119
|
+
# and '}}'.
|
120
|
+
class VariableAST < AST
|
121
|
+
attr_accessor :text
|
122
|
+
end
|