Wiki2Go 1.16.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/lib/Web2Go/CGIRequest.rb +40 -8
  2. data/lib/Web2Go/MockRequest.rb +11 -2
  3. data/lib/Web2Go/WebrickRequest.rb +4 -0
  4. data/lib/Wiki2Go/DotGraphics.rb +1 -1
  5. data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +1537 -13
  6. data/lib/Wiki2Go/Install/config/mime.types.conf +49 -0
  7. data/lib/Wiki2Go/Install/config/passwords +1 -1
  8. data/lib/Wiki2Go/Install/make_repository.rb +3 -2
  9. data/lib/Wiki2Go/Install/make_site.rb +222 -19
  10. data/lib/Wiki2Go/Install/site/error.html +52 -52
  11. data/lib/Wiki2Go/Install/templates/admin_pages/commit_site.txt +5 -1
  12. data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +8 -2
  13. data/lib/Wiki2Go/Install/templates/admin_pages/editfiles.txt +52 -7
  14. data/lib/Wiki2Go/Install/templates/admin_pages/greylist.txt +6 -3
  15. data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +5 -2
  16. data/lib/Wiki2Go/Install/templates/admin_pages/regenerate.txt +4 -1
  17. data/lib/Wiki2Go/Install/templates/admin_pages/removespam.txt +4 -1
  18. data/lib/Wiki2Go/Install/templates/admin_pages/show_log.txt +5 -1
  19. data/lib/Wiki2Go/Install/templates/admin_pages/update_blacklist.txt +4 -1
  20. data/lib/Wiki2Go/Install/templates/admin_pages/update_conflicts.txt +4 -1
  21. data/lib/Wiki2Go/Install/templates/admin_pages/update_site.txt +5 -1
  22. data/lib/Wiki2Go/Install/templates/full_footer.htm +2 -2
  23. data/lib/Wiki2Go/Install/templates/simple_footer.htm +1 -1
  24. data/lib/Wiki2Go/LineFormatter.rb +41 -31
  25. data/lib/Wiki2Go/Web.rb +1 -22
  26. data/lib/Wiki2Go/Wiki2GoServlet.rb +11 -4
  27. data/test/TestFormatter.rb +11 -11
  28. data/test/TestLineFormatter.rb +37 -37
  29. data/test/TestRepositoryMaker.rb +1 -1
  30. data/test/TestWeb.rb +3 -4
  31. data/test/TestWeb2Go.rb +5 -6
  32. data/test/TestWiki2GoServlet.rb +95 -74
  33. data/test/testdata/expected_edit.html +10 -10
  34. data/test/testdata/expected_out.html +22 -22
  35. data/test/testdata/expected_put.html +10 -10
  36. data/test/testdata/expected_save.html +11 -11
  37. data/test/testdata/expected_savehtml.html +11 -11
  38. data/test/testdata/expected_search.html +8 -8
  39. data/test/testdata/expected_upload.html +11 -11
  40. data/test/testdata/expected_view.html +22 -22
  41. metadata +3 -2
@@ -1,33 +1,78 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ @formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
5
+
6
+ def show_directory(dirname,label)
7
+ "<a href=\"#{ @formatter.make_verb_url('admin','editfiles')}?dir=#{CGI::escape(dirname)}\">&gt;#{label}</a>"
8
+ end
2
9
 
3
- def edit_file(filename)
4
- "<a href=\"#{ File.join(@web.script_prefix,'admin','edit')}?file=#{CGI::escape(filename)}\">#{filename}</a>"
10
+ def up_directory(dirname)
11
+ "<a href=\"#{ @formatter.make_verb_url('admin','editfiles')}?dir=#{CGI::escape(dirname)}\">..</a>"
12
+ end
13
+
14
+ def edit_file(filename,label)
15
+ "<a href=\"#{ @formatter.make_verb_url('admin','edit')}?file=#{CGI::escape(filename)}\">#{label}</a>"
5
16
  end
6
17
  %>
7
18
 
8
19
  <%
9
20
  all_files = []
10
21
 
