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
@@ -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 '<'
|
41
|
+
when '>' then '>'
|
42
|
+
when '&' then '&'
|
43
|
+
when '"' then '"'
|
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
|