motiro 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/AUTHORS +15 -0
  2. data/README +2 -2
  3. data/README.en +1 -2
  4. data/README.pt-br +1 -2
  5. data/app/controllers/account_controller.rb +1 -1
  6. data/app/controllers/application.rb +13 -12
  7. data/app/controllers/javascript_controller.rb +1 -1
  8. data/app/controllers/report_controller.rb +1 -1
  9. data/app/controllers/wiki_controller.rb +3 -5
  10. data/app/core/cache_reporter.rb +1 -1
  11. data/app/core/cache_reporter_fetcher.rb +1 -1
  12. data/app/core/chief_editor.rb +1 -1
  13. data/app/core/reporter.rb +1 -1
  14. data/app/core/reporter_driver.rb +1 -1
  15. data/app/core/reporter_fetcher.rb +1 -1
  16. data/app/core/settings.rb +1 -1
  17. data/app/core/version.rb +1 -1
  18. data/app/core/wiki_reporter.rb +1 -1
  19. data/app/helpers/application_helper.rb +5 -1
  20. data/app/helpers/default_page_provider.rb +6 -2
  21. data/app/helpers/report_helper.rb +14 -1
  22. data/app/models/change.rb +1 -1
  23. data/app/models/chunk.rb +1 -1
  24. data/app/models/feed_observer.rb +1 -1
  25. data/app/models/headline.rb +1 -1
  26. data/app/models/page.rb +38 -4
  27. data/app/models/revision.rb +1 -1
  28. data/app/models/user.rb +1 -1
  29. data/app/models/wiki_reference.rb +21 -0
  30. data/app/models/wiki_sweeper.rb +17 -2
  31. data/app/ports/chdir_runner.rb +1 -1
  32. data/app/ports/runner.rb +1 -1
  33. data/app/reporters/darcs_connection.rb +1 -1
  34. data/app/reporters/darcs_reporter.rb +1 -1
  35. data/app/reporters/darcs_temp_repo.rb +1 -1
  36. data/app/reporters/events_reporter.rb +1 -1
  37. data/app/reporters/features_reporter.rb +1 -1
  38. data/app/reporters/subversion_reporter.rb +1 -1
  39. data/app/reporters/svn_connection.rb +1 -1
  40. data/app/reporters/svn_settings.rb +1 -1
  41. data/app/views/report/list.rhtml +6 -7
  42. data/app/views/report/older.rhtml +1 -2
  43. data/app/views/report/rss.rxml +1 -1
  44. data/app/views/report/show.rhtml +2 -2
  45. data/app/views/wiki/_edit_event.rhtml +2 -0
  46. data/app/views/wiki/_edit_feature.rhtml +2 -0
  47. data/app/views/wiki/_properties_edit.rhtml +3 -5
  48. data/app/views/wiki/_properties_show.rhtml +4 -5
  49. data/app/views/wiki/_show_event.rhtml +3 -0
  50. data/app/views/wiki/_show_feature.rhtml +2 -0
  51. data/app/views/wiki/show.rhtml +1 -1
  52. data/bin/motiro +3 -3
  53. data/config/routes.rb +1 -1
  54. data/db/migrate/024_add_feature_status.rb +11 -0
  55. data/db/migrate/025_add_page_references.rb +12 -0
  56. data/db/migrate/026_convert_link_syntax.rb +12 -0
  57. data/db/migrate/027_register_page_references.rb +12 -0
  58. data/db/motirodb.sqlite.initial +0 -0
  59. data/db/schema_version +1 -1
  60. data/db/translation/pt-BR.rb +7 -1
  61. data/lib/array_extensions.rb +1 -1
  62. data/lib/diff_chunk_builder.rb +1 -1
  63. data/lib/differ.rb +1 -1
  64. data/lib/string_extensions.rb +13 -6
  65. data/lib/stub_hash.rb +1 -1
  66. data/lib/tasks/packaging.rake +10 -12
  67. data/lib/tasks/testing.rake +1 -1
  68. data/lib/tick_daemon.rb +1 -1
  69. data/lib/{wiki_url_generator.rb → wiki_link_handler.rb} +13 -3
  70. data/lib/wiki_renderer.rb +63 -34
  71. data/public/images/done.png +0 -0
  72. data/public/images/not-done.png +0 -0
  73. data/public/stylesheets/motiro.css +8 -0
  74. data/script/ticker +1 -1
  75. data/test/acceptance/account_test.rb +1 -1
  76. data/test/acceptance/darcs_test.rb +1 -1
  77. data/test/acceptance/events_test.rb +1 -1
  78. data/test/acceptance/main_page_test.rb +1 -1
  79. data/test/acceptance/subversion_test.rb +1 -1
  80. data/test/acceptance/ts_all_suites.rb +1 -1
  81. data/test/acceptance/wiki_test.rb +3 -3
  82. data/test/contract/darcs_test.rb +1 -1
  83. data/test/contract/remote_darcs_test.rb +1 -1
  84. data/test/contract/svn_test.rb +1 -1
  85. data/test/fixtures/pages.yml +20 -1
  86. data/test/fixtures/revisions.yml +40 -1
  87. data/test/fixtures/wiki_references.yml +5 -0
  88. data/test/functional/report_controller_test.rb +1 -1
  89. data/test/functional/report_features_test.rb +8 -1
  90. data/test/functional/report_subversion_test.rb +1 -1
  91. data/test/functional/root_controller_test.rb +1 -1
  92. data/test/functional/wiki_controller_test.rb +67 -2
  93. data/test/lib/acceptance_test_case.rb +1 -1
  94. data/test/lib/darcs_excerpts.rb +1 -1
  95. data/test/lib/darcs_repo.rb +1 -1
  96. data/test/lib/hash_extensions.rb +22 -0
  97. data/test/lib/live_mode_test.rb +1 -1
  98. data/test/lib/netutils.rb +1 -1
  99. data/test/lib/platform_thread.rb +1 -1
  100. data/test/lib/selenium_extensions.rb +1 -1
  101. data/test/lib/stubio.rb +1 -1
  102. data/test/lib/webserver.rb +1 -1
  103. data/test/meta/darcs_repo_test.rb +1 -1
  104. data/test/meta/local_svn_test.rb +1 -1
  105. data/test/meta/platform_thread_test.rb +1 -1
  106. data/test/meta/stubio_test.rb +1 -1
  107. data/test/stubs/{url_generator.rb → wiki_link_handler.rb} +8 -4
  108. data/test/test_helper.rb +3 -1
  109. data/test/unit/array_extensions_test.rb +1 -1
  110. data/test/unit/cache_reporter_fetcher_test.rb +1 -1
  111. data/test/unit/cache_reporter_test.rb +1 -1
  112. data/test/unit/change_test.rb +1 -1
  113. data/test/unit/chdir_runner_test.rb +1 -1
  114. data/test/unit/chief_editor_test.rb +1 -1
  115. data/test/unit/darcs_connection_test.rb +1 -1
  116. data/test/unit/darcs_reporter_test.rb +4 -4
  117. data/test/unit/darcs_temp_repo_test.rb +1 -1
  118. data/test/unit/default_page_provider_test.rb +23 -13
  119. data/test/unit/diff_chunk_builder_test.rb +1 -1
  120. data/test/unit/page_test.rb +67 -4
  121. data/test/unit/reporter_driver_test.rb +1 -1
  122. data/test/unit/reporter_test.rb +1 -1
  123. data/test/unit/revision_test.rb +1 -1
  124. data/test/unit/runner_test.rb +1 -1
  125. data/test/unit/string_extensions_test.rb +15 -3
  126. data/test/unit/svn_connection_test.rb +1 -1
  127. data/test/unit/svn_reporter_interaction_test.rb +1 -1
  128. data/test/unit/svn_reporter_test.rb +1 -1
  129. data/test/unit/svn_settings_test.rb +1 -1
  130. data/test/unit/user_test.rb +1 -1
  131. data/test/unit/{wiki_url_generator_test.rb → wiki_link_handler_test.rb} +3 -3
  132. data/test/unit/wiki_renderer_test.rb +75 -20
  133. data/test/unit/wiki_reporter_test.rb +1 -1
  134. data/vendor/mediacloth-trunk/MIT-LICENSE +20 -0
  135. data/vendor/mediacloth-trunk/README +32 -0
  136. data/vendor/mediacloth-trunk/Rakefile +33 -0
  137. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiast.rb +122 -0
  138. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikihtmlgenerator.rb +252 -0
  139. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikilexer.rb +821 -0
  140. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikilinkhandler.rb +68 -0
  141. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparams.rb +33 -0
  142. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparser.rb +1218 -0
  143. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiparser.y +493 -0
  144. data/vendor/mediacloth-trunk/lib/mediacloth/mediawikiwalker.rb +146 -0
  145. data/vendor/mediacloth-trunk/lib/mediacloth.rb +29 -0
  146. data/vendor/mediacloth-trunk/mediacloth.gemspec +24 -0
  147. data/vendor/mediacloth-trunk/mediacloth.kdevelop +117 -0
  148. data/vendor/mediacloth-trunk/setup.rb +1585 -0
  149. data/vendor/mediacloth-trunk/test/data/html1 +26 -0
  150. data/vendor/mediacloth-trunk/test/data/html10 +130 -0
  151. data/vendor/mediacloth-trunk/test/data/html11 +17 -0
  152. data/vendor/mediacloth-trunk/test/data/html12 +12 -0
  153. data/vendor/mediacloth-trunk/test/data/html13 +11 -0
  154. data/vendor/mediacloth-trunk/test/data/html2 +2 -0
  155. data/vendor/mediacloth-trunk/test/data/html3 +1 -0
  156. data/vendor/mediacloth-trunk/test/data/html4 +47 -0
  157. data/vendor/mediacloth-trunk/test/data/html5 +57 -0
  158. data/vendor/mediacloth-trunk/test/data/html6 +8 -0
  159. data/vendor/mediacloth-trunk/test/data/html7 +45 -0
  160. data/vendor/mediacloth-trunk/test/data/html8 +1 -0
  161. data/vendor/mediacloth-trunk/test/data/html9 +14 -0
  162. data/vendor/mediacloth-trunk/test/data/input1 +34 -0
  163. data/vendor/mediacloth-trunk/test/data/input10 +124 -0
  164. data/vendor/mediacloth-trunk/test/data/input11 +17 -0
  165. data/vendor/mediacloth-trunk/test/data/input12 +15 -0
  166. data/vendor/mediacloth-trunk/test/data/input13 +10 -0
  167. data/vendor/mediacloth-trunk/test/data/input2 +2 -0
  168. data/vendor/mediacloth-trunk/test/data/input3 +2 -0
  169. data/vendor/mediacloth-trunk/test/data/input4 +50 -0
  170. data/vendor/mediacloth-trunk/test/data/input5 +63 -0
  171. data/vendor/mediacloth-trunk/test/data/input6 +8 -0
  172. data/vendor/mediacloth-trunk/test/data/input7 +45 -0
  173. data/vendor/mediacloth-trunk/test/data/input8 +1 -0
  174. data/vendor/mediacloth-trunk/test/data/input9 +14 -0
  175. data/vendor/mediacloth-trunk/test/data/lex1 +26 -0
  176. data/vendor/mediacloth-trunk/test/data/lex10 +85 -0
  177. data/vendor/mediacloth-trunk/test/data/lex11 +17 -0
  178. data/vendor/mediacloth-trunk/test/data/lex12 +15 -0
  179. data/vendor/mediacloth-trunk/test/data/lex13 +3 -0
  180. data/vendor/mediacloth-trunk/test/data/lex2 +2 -0
  181. data/vendor/mediacloth-trunk/test/data/lex3 +1 -0
  182. data/vendor/mediacloth-trunk/test/data/lex4 +47 -0
  183. data/vendor/mediacloth-trunk/test/data/lex5 +57 -0
  184. data/vendor/mediacloth-trunk/test/data/lex6 +8 -0
  185. data/vendor/mediacloth-trunk/test/data/lex7 +45 -0
  186. data/vendor/mediacloth-trunk/test/data/lex8 +1 -0
  187. data/vendor/mediacloth-trunk/test/data/lex9 +14 -0
  188. data/vendor/mediacloth-trunk/test/data/result1 +48 -0
  189. data/vendor/mediacloth-trunk/test/dataproducers/html.rb +18 -0
  190. data/vendor/mediacloth-trunk/test/dataproducers/lex.rb +15 -0
  191. data/vendor/mediacloth-trunk/test/debugwalker.rb +68 -0
  192. data/vendor/mediacloth-trunk/test/htmlgenerator.rb +97 -0
  193. data/vendor/mediacloth-trunk/test/lexer.rb +542 -0
  194. data/vendor/mediacloth-trunk/test/linkhandler.rb +39 -0
  195. data/vendor/mediacloth-trunk/test/parser.rb +22 -0
  196. data/vendor/mediacloth-trunk/test/testhelper.rb +27 -0
  197. data/vendor/mediacloth.rb +3 -0
  198. data/vendor/motiro-installer.rb +1 -1
  199. data/vendor/plugins/cache_test-0.2/CHANGELOG +14 -0
  200. data/vendor/plugins/cache_test-0.2/MIT-LICENSE +20 -0
  201. data/vendor/plugins/cache_test-0.2/README +124 -0
  202. data/vendor/plugins/cache_test-0.2/init.rb +8 -0
  203. data/vendor/plugins/cache_test-0.2/lib/fragment_cache_test.rb +205 -0
  204. data/vendor/plugins/cache_test-0.2/lib/page_cache_test.rb +140 -0
  205. data/vendor/plugins/global_routing/init.rb +1 -1
  206. metadata +517 -455
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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 '<h1>Motiro</h1><p>Another paragraph</p>', str.medialize
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
- end
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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 WikiUrlGeneratorTest < Test::Unit::TestCase
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', WikiUrlGenerator.new(cont).generate_url_for('MyPage')
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-2007 Thiago Arrais
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/url_generator'
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 = '<h1>Motiro</h1><p>This is project Motiro</p>'
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\" rel=\"nofollow\">Nowhere</a></p>"
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
- expected = "<p><a href=\"http://test.host/wiki/show/AnotherPage\" rel=\"nofollow\">go somewhere else</a></p>"
59
- assert_equal expected, renderer.render_wiki_text('[AnotherPage go somewhere else]')
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
- expected = "<p><a href=\"http://test.host/wiki/show/InternalPage\" rel=\"nofollow\">go there</a> <a href=\"http://test.host/wiki/show/OtherInternalPage\" rel=\"nofollow\">and there</a></p>"
64
- assert_equal expected, renderer.render_wiki_text("[InternalPage go there] " +
65
- "[OtherInternalPage and there]")
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\" rel=\"nofollow\">AnotherPage</a></p>"
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\" rel=\"nofollow\">placed an opening bracket [ inside the link text, but Motiro managed to recover correctly</a></p>",
80
- renderer.render_wiki_text("[SomeoneMistankenly placed an opening bracket [ inside the link text, but Motiro managed to recover correctly]")
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" rel="nofollow"><span style="background: #ffb8b8">link</span></a>' +
139
- '<a href="http://www.motiro.com" rel="nofollow"><span style="background: #b8ffb8">link</span></a></p>',
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">Sub</span>' +
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; TestingUrlGenerator.new; end
279
+ def url_generator; TestingWikiLinkHandler.new; end
225
280
 
226
- end
281
+ end
@@ -1,5 +1,5 @@
1
1
  # Motiro - A project tracking tool
2
- # Copyright (C) 2006-2007 Thiago Arrais
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
@@ -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