11
- Dir.chdir(@config.root_directory)
12
- files = Dir.glob('**/*')
22
+ dir = @request.parameter('dir','')
23
+
24
+ Dir.chdir(File.join(@config.root_directory,dir))
13
25
 
14
- all_files = files.find_all { |name| File.file?(File.join(@config.root_directory,name)) && name !~ /CVS/ }.sort
15
- all_files = all_files.reject do |name|
26
+ if dir.length > 0 then
27
+ up = File.expand_path(File.join('..'))
28
+ up = up[@config.root_directory.length,up.length-@config.root_directory.length]
29
+ else
30
+ up = nil
31
+ end
32
+
33
+ files = Dir.glob('*')
34
+
35
+ all_files = files.reject do |name|
36
+ File.directory?(name) ||
16
37
  name =~ /\.png$/ || name =~ /\.jpg$/ || name =~ /\.gif$/ || name =~ /\.pdf$/ || name =~ /\.xls$/
17
38
  end
39
+ all_files = all_files.sort
40
+
41
+ directories = files.reject do |name|
42
+ name =~ /CVS/ || !File.directory?(name)
43
+ end
18
44
 
45
+ directories = directories.sort
46
+
19
47
  odd = false
20
48
  %>
21
49
 
22
50
  <h3>Site files</h3>
23
51
 
52
+ <h4><%= dir %></h4>
53
+ <table class="topiclist">
54
+ <%
55
+ if !up.nil? then
56
+ %>
57
+ <tr class="odd"><td><%= up_directory(up) %></td></tr>
58
+ <%
59
+ end
60
+ %>
61
+ <% directories.each do |directory|
62
+ style = (odd ? "odd" : "even")
63
+ odd = !odd
64
+ %>
65
+ <tr class="<%= style%>"><td><%= show_directory(File.join(dir,directory),directory) %></td></tr>
66
+ <% end %>
67
+ </table>
68
+
24
69
  <% if all_files.length > 0 then %>
25
70
  <table class="topiclist">
26
71
  <% all_files.each do |file|
27
72
  style = (odd ? "odd" : "even")
28
73
  odd = !odd
29
74
  %>
30
- <tr class="<%= style%>"><td><%= edit_file(file) %></td></tr>
75
+ <tr class="<%= style%>"><td><%= edit_file(File.join(dir,file),file) %></td></tr>
31
76
  <% end %>
32
77
  </table>
33
78
  <% end %>
@@ -1,5 +1,8 @@
1
1
  <%
2
- require 'Wiki2Go/SpamFilter'
2
+ require 'Wiki2Go/SpamFilter'
3
+ require 'Wiki2Go/WikiFormatter'
4
+
5
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
3
6
 
4
7
  spamfilter = Wiki2Go::SpamFilter.new(@config)
5
8
 
@@ -36,14 +39,14 @@ supects = spamfilter.greylist_suspects
36
39
  <td><%= name%></td>
37
40
  <td><a href="<%= clean_url %>" target="_blank"><%= clean_url %></a></td>
38
41
  <td>
39
- <form action="<%= File.join(@web.script_prefix,'admin','greylist')%>" method="GET">
42
+ <form action="<%= formatter.make_verb_url('admin','greylist')%>" method="GET">
40
43
  <input type="submit" name="accept" value="Accept">
41
44
  <input type="hidden" name="author" value="<%= name %>">
42
45
  <input type="hidden" name="url" value="<%= clean_url %>">
43
46
  </form>
44
47
  </td>
45
48
  <td>
46
- <form action="<%= File.join(@web.script_prefix,'admin','greylist')%>" method="GET">
49
+ <form action="<%= formatter.make_verb_url('admin','greylist')%>" method="GET">
47
50
  <input type="hidden" name="author" value="<%= name %>">
48
51
  <input type="hidden" name="url" value="<%= clean_url %>">
49
52
  <input type="submit" name="blacklist" value="Blacklist">
@@ -1,4 +1,7 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
2
5
 
3
6
  passwords = File.join(@config.root_directory,'config','passwords')
