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
@@ -0,0 +1,252 @@
1
+ require 'mediacloth/mediawikiwalker'
2
+ require 'mediacloth/mediawikiparams'
3
+
4
+ #HTML generator for a MediaWiki parse tree
5
+ #
6
+ #Typical use case:
7
+ # parser = MediaWikiParser.new
8
+ # parser.lexer = MediaWikiLexer.new
9
+ # ast = parser.parse(input)
10
+ # walker = MediaWikiHTMLGenerator.new
11
+ # walker.parse(ast)
12
+ # puts walker.html
13
+ class MediaWikiHTMLGenerator < MediaWikiWalker
14
+
15
+ attr_reader :html
16
+
17
+ def parse(ast)
18
+ @html = ""
19
+ @ast = ast
20
+ @html = super(ast)
21
+ end
22
+
23
+ #Set this generator's URL handler.
24
+ def link_handler=(handler)
25
+ @link_handler = handler
26
+ end
27
+
28
+ #Returns's this generator URL handler. If no handler was set, returns the
29
+ #default handler.
30
+ def link_handler
31
+ @link_handler ||= MediaWikiLinkHandler.new
32
+ end
33
+
34
+ # Utility method that returns the string with '<', '>', '&' and '"' escaped as
35
+ # XHTML character entities
36
+ def MediaWikiHTMLGenerator.escape(str)
37
+ r = str.gsub(%r{[<>&"]}) do
38
+ |match|
39
+ case match
40
+ when '<' then '&lt;'
41
+ when '>' then '&gt;'
42
+ when '&' then '&amp;'
43
+ when '"' then '&quot;'
44
+ end
45
+ end
46
+ r
47
+ end
48
+
49
+ # Utility method that converts the string specified into a specially formatted text
50
+ # string which can be used as an XHTML link anchor name.
51
+ def MediaWikiHTMLGenerator.anchor_for(str)
52
+ str.strip.squeeze(' ').gsub(' ', '_')
53
+ end
54
+
55
+
56
+ protected
57
+
58
+ def parse_wiki_ast(ast)
59
+ super(ast).join
60
+ end
61
+
62
+ def parse_paragraph(ast)
63
+ if ast.children
64
+ "<p>" + super(ast) + "</p>"
65
+ else
66
+ "<p><br /></p>"
67
+ end
68
+ end
69
+
70
+ def parse_text(ast)
71
+ if ast.formatting
72
+ case(ast.formatting)
73
+ when :None then MediaWikiHTMLGenerator.escape(ast.contents)
74
+ when :CharacterEntity then "&#{ast.contents};"
75
+ when :HLine then "<hr></hr>"
76
+ when :SignatureDate then MediaWikiParams.instance.time.to_s
77
+ when :SignatureName then MediaWikiParams.instance.author
78
+ when :SignatureFull then MediaWikiParams.instance.author + " " + MediaWikiParams.instance.time.to_s
79
+ end
80
+ else
81
+ escape(ast.contents)
82
+ end
83
+ end
84
+
85
+ def parse_formatted(ast)
86
+ tag = ast.formatting == :Bold ? 'b' : 'i'
87
+ "<#{tag}>" + super(ast) + "</#{tag}>"
88
+ end
89
+
90
+ def parse_list(ast)
91
+ tag = list_tag(ast)
92
+ (["<#{tag}>"] +
93
+ super(ast) +
94
+ ["</#{tag}>"]).join
95
+ end
96
+
97
+ def parse_list_item(ast)
98
+ "<li>" + super(ast) + "</li>"
99
+ end
100
+
101
+ def parse_list_term(ast)
102
+ "<dt>" + super(ast) + "</dt>"
103
+ end
104
+
105
+ def parse_list_definition(ast)
106
+ "<dd>" + super(ast) + "</dd>"
107
+ end
108
+
109
+ def parse_preformatted(ast)
110
+ "<pre>" + super(ast) + "</pre>"
111
+ end
112
+
113
+ def parse_section(ast)
114
+ generator = TextGenerator.new
115
+ anchor = MediaWikiHTMLGenerator.anchor_for(generator.parse(ast).join(' '))
116
+ "<h#{ast.level}><a name='#{anchor}'></a>" + super(ast) + "</h#{ast.level}>"
117
+ end
118
+
119
+ def parse_internal_link(ast)
120
+ text = parse_wiki_ast(ast)
121
+ text = MediaWikiHTMLGenerator.escape(ast.locator) if text.length == 0
122
+ link_handler.link_for(ast.locator, text)
123
+ end
124
+
125
+ def parse_resource_link(ast)
126
+ options = ast.children.map do |node|
127
+ parse_internal_link_item(node)
128
+ end
129
+ link_handler.link_for_resource(ast.prefix, ast.locator, options)
130
+ end
131
+
132
+ def parse_internal_link_item(ast)
133
+ text = super(ast)
134
+ text.strip
135
+ end
136
+
137
+ def parse_link(ast)
138
+ text = super(ast)
139
+ href = ast.url
140
+ text = MediaWikiHTMLGenerator.escape(href) if text.length == 0
141
+ "<a href=\"#{href}\">#{text}</a>"
142
+ end
143
+
144
+ #Reimplement this
145
+ def parse_table(ast)
146
+ options = ast.options ? ' ' + ast.options.strip : ''
147
+ "<table#{options}>" + super(ast) + "</table>\n"
148
+ end
149
+
150
+ #Reimplement this
151
+ def parse_table_row(ast)
152
+ options = ast.options ? ' ' + ast.options.strip : ''
153
+ "<tr#{options}>" + super(ast) + "</tr>\n"
154
+ end
155
+
156
+ #Reimplement this
157
+ def parse_table_cell(ast)
158
+ if ast.type == :head
159
+ "<th>" + super(ast) + "</th>"
160
+ else
161
+ "<td>" + super(ast) + "</td>"
162
+ end
163
+ end
164
+
165
+ def parse_element(ast)
166
+ attr = ''
167
+ if ast.attributes
168
+ attr = ' ' + ast.attributes.collect{ |name, value|
169
+ name + '="' + MediaWikiHTMLGenerator.escape(value) + '"' }.join(' ')
170
+ end
171
+ if ast.children.size == 0
172
+ "<#{ast.name}#{attr} />"
173
+ else
174
+ "<#{ast.name}#{attr}>" + super(ast) + "</#{ast.name}>"
175
+ end
176
+ end
177
+
178
+ def parse_keyword(ast)
179
+ if ast.text == 'TOC'
180
+ generator = TocGenerator.new
181
+ generator.parse(@ast)
182
+ generator.html
183
+ end
184
+ end
185
+
186
+ #returns a tag name of the list in ast node
187
+ def list_tag(ast)
188
+ if ast.list_type == :Bulleted
189
+ return "ul"
190
+ elsif ast.list_type == :Numbered
191
+ return "ol"
192
+ elsif ast.list_type == :Dictionary
193
+ return "dl"
194
+ end
195
+ end
196
+
197
+ # AST walker that generates a table of contents, containing links to all
198
+ # section headings in the page.
199
+ class TocGenerator < MediaWikiHTMLGenerator
200
+
201
+ def parse(ast)
202
+ @html = ''
203
+ @text_generator = TextGenerator.new
204
+ @counter = []
205
+ @level = 0
206
+ ast.children.each do
207
+ |child|
208
+ if child.class == SectionAST
209
+ @html += parse_section(child)
210
+ end
211
+ end
212
+ while @level > 0 do
213
+ @html += '</ul>'
214
+ @level -= 1
215
+ end
216
+ end
217
+
218
+ protected
219
+
220
+ def parse_section(ast)
221
+ level = ast.level
222
+ html = ''
223
+ while @level > level do
224
+ html += '</ul>'
225
+ @level -= 1
226
+ end
227
+ while @level < level do
228
+ @counter[@level] = 0
229
+ html += '<ul>'
230
+ @level += 1
231
+ end
232
+ @counter[@level - 1] += 1
233
+ anchor = MediaWikiHTMLGenerator.anchor_for(@text_generator.parse(ast).join(' '))
234
+ html += "<li>#{@counter[0 ... @level].join('.')} <a href='##{anchor}'>#{parse_wiki_ast(ast)}</a></li>\n"
235
+ html
236
+ end
237
+
238
+ end
239
+
240
+
241
+ # AST walker that outputs just the text portions of a page.
242
+ class TextGenerator < MediaWikiWalker
243
+
244
+ protected
245
+
246
+ def parse_text(ast)
247
+ MediaWikiHTMLGenerator.escape(ast.contents)
248
+ end
249
+
250
+ end
251
+
252
+ end