4
7
  exists = File.exists?(passwords)
@@ -50,7 +53,7 @@ end
50
53
  %>
51
54
  <tr class="<%= style%>"><td><%= name%></td><td><%= pwd %></td>
52
55
  <td>
53
- <form action="<%= File.join(@web.script_prefix,'admin','passwords')%>" method="GET">
56
+ <form action="<%= formatter.make_verb_url('admin','passwords')%>" method="GET">
54
57
  <input type="submit" name="remove" value="Delete">
55
58
  <input type="hidden" name="user" value="<%= name %>">
56
59
  </form>
@@ -58,7 +61,7 @@ end
58
61
  </tr>
59
62
  <% end %>
60
63
  </table>
61
- <form action="<%= File.join(@web.script_prefix,'admin','passwords')%>" method="GET">
64
+ <form action="<%= formatter.make_verb_url('admin','passwords')%>" method="GET">
62
65
  <table>
63
66
  <tr><td>Name</td><td><input name="user" value="<%= user %>"></td></tr>
64
67
  <tr><td>Password</td><td><input name="password" value="<%= user_pwd %>"></td></tr>
@@ -1,5 +1,8 @@
1
1
  <%
2
2
  require 'Wiki2Go/Wiki2Go'
3
+ require 'Wiki2Go/WikiFormatter'
4
+
5
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
3
6
 
4
7
  output = ''
5
8
  subwiki = @request.params['wiki']
@@ -20,7 +23,7 @@
20
23
  %>
21
24
  <ul>
22
25
  <% subwikis.each do |subwiki| %>
23
- <li><a href="<%= File.join(@web.script_prefix,'admin','regenerate') %>?wiki=<%= subwiki %>">Generate static HTML for '<%= (subwiki.empty? ? '&lt;whole site&gt;' : subwiki) %>'</a>
26
+ <li><a href="<%= formatter.make_verb_url('admin','regenerate') %>?wiki=<%= subwiki %>">Generate static HTML for '<%= (subwiki.empty? ? '&lt;whole site&gt;' : subwiki) %>'</a>
24
27
  <% end %>
25
28
  </ul>
26
29
  <hr>
@@ -1,4 +1,7 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
2
5
 
3
6
  username = ''
4
7
  bad_user = @request.params['bad_user']
@@ -11,7 +14,7 @@ end
11
14
  <% if username.length > 0 then %>
12
15
  Remove spam added by <%= username %>
13
16
  <% end %>
14
- <form action="<%= File.join(@web.script_prefix,'admin','removespam')%>" method="GET">
17
+ <form action="<%= formatter.make_verb_url('admin','removespam')%>" method="GET">
15
18
  <table>
16
19
  <tr><td>Name</td><td><input name="bad_user" value="<%= username%>"></td></tr>
17
20
  <tr><td colspan=2><input type="submit" name="Erase" value="Erase"></td></tr>
@@ -1,4 +1,8 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
5
+
2
6
  output = ''
3
7
 
4
8
  doit = @request.parameter('show',nil)
@@ -12,7 +16,7 @@
12
16
  %>
13
17
 
14
18
  <h3>View log</h3>
15
- <form action="<%= File.join(@web.script_prefix,'admin','show_log')%>" method="get">
19
+ <form action="<%= formatter.make_verb_url('admin','show_log')%>" method="get">
16
20
  <button type="submit" name="show" value="show">
17
21
  Show logfile
18
22
  </button>
@@ -1,6 +1,9 @@
1
1
  <%
2
2
  require 'Wiki2Go/SpamFilter'
3
3
  require 'cgi'
4
+ require 'Wiki2Go/WikiFormatter'
5
+
6
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
4
7
 
5
8
  output = ''
6
9
  doit = @request.parameter('update',nil)
@@ -11,7 +14,7 @@
11
14
  end
12
15
  %>
13
16
  <h3>Download the blacklist from http://blacklist.chongqed.org/index.html</h3>
14
- <form action="<%= File.join(@web.script_prefix,'admin','update_blacklist')%>" method="get">
17
+ <form action="<%= formatter.make_verb_url('admin','update_blacklist')%>" method="get">
15
18
  <input type="submit" name="update" value="Download">
16
19
  </form>
17
20
  <%= CGI::escapeHTML(output).gsub(/\n/,'<br>') %>
@@ -1,7 +1,10 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
2
5
 
3
6
  def edit_file(filename)
4
- "<a href=\"#{ File.join(@web.script_prefix,'admin','edit')}?file=#{CGI::escape(filename)}\">#{filename}</a>"
7
+ "<a href=\"#{ formatter.make_verb_url('admin','edit')}?file=#{CGI::escape(filename)}\">#{filename}</a>"
5
8
  end
6
9
 
7
10
  def contains_conflict_marker(name)
@@ -1,4 +1,8 @@
1
1
  <%
2
+ require 'Wiki2Go/WikiFormatter'
3
+
4
+ formatter = Wiki2Go::Formatter.new(@web,@config.storage,@config,true,@config.editable?(@web))
5
+
2
6
  output = ''
3
7
 
4
8
  doit = @request.parameter('update',nil)
@@ -18,7 +22,7 @@
18
22
  %>
19
23
 
20
24
  <h3>Update Site</h3>
21
- <form action="<%= File.join(@web.script_prefix,'admin','update_site')%>" method="get">
25
+ <form action="<%= formatter.make_verb_url('admin','update_site')%>" method="get">
22
26
  <button type="submit" name="update" value="update">
23
27
  Update the site from repository
24
28
  </button>
@@ -23,12 +23,12 @@
23
23
  </TR>
24
24
  <TR>
25
25
  <td>Changed on <%= current.page.lastmodified.strftime("%d/%m/%Y") %> by <%= current.page.alias%>
26
- <a href="<%= current.format.resource_url('rss.xml')%>"><img src="html/rssLogo.png" width="36" height="14" border="0" alt="Keep up to date"></a>
26
+ <a href="<%= current.format.resource_url('rss.xml')%>"><img src="/html/rssLogo.png" width="36" height="14" border="0" alt="Keep up to date"></a>
27
27
  </td>
28
28
  <TD align="right">
29
29
  Contact the site administrator: <%= current.format.encodeMailTo(current.config.site_admin) %>
30
30
  <a target="_blank" href="http://validator.w3.org/check?uri=<%= current.format.absolute_url %>">
31
- <img border="0" src="html/valid-html401.png" alt="Verify if layout is correct!" height="31" width="88"></a>
31
+ <img border="0" src="/html/valid-html401.png" alt="Verify if layout is correct!" height="31" width="88"></a>
32
32
  </TD>
33
33
  </TR>
34
34
  </TABLE>
@@ -8,7 +8,7 @@
8
8
  </TD>
9
9
  </TR>
10
10
  <TR>
11
- <td><a href="<%= current.format.resource_url('rss.xml')%>"><img src="html/rssLogo.png" width="36" height="14" border="0" alt="Keep informed"></a></td>
11
+ <td><a href="<%= current.format.resource_url('rss.xml')%>"><img src="/html/rssLogo.png" width="36" height="14" border="0" alt="Keep informed"></a></td>
12
12
  <TD align="right">
13
13
  Contact the site administrator: <%= current.format.encodeMailTo(current.config.site_admin) %>
14
14
  </TD>
@@ -41,16 +41,37 @@ module Wiki2Go
41
41
 
42
42
  def formatting_done
43
43
  emit_bullets
44
- @pre_line
44
+ result =@pre_line
45
+ @pre_line = ''
46
+ result
47
+ end
48
+
49
+ # Return the path to the script verb, with the right extension and parameters
50
+ # * verb = name of the verb (view, edit,...)
51
+ # * parameters = further parameters: web.name, web.current_page, ...
52
+ def make_verb_url(verb,*parameters)
53
+ make_url(@web.script_prefix,verb + @web.script_extension,*parameters)
45
54
  end
46
55
 
56
+ # Return the path to the given resource. Nil and empty parameters are ignored
57
+ # The generated url is relative to the root of the site
58
+ def make_url(*parameters)
59
+ result = @web.subsite.empty? ? '' : ('/' + @web.subsite)
60
+ parameters.each do |name|
61
+ if !name.nil? and !name.empty? then
62
+ result += '/'
63
+ result += name
64
+ end
65
+ end
66
+ result.squeeze('/')
67
+ end
47
68
 
48
69
  def absolute_url
49
- return @web.base_url + view_page_url(@web.name,@web.current_page)
70
+ absolute_url_of_topic(@web.current_page)
50
71
  end
51
72
 
52
73
  def absolute_url_of_topic(topic)
53
- return @web.base_url + view_page_url(@web.name,topic)
74
+ return @web.base_url.chop + view_page_url(@web.name,topic)
54
75
  end
55
76
 
56
77
  def edit_link(subwiki,page,name)
@@ -63,7 +84,7 @@ module Wiki2Go
63
84
 
64
85
  def edit_this_link(subwiki,page,name)
65
86
  if @editable then
66
- return "<a href=\"#{join(@web.script_prefix,"edit"+@web.script_extension,subwiki,page)}\">#{name}</a>"
87
+ return "<a href=\"#{make_verb_url('edit',subwiki,page)}\">#{name}</a>"
67
88
  else
68
89
  return ""
69
90
  end
@@ -71,22 +92,22 @@ module Wiki2Go
71
92
 
72
93
  def save_this_link(subwiki,page)
73
94
  if @editable then
74
- return join(@web.script_prefix,"save"+@web.script_extension,subwiki,page)
95
+ return make_verb_url('save',subwiki,page)
75
96
  else
76
97
  return page
77
98
  end
78
99
  end
79
100
 
80
101
  def verb_url(verb)
81
- return join(@web.script_prefix,verb+@web.script_extension,@web.name,@web.current_page)
102
+ return make_verb_url(verb,@web.name,@web.current_page)
82
103
  end
83
104
 
84
105
  def removespam_url(user)
85
- return join(@web.script_prefix,'removespam'+@web.script_extension,@web.name,'') + '?user=' + user
106
+ return make_verb_url('removespam',@web.name,'') + '?user=' + user
86
107
  end
87
108
 
88
109
  def version_url(page)
89
- return join(@web.script_prefix,'versions'+@web.script_extension,@web.name,page)
110
+ return make_verb_url('versions',@web.name,page)
90
111
  end
91
112
 
92
113
  def save_url
@@ -102,14 +123,14 @@ module Wiki2Go
102
123
  end
103
124
 
104
125
  def search_url
105
- return join(@web.script_prefix,'search'+@web.script_extension,@web.name)
126
+ return make_verb_url('search',@web.name)
106
127
  end
107
128
 
108
129
  def changes_url
109
130
  if @generate_html then
110
- return join(@web.name,'recent_changes.html')
131
+ return make_url(@web.name,'recent_changes.html')
111
132
  else
112
- return join(@web.script_prefix,'changes'+@web.script_extension,@web.name)
133
+ return make_verb_url('changes',@web.name)
113
134
  end
114
135
  end
115
136
 
@@ -119,15 +140,15 @@ module Wiki2Go
119
140
 
120
141
  def view_page_url(subwiki,page)
121
142
  if @generate_html then
122
- return join(subwiki,page + ".html")
143
+ return make_url(subwiki,page + ".html")
123
144
  else
124
- return join(@web.script_prefix,"view" + @web.script_extension,subwiki,page)
145
+ return make_verb_url('view',subwiki,page)
125
146
  end
126
147
  end
127
148
 
128
149
  def view_url(subwiki,page)
129
150
  if @absolute_urls then
130
- return File.join(@web.base_url,view_page_url(subwiki,page))
151
+ return @web.base_url.chop + view_page_url(subwiki,page)
131
152
  else
132
153
  return view_page_url(subwiki,page)
133
154
  end
@@ -145,7 +166,7 @@ module Wiki2Go
145
166
 
146
167
  def perform_link(subwiki,page,name)
147
168
  if @storage.exists?(File.join(subwiki,page)) then
148
- url = join(@web.script_prefix,"view" + @web.script_extension,subwiki,page)
169
+ url = make_verb_url('view',subwiki,page)
149
170
  if subwiki == @web.name then
150
171
  return "<a href=\"#{url}\">#{name}</a>"
151
172
  else
@@ -161,7 +182,7 @@ module Wiki2Go
161
182
  end
162
183
 
163
184
  def view_version_url(subwiki,page)
164
- return join(@web.script_prefix,"view" + @web.script_extension,subwiki,page)
185
+ return make_verb_url('view',subwiki,page)
165
186
  end
166
187
 
167
188
  def query_string(parameters)
@@ -174,13 +195,13 @@ module Wiki2Go
174
195
  end
175
196
 
176
197
  def admin_link(page,name)
177
- return "<a href=\"#{join(@web.script_prefix,'admin' + @web.script_extension,page)}\">#{name}</a>"
198
+ return "<a href=\"#{make_verb_url('admin',page)}\">#{name}</a>"
178
199
  end
179
200
 
180
201
 
181
202
  def redirect_url(url)
182
203
  if @config.redirect_url?(@web,url) then
183
- redirected_url = join(@web.script_prefix,"redirect",@web.name + "?url=" + CGI::escape(url) )
204
+ redirected_url = make_verb_url('redirect',@web.name) + "?url=" + CGI::escape(url)
184
205
  return redirected_url
185
206
  else
186
207
  return url
@@ -200,9 +221,9 @@ module Wiki2Go
200
221
 
201
222
  def resource_url(name)
202
223
  if @absolute_urls then
203
- File.join(@web.base_url,'html',@web.name,name)
224
+ @web.base_url.chop + make_url('html',@web.name,name)
204
225
  else
205
- File.join('html',@web.name,name)
226
+ make_url('html',@web.name,name)
206
227
  end
207
228
  end
208
229
 
@@ -484,17 +505,6 @@ module Wiki2Go
484
505
  end
485
506
  end
486
507
 
487
- def join(*dirs)
488
- result = ""
489
- dirs.each do |name|
490
- if !name.nil? and name.length > 0 then
491
- result += '/' unless result.length == 0
492
- result += name
493
- end
494
- end
495
- return result.squeeze('/')
496
- end
497
-
498
508
  def url?(name)
499
509
  name =~ /(http|ftp|gopher|news|https)\:(\w|\/|\.|_|-|\?|\=|&|;|\~|#|,)+/
500
510
  end
data/lib/Wiki2Go/Web.rb CHANGED
@@ -81,9 +81,6 @@ module Wiki2Go
81
81
  else
82
82
  url = "http://#{@server}:#{@port}/"
83
83
  end
84
- if !@subsite.empty? then
85
- url += @subsite + '/'
86
- end
87
84
  url
88
85
  end
89
86
 
@@ -113,7 +110,7 @@ module Wiki2Go
113
110
  def Web.from_request(request,config)
114
111
  server = request.host
115
112
  port = request.port
116
- before,verb = Web.parse_scriptpath(request.server_variable['SCRIPT_NAME'],config)
113
+ before,verb = Web.parse_scriptpath(request.script_name,config)
117
114
  web,page = Web.parse_path(request.path,config.multi_wiki)
118
115
  web = Web.new(server,port,config.subsite,before,verb,web,page,request)
119
116
  return web
@@ -124,24 +121,6 @@ module Wiki2Go
124
121
  return ($1.nil? ? "" : $1)
125
122
  end
126
123
 
127
- def read_env(env)
128
- @secure = env.has_key?("AUTH_TYPE")
129
-
130
- user = env['REMOTE_USER']
131
- if user.nil? or user.empty? then
132
- user = env['REMOTE_ADDR']
133
- begin
134
- # addr = Resolv.getname(user)
135
- if !addr.nil? and !addr.empty? then
136
- user = addr
137
- end
138
- rescue
139
- end
140
- end
141
- @user = user
142
- end
143
-
144
-
145
124
  private
146
125
 
147
126
  def Web.parse_url(path,verb,config)
@@ -42,11 +42,10 @@ module Wiki2Go
42
42
 
43
43
  def perform_save(req,res,wikiweb)
44
44
 
45
- content = req.parameter('text')
45
+ content = req.parameter('text','')
46
46
  name = req.parameter('title',wikiweb.current_page)
47
47
  author = req.parameter('author')
48
48
  remember_me = req.parameter('remember_me')
49
- # @config.log("Author = #{author}, remember = #{remember_me}")
50
49
 
51
50
  if !author.nil? && author.length > 0 then # !wikiweb.secure &&
52
51
  wikiweb.alias = author
@@ -138,7 +137,6 @@ module Wiki2Go
138
137
  wiki = Wiki2Go::Wiki.new(@config)
139
138
 
140
139
  res.content_type = "text/html"
141
- @config.log("Generate static in servlet for #{wikiweb.inspect}")
142
140
  res.body = wiki.generate_html(wikiweb)
143
141
  true
144
142
  end
@@ -148,7 +146,16 @@ module Wiki2Go
148
146
  uploaded_file = req.uploaded_file('FILE')
149
147
  wiki = Wiki2Go::Wiki.new(@config)
150
148
 
151
- redirect_to = wiki.upload(wikiweb,uploaded_file.filename,uploaded_file.content)
149
+ filename = uploaded_file.filename
150
+ if filename =~ /\\/ then
151
+ filename = filename.split('\\').pop
152
+ end
153
+
154
+ if filename =~ /\// then
155
+ filename = filename.split('/').pop
156
+ end
157
+
158
+ redirect_to = wiki.upload(wikiweb,filename,uploaded_file.content)
152
159
  res.redirect_to = redirect_to
153
160
  res.content_type = "text/html"
154
161
  res.body = "Redirect to #{redirect_to}"
@@ -64,10 +64,10 @@ END_OF_INPUT
64
64
  formatter.config.allow_dynamic_pages
65
65
 
66
66
  formatted = formatter.format_page("{%DynamicPage%}")
67
- assert_equal("<a href=\"view/Xpday/DynamicPage.rbl\">DynamicPage</a>",formatted)
67
+ assert_equal("<a href=\"/view/Xpday/DynamicPage.rbl\">DynamicPage</a>",formatted)
68
68
 
69
69
  formatted = formatter.format_page("{%Click here...@DynamicPage%}")
70
- assert_equal("<a href=\"view/Xpday/DynamicPage.rbl\">Click here...</a>",formatted)
70
+ assert_equal("<a href=\"/view/Xpday/DynamicPage.rbl\">Click here...</a>",formatted)
71
71
  end
72
72
 
73
73
 
@@ -82,7 +82,7 @@ END_OF_INPUT
82
82
  assert_equal("<pre>\r\n a SomeLink AnotherLink Nolink \r\n</PRE>",formatted)
83
83
 
84
84
  formatted = formatter.format_page(" a SomeLink AnotherLink Nolink ")
85
- assert_equal(" a <a href=\"view/Xpday/SomeLink\">SomeLink</a> <a href=\"view/Xpday/AnotherLink\">AnotherLink</a> Nolink ",formatted)
85
+ assert_equal(" a <a href=\"/view/Xpday/SomeLink\">SomeLink</a> <a href=\"/view/Xpday/AnotherLink\">AnotherLink</a> Nolink ",formatted)
86
86
 
87
87
  end
88
88
 
@@ -133,14 +133,14 @@ END_OF_EXPECTED
133
133
  def test_view_link
134
134
  formatter = makeFormatter
135
135
  formatted = formatter.view_link("Xpday", "aPage", "aLabel")
136
- assert_equal('<a href="view/Xpday/aPage">aLabel</a>',formatted)
136
+ assert_equal('<a href="/view/Xpday/aPage">aLabel</a>',formatted)
137
137
 
138
138
  end
139
139
 
140
140
  def test_view_link_with_parameters
141
141
  formatter = makeFormatter
142
142
  formatted = formatter.view_version_link("Xpday", "aPage", "aLabel", { 'version' => '2' , 'user' => 'firstuser', 'firstparam' => 'value' })
143
- assert_equal('<a href="view/Xpday/aPage?firstparam=value&user=firstuser&version=2">aLabel</a>',formatted)
143
+ assert_equal('<a href="/view/Xpday/aPage?firstparam=value&user=firstuser&version=2">aLabel</a>',formatted)
144
144
 
145
145
  end
146
146
 
@@ -168,13 +168,13 @@ END_OF_EXPECTED
168
168
  def test_combine_links_and_formatting
169
169
  formatter = makeFormatter
170
170
  formatted = formatter.format_page("*{link@http://wiki2go.nayima.be}*")
171
- assert_equal('<STRONG><a href="redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG>',formatted)
171
+ assert_equal('<STRONG><a href="/redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG>',formatted)
172
172
 
173
173
  formatted = formatter.format_page('*<a href="http://wiki2go.nayima.be">link</a>*')
174
- assert_equal('<STRONG><a href="redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG>',formatted)
174
+ assert_equal('<STRONG><a href="/redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG>',formatted)
175
175
 
176
176
  formatted = formatter.format_page(" * *{link@http://wiki2go.nayima.be}*")
177
- assert_equal('<ul><li> <STRONG><a href="redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG></ul>',formatted)
177
+ assert_equal('<ul><li> <STRONG><a href="/redirect/Xpday?url=http%3A%2F%2Fwiki2go.nayima.be" rel="nofollow" target="_blank">link</a></STRONG></ul>',formatted)
178
178
  end
179
179
 
180
180
 
@@ -192,8 +192,8 @@ END_OF_INPUT
192
192
  expected = <<END_OF_EXPECTED
193
193
  <table class="wikitable" >
194
194
  <tr><td> <STRONG>When</STRONG> </td><td> <STRONG>Where</STRONG> </td><td> <STRONG>What</STRONG> </td><td> <STRONG>Who</STRONG> </td></tr>
195
- <tr><td> 23/02/2005 </td><td> <a href="redirect/Xpday?url=http%3A%2F%2Fwww.engels.nl%2F" rel="nofollow" target="_blank">Engels, Rotterdam</a> </td><td> Check out location </td><td> </td></tr>
196
- <tr><td> 13/05/2005 </td><td> <a href="view/Xpday/MastBosch">MastBosch</a>, Breda </td><td> Agile Systems annual meeting + XP Day re-kickstart </td><td> </td></tr>
195
+ <tr><td> 23/02/2005 </td><td> <a href="/redirect/Xpday?url=http%3A%2F%2Fwww.engels.nl%2F" rel="nofollow" target="_blank">Engels, Rotterdam</a> </td><td> Check out location </td><td> </td></tr>
196
+ <tr><td> 13/05/2005 </td><td> <a href="/view/Xpday/MastBosch">MastBosch</a>, Breda </td><td> Agile Systems annual meeting + XP Day re-kickstart </td><td> </td></tr>
197
197
  <tr><td> 17/05/2005 21:00 </td><td> Skype </td><td> Standup </td><td> Marc, Rob, Nynke, Vera, Pascal </td></tr>
198
198
  <tr><td> <STRONG>28/06/2005</STRONG> 21:00 </td><td> Skype </td><td> Standup </td><td> </td></tr>
199
199
  </table>
@@ -257,7 +257,7 @@ END_OF_CONTENT
257
257
 
258
258
  def tag_test_expected
259
259
  return <<-END_OF_CONTENT
260
- This is a test of a long tag <a href="redirect/Xpday?url=http%3A%2F%2Fwww.microsoft.com\" rel=\"nofollow\" target=\"_blank\">
260
+ This is a test of a long tag <a href="/redirect/Xpday?url=http%3A%2F%2Fwww.microsoft.com\" rel=\"nofollow\" target=\"_blank\">
261
261
  That should not be changed
262
262
  END_OF_CONTENT
263
263