Wiki2Go 1.17.5 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/bin/Wiki2Go_firewall_blacklist.rb +8 -0
  2. data/bin/Wiki2Go_make_cvs_repository.rb +1 -0
  3. data/bin/Wiki2Go_make_site.rb +1 -2
  4. data/bin/Wiki2Go_update_site.rb +1 -2
  5. data/lib/Web2Go/CGIRequest.rb +8 -2
  6. data/lib/Web2Go/CGIResponse.rb +17 -14
  7. data/lib/Web2Go/MockRequest.rb +12 -2
  8. data/lib/Web2Go/MockResponse.rb +10 -7
  9. data/lib/Web2Go/WebrickRequest.rb +106 -101
  10. data/lib/Web2Go/WebrickResponse.rb +4 -8
  11. data/lib/Wiki2Go/BlackList.rb +48 -25
  12. data/lib/Wiki2Go/DotGraphics.rb +1 -1
  13. data/lib/Wiki2Go/FileStorage.rb +266 -266
  14. data/lib/Wiki2Go/HTMLFormatter.rb +28 -0
  15. data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +418 -0
  16. data/lib/Wiki2Go/Install/config/passwords +1 -1
  17. data/lib/Wiki2Go/Install/config/url_blacklist.txt +3855 -0
  18. data/lib/Wiki2Go/Install/make_repository.rb +32 -26
  19. data/lib/Wiki2Go/Install/make_site.rb +197 -111
  20. data/lib/Wiki2Go/Install/site/error.html +1 -1
  21. data/lib/Wiki2Go/Install/site/robots.txt +10 -1
  22. data/lib/Wiki2Go/Install/site/style.css +129 -64
  23. data/lib/Wiki2Go/Install/templates/admin.htm +1 -1
  24. data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +2 -1
  25. data/lib/Wiki2Go/Install/templates/admin_pages/format_for_fck.txt +31 -0
  26. data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +1 -1
  27. data/lib/Wiki2Go/Install/templates/edit.htm +62 -46
  28. data/lib/Wiki2Go/Install/templates/full_footer.htm +31 -33
  29. data/lib/Wiki2Go/Install/templates/header.htm +0 -1
  30. data/lib/Wiki2Go/Install/templates/menu.htm +29 -0
  31. data/lib/Wiki2Go/Install/templates/pagelist.htm +46 -43
  32. data/lib/Wiki2Go/Install/templates/simple_footer.htm +20 -16
  33. data/lib/Wiki2Go/Install/templates/versionlist.htm +52 -40
  34. data/lib/Wiki2Go/Install/templates/view.htm +46 -29
  35. data/lib/Wiki2Go/Install/templates/wikiedit.htm +63 -0
  36. data/lib/Wiki2Go/Install/wiki/delete.png +0 -0
  37. data/lib/Wiki2Go/Install/wiki/style.css +133 -63
  38. data/lib/Wiki2Go/LineFormatter.rb +345 -197
  39. data/lib/Wiki2Go/Page.rb +16 -3
  40. data/lib/Wiki2Go/PrivateWikiConfig.rb +5 -5
  41. data/lib/Wiki2Go/PublicWikiConfig.rb +83 -37
  42. data/lib/Wiki2Go/ReadWriteWikiConfig.rb +8 -8
  43. data/lib/Wiki2Go/Server.rb +6 -1
  44. data/lib/Wiki2Go/SpamFilter.rb +32 -41
  45. data/lib/Wiki2Go/Web.rb +10 -3
  46. data/lib/Wiki2Go/Wiki2Go.rb +301 -94
  47. data/lib/Wiki2Go/Wiki2GoConfig.rb +87 -6
  48. data/lib/Wiki2Go/Wiki2GoServlet.rb +66 -12
  49. data/lib/Wiki2Go/WikiFormatter.rb +60 -30
  50. data/lib/Wiki2Go/cgi/diff.rb +20 -0
  51. data/lib/Wiki2Go/cgi/secure/log_rss.rb +21 -0
  52. data/lib/Wiki2Go/cgi/sidebyside.rb +20 -0
  53. data/lib/Wiki2Go/cgi/wikiedit.rb +20 -0
  54. data/lib/Wiki2Go/firewall_blacklist.rb +88 -0
  55. data/test/All.rb +5 -2
  56. data/test/TestBlackList.rb +70 -14
  57. data/test/TestConfig.rb +5 -5
  58. data/test/TestDiff.rb +95 -0
  59. data/test/TestFormatter.rb +14 -16
  60. data/test/TestHTMLFormatter.rb +37 -0
  61. data/test/TestInstall.rb +70 -27
  62. data/test/TestLineFormatter.rb +71 -15
  63. data/test/TestRSS.rb +8 -7
  64. data/test/TestRepository.rb +50 -0
  65. data/test/TestServer.rb +3 -8
  66. data/test/TestSpamFilter.rb +33 -1
  67. data/test/TestStorage.rb +11 -0
  68. data/test/TestWeb.rb +2 -2
  69. data/test/TestWiki2Go.rb +766 -166
  70. data/test/TestWiki2GoServlet.rb +1122 -524
  71. data/test/UnitTestFiles.rb +7 -3
  72. data/test/Wiki2GoConfigForTest.rb +40 -6
  73. data/test/checksite.rb +17 -50
  74. data/test/test_firewall_blacklist.rb +131 -0
  75. data/test/test_page.rb +45 -0
  76. data/test/testdata/Registration.rbl.txt +7 -0
  77. data/test/testdata/config/url_blacklist.txt +38822 -0
  78. data/test/testdata/expected_changes.html +1 -2
  79. data/test/testdata/expected_edit.html +108 -59
  80. data/test/testdata/expected_full_rss.xml +2 -2
  81. data/test/testdata/expected_out.html +97 -61
  82. data/test/testdata/expected_put.html +88 -53
  83. data/test/testdata/expected_save.html +88 -52
  84. data/test/testdata/expected_savehtml.html +88 -52
  85. data/test/testdata/expected_search.html +68 -53
  86. data/test/testdata/expected_upload.html +88 -53
  87. data/test/testdata/expected_versions.html +97 -82
  88. data/test/testdata/expected_view.html +97 -61
  89. data/test/testdata/firewall/iptables.config +37 -0
  90. data/test/testdata/firewall/user_blacklist.txt +162 -0
  91. data/test/testdata/logs/wiki.log +652 -0
  92. data/test/testdata/logs/wiki.log.0 +113 -0
  93. data/test/testdata/logs/wiki.log.1 +113 -0
  94. data/test/testdata/logs/wiki.log.2 +113 -0
  95. data/test/testdata/logs/wiki.log.3 +115 -0
  96. data/test/testdata/logs/wiki.log.4 +5 -0
  97. data/test/testdata/logs/wiki.log.5 +7 -0
  98. data/test/testdata/logs/wiki.log.6 +5 -0
  99. data/test/testdata/logs/wiki.log.7 +118 -0
  100. data/test/testdata/logs/wiki.log.8 +12 -0
  101. data/test/testdata/site/html/Xpday/rss.xml +53 -103
  102. data/test/testdata/texts/Bugs/FrontPage.txt +6 -0
  103. data/test/testdata/texts/Bugs/NoHidden.spam +17850 -0
  104. data/test/testdata/texts/Bugs/PairProgrammingParties.spam +102 -0
  105. data/test/testdata/texts/Bugs/PairProgrammingParties.txt +99 -0
  106. metadata +53 -7
  107. data/test/TestMail.rb +0 -29
  108. data/test/gc.log +0 -2
@@ -5,10 +5,16 @@ require 'etc'
5
5
  require 'logger'
6
6
  require 'tempfile'
7
7
 
8
- require 'rubygems'
9
- gem 'rscm','~>0.3.0'
10
- require 'rscm/logging'
11
- require 'rscm/better'
8
+ begin
9
+ require 'rubygems'
10
+ gem 'rscm','~>0.3.1'
11
+ require 'rscm'
12
+ #require 'rscm/logging'
13
+ require 'rscm/better'
14
+
15
+ rescue Exception => e
16
+ puts e
17
+ end
12
18
 
13
19
  module RSCM
14
20
  class Better
@@ -79,7 +85,6 @@ module RSCM
79
85
  end
80
86
  end
81
87
 
82
-
83
88
  module Wiki2Go
84
89
  class RepositoryMaker
85
90
 
@@ -392,8 +397,8 @@ module Wiki2Go
392
397
  config_file = File.join(dir,'config')
393
398
  lock_directory = File.join(@dir,'locks')
394
399
  update_file(config_file,{/LockDir=/ => "LockDir=#{lock_directory}\n" ,
395
- /LogHistory=/ => "LogHistory=TMAR\n" ,
396
- /LockServer=/ => "LockServer=none\n" })
400
+ /LogHistory=/ => "LogHistory=TMAR\n" ,
401
+ /LockServer=/ => "LockServer=none\n" })
397
402
  end
398
403
 
399
404
  def update_file(name,substitutions)
@@ -448,31 +453,32 @@ module Wiki2Go
448
453
  *.pdf -k 'b'
449
454
  *.xls -k 'b'
450
455
  *.ppt -k 'b'
451
- END_CVS_WRAPPERS
456
+ *.swf -k 'b'
457
+ END_CVS_WRAPPERS
452
458
  end
453
459
 
454
- def set_owner(dir,username,groupname)
455
- info = Etc.getpwnam(username)
456
- if !info.nil? then
457
- user_id = info.uid
458
- group_id = info.gid
459
- if !groupname.nil? then
460
- group_id = Etc.getgrnam(groupname).gid
461
- end
462
- mode = File.stat(dir).mode | 02775
463
- File.chmod(mode,dir)
464
- File.chown(user_id,group_id,dir)
465
- Dir.glob(File.join(dir,'**/*')).each do |file|
466
- if file[0] != '.' then
467
- mode = File.stat(file).mode | 02775
468
- File.chmod(mode,file)
469
- File.chown(user_id,group_id,file)
460
+ def set_owner(dir,username,groupname)
461
+ info = Etc.getpwnam(username)
462
+ if !info.nil? then
463
+ user_id = info.uid
464
+ group_id = info.gid
465
+ if !groupname.nil? then
466
+ group_id = Etc.getgrnam(groupname).gid
467
+ end
468
+ mode = File.stat(dir).mode | 02775
469
+ File.chmod(mode,dir)
470
+ File.chown(user_id,group_id,dir)
471
+ Dir.glob(File.join(dir,'**/*')).each do |file|
472
+ if file[0] != '.' then
473
+ mode = File.stat(file).mode | 02775
474
+ File.chmod(mode,file)
475
+ File.chown(user_id,group_id,file)
476
+ end
470
477
  end
471
478
  end
472
479
  end
473
- end
474
480
 
475
- end
481
+ end
476
482
 
477
483
  end
478
484
 
@@ -5,12 +5,12 @@ require 'fileutils'
5
5
  require 'optparse'
6
6
  require "uri"
7
7
 
8
- require 'rubygems'
9
- WIKI2GO_VERSION = '1.17.5'
8
+ WIKI2GO_VERSION = '1.22.0'
10
9
  gem "Wiki2Go","~>#{WIKI2GO_VERSION}"
11
10
 
12
11
  require 'Wiki2Go/Web.rb'
13
12
  require 'Wiki2Go/Wiki2Go.rb'
13
+
14
14
  require 'Wiki2Go/PublicWikiConfig'
15
15
  require 'Wiki2Go/PrivateWikiConfig'
16
16
  require 'Wiki2Go/ReadWriteWikiConfig'
@@ -39,16 +39,45 @@ module Wiki2Go
39
39
  attr_accessor :subsite
40
40
 
41
41
  def initialize
42
- @user = WebUser.new('www-data',nil)
42
+ @user = WebUser.new(nil,nil)
43
43
  @server = 'localhost'
44
44
  @port = '80'
45
45
  @default_wiki = ''
46
46
  @directory = Dir.getwd
47
- @type = ''
47
+ @type = nil
48
48
  @source_dir = File.expand_path(File.dirname(__FILE__))
49
49
  @subsite = ''
50
50
  end
51
51
 
52
+ # Return a Wiki2GoConfig object, if there is a CgiOptions.rb file
53
+ # Returns nil if no configuration could be read
54
+ def existing_configuration
55
+ configfile = File.join(@directory,'site','scripts','CgiOptions.rb')
56
+ if File.exists?(configfile) then
57
+ load configfile
58
+ return CgiOptions.new
59
+ end
60
+ return nil
61
+ end
62
+
63
+ def read_existing_configuration
64
+ config = existing_configuration
65
+ unless config.nil? then
66
+ if @type.nil? then
67
+ @type = Configuration.type_of(config)
68
+ end
69
+
70
+ if @user.user.nil? then
71
+ @user.user = config.user if config.respond_to?(:user)
72
+ end
73
+
74
+ if @user.group.nil? || @user.group.empty? then
75
+ @user.group = (config.respond_to?(:group) ? config.group : nil)
76
+ end
77
+
78
+ end
79
+ end
80
+
52
81
  def dotted_port
53
82
  if @port.nil? || @port.empty? then
54
83
  ':80'
@@ -74,12 +103,20 @@ module Wiki2Go
74
103
  @subsite = uri.path
75
104
  @port = uri.port.to_s
76
105
  end
77
- end
106
+ end
107
+
108
+ private
109
+ def self.type_of(configuration)
110
+ return 'public' if configuration.kind_of?(Wiki2Go::PublicWikiConfig)
111
+ return 'private' if configuration.kind_of?(Wiki2Go::PrivateWikiConfig)
112
+ return 'readwrite' if configuration.kind_of?(Wiki2Go::ReadWriteWikiConfig)
113
+ return nil
114
+ end
78
115
  end
79
116
 
80
117
  module Install
81
118
 
82
- def Install.make_site(args)
119
+ def Install.make_site(args,&block)
83
120
  opts = OptionParser.new
84
121
 
85
122
  configuration = Configuration.new
@@ -89,7 +126,7 @@ module Wiki2Go
89
126
  opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
90
127
  opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
91
128
  opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val }
92
- opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val }
129
+ opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val.downcase }
93
130
  opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
94
131
  opts.on_tail("-h", "--help", "Show this message") do
95
132
  puts opts
@@ -97,11 +134,14 @@ module Wiki2Go
97
134
  end
98
135
  opts.parse(args)
99
136
 
100
- puts "Installing Wiki2Go site in #{ configuration.directory}"
101
-
102
- if configuration.server.empty? or configuration.type.empty? then
137
+ configuration.read_existing_configuration
138
+
139
+ if configuration.server.empty? or configuration.type.nil? then
140
+ puts "Server URL must be specified" if configuration.server.empty?
141
+ puts "Wiki type (public, private, readwrite) must be specified" if configuration.type.nil?
103
142
  puts opts
104
143
  else
144
+ yield "Installing Wiki2Go site in #{configuration.directory}" if block_given?
105
145
  oldmask = File.umask(02)
106
146
  ensure_path_exists(configuration.directory)
107
147
  cd(configuration.directory) {
@@ -116,20 +156,20 @@ module Wiki2Go
116
156
  }
117
157
  set_owner(configuration.directory,configuration.user)
118
158
  File.umask(oldmask)
119
- puts "Installed."
120
- puts "Include '#{configuration.directory}/config/site.conf' in your Apache configuration"
121
- puts " and restart Apache to activate your wiki."
159
+ yield "Installed." if block_given?
160
+ yield "Include '#{configuration.directory}/config/site.conf' in your Apache configuration" if block_given?
161
+ yield " and restart Apache to activate your wiki." if block_given?
122
162
  end
123
163
  end
124
164
 
125
- def Install.update_site(args)
165
+ def Install.update_site(args,&block)
126
166
  opts = OptionParser.new
127
167
 
128
168
  configuration = Configuration.new
129
169
  opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
130
170
  opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
131
171
  opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
132
- opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val }
172
+ opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val.downcase }
133
173
  opts.on_tail("-h", "--help", "Show this message") do
134
174
  puts opts
135
175
  exit
@@ -137,14 +177,19 @@ module Wiki2Go
137
177
 
138
178
  opts.parse(args)
139
179
 
140
- if configuration.type.empty? then
180
+ configuration.read_existing_configuration
181
+
182
+ if configuration.type.nil? then
183
+ puts "Wiki type (public, private, readwrite) must be specified" if configuration.type.nil?
141
184
  puts opts
142
185
  else
186
+ yield "Updating Wiki2Go site in #{configuration.directory}" if block_given?
187
+
143
188
  oldmask = File.umask(02)
144
189
  cd(configuration.directory) {
145
190
  case configuration.type
146
191
  when 'private' then
147
- do_update_private_site( configuration)
192
+ do_update_private_site(configuration)
148
193
  when 'public'
149
194
  do_update_public_site(configuration)
150
195
  else
@@ -153,17 +198,18 @@ module Wiki2Go
153
198
  }
154
199
  set_owner(configuration.directory,configuration.user)
155
200
  File.umask(oldmask)
201
+ yield "Updated." if block_given?
156
202
  end
157
203
  end
158
204
 
159
- def Install.make_wiki(args)
205
+ def Install.make_wiki(args,&block)
160
206
  opts = OptionParser.new
161
207
 
162
208
  configuration = Configuration.new
163
209
 
164
210
  opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
165
211
  opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
166
- opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val }
212
+ opts.on("-w",'--web default_wiki',String) { |val| configuration.default_wiki = val }
167
213
  opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
168
214
  opts.on_tail("-h", "--help", "Show this message") do
169
215
  puts opts
@@ -171,21 +217,27 @@ module Wiki2Go
171
217
  end
172
218
  opts.parse(args)
173
219
 
174
- oldmask = File.umask(02)
175
- cd(configuration.directory) {
176
- do_make_wiki(configuration)
177
- }
178
- set_owner(configuration.directory,configuration.user)
179
- File.umask(oldmask)
220
+ configuration.read_existing_configuration
221
+
222
+ if configuration.default_wiki.empty? then
223
+ puts "The name of the subwiki is required"
224
+ puts opts
225
+ else
226
+ yield "Creating subwiki #{configuration.default_wiki} in #{configuration.directory}" if block_given?
227
+ oldmask = File.umask(02)
228
+ cd(configuration.directory) {
229
+ do_make_wiki(configuration)
230
+ }
231
+ set_owner(configuration.directory,configuration.user)
232
+ File.umask(oldmask)
233
+ yield "Created." if block_given?
234
+ end
180
235
  end
181
236
 
182
237
  private
183
238
 
184
239
  def Install.do_make_public_site(configuration)
185
240
  do_update_public_site(configuration)
186
- config_file = make_config( configuration,'PublicWikiConfig')
187
-
188
- install_html(configuration)
189
241
 
190
242
  do_make_wiki( configuration)
191
243
 
@@ -195,9 +247,6 @@ module Wiki2Go
195
247
 
196
248
  def Install.do_make_readwrite_site( configuration)
197
249
  do_update_readwrite_site( configuration)
198
- config_file = make_config( configuration,'ReadWriteWikiConfig')
199
-
200
- install_html(configuration)
201
250
 
202
251
  do_make_wiki( configuration)
203
252
 
@@ -208,9 +257,6 @@ module Wiki2Go
208
257
  def Install.do_make_private_site(configuration)
209
258
 
210
259
  do_update_private_site(configuration)
211
- config_file = make_config( configuration,'PrivateWikiConfig')
212
-
213
- install_html(configuration)
214
260
 
215
261
  do_make_wiki( configuration)
216
262
 
@@ -220,22 +266,32 @@ module Wiki2Go
220
266
 
221
267
 
222
268
  def Install.do_update_public_site(config)
223
- mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
269
+ install_html(config)
270
+
224
271
  install_scripts(config)
272
+
273
+ make_config( config,'PublicWikiConfig')
225
274
  end
226
275
 
227
276
  def Install.do_update_readwrite_site(config)
228
- mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
277
+ install_html(config)
278
+
229
279
  install_readwrite_scripts(config)
280
+
281
+ make_config( config,'ReadWriteWikiConfig')
282
+
230
283
  end
231
284
 
232
285
  def Install.do_update_private_site(config)
233
- mkdir_p(File.join('site','scripts'),{ :mode => 0775})
286
+ install_html(config)
287
+
234
288
  install_scripts(config)
235
- end
236
289
 
290
+ make_config( config,'PrivateWikiConfig')
291
+ end
237
292
 
238
293
  def Install.install_scripts(config)
294
+ mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
239
295
  source = File.join(config.source_dir,'..','cgi')
240
296
  copy_scripts(source,'site/scripts')
241
297
  copy_scripts(source,'site/scripts/secure')
@@ -246,9 +302,10 @@ module Wiki2Go
246
302
  end
247
303
 
248
304
  def Install.install_readwrite_scripts(config)
305
+ mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
249
306
  source = File.join(config.source_dir,'..','cgi')
250
307
  copy_scripts(source,'site/scripts') { |name|
251
- value = (name != 'save.rb' && name != 'edit.rb')
308
+ value = (name != 'save.rb' && name != 'edit.rb' && name != 'wikiedit.rb')
252
309
  value
253
310
  }
254
311
  copy_scripts(source,'site/scripts/secure')
@@ -297,37 +354,39 @@ module Wiki2Go
297
354
  end
298
355
 
299
356
  def Install.set_owner(dir,owner)
300
- info = Etc.getpwnam(owner.user)
301
- if !info.nil? then
302
- user_id = info.uid
303
- group_id = info.gid
304
- if !owner.group.nil? then
305
- group_id = Etc.getgrnam(owner.group).gid
306
- end
307
- mode = File.stat(dir).mode | 0664
308
- File.chmod(mode,dir)
309
- File.chown(user_id,group_id,dir)
310
- Dir.glob(File.join(dir,'**/*')).each do |file|
311
- if file[0] != '.' then
312
- if File.extname(file) == '.rb' then
313
- mode = File.stat(file).mode | 0764
314
- else
315
- mode = File.stat(file).mode | 0664
357
+ if !owner.user.nil? then
358
+ info = Etc.getpwnam(owner.user)
359
+ if !info.nil? then
360
+ user_id = info.uid
361
+ group_id = info.gid
362
+ if !owner.group.nil? then
363
+ group_id = Etc.getgrnam(owner.group).gid
364
+ end
365
+ mode = File.stat(dir).mode | 0664
366
+ File.chmod(mode,dir)
367
+ File.chown(user_id,group_id,dir)
368
+ Dir.glob(File.join(dir,'**/*')).each do |file|
369
+ if file[0] != '.' then
370
+ if File.extname(file) == '.rb' then
371
+ mode = File.stat(file).mode | 0764
372
+ else
373
+ mode = File.stat(file).mode | 0664
374
+ end
375
+ File.chmod(mode,file)
376
+ File.chown(user_id,group_id,file)
316
377
  end
317
- File.chmod(mode,file)
318
- File.chown(user_id,group_id,file)
319
378
  end
320
379
  end
321
380
  end
322
381
  end
323
-
382
+
324
383
  def Install.make_config(config,baseconfig)
325
384
  template = <<-TEMPLATE_END
326
385
  #!/usr/bin/env ruby
327
386
 
328
387
  # Select which version of Wiki2Go is used.
329
388
  require 'rubygems'
330
- require_gem "Wiki2Go","~>#{WIKI2GO_VERSION}"
389
+ gem "Wiki2Go","~>#{WIKI2GO_VERSION}"
331
390
  require "Wiki2Go/#{baseconfig}"
332
391
 
333
392
  class CgiOptions < Wiki2Go::#{baseconfig}
@@ -351,6 +410,17 @@ class CgiOptions < Wiki2Go::#{baseconfig}
351
410
  # Set your Amazon affiliate ID for ISBN links
352
411
  @amazon_affiliate = 'agilesystems-21'
353
412
 
413
+ # The number of pages that appear in the 'Recent Changes' list and in RSS feeds
414
+ @pages_in_recent_changes = 20
415
+ @pages_in_rss = 20
416
+
417
+ # Choose either 'edit' (rich edit) or 'wikiedit' (classic wiki editor)
418
+ # To enable rich editing
419
+ # 1. Install the Wiki2GoEditor gem to enable the rich editor
420
+ # 2. Execute Wiki2Go_install_editor.rb -d <the directory where the wiki is installed> to add the rich editor
421
+ # 3. Change this setting to 'edit'
422
+ @editor = 'wikiedit'
423
+
354
424
  # Set to true if you want to allow the execution of Ruby code inside pages
355
425
  # SECURITY WARNING: this code can do absolutely anything, only allow for trusted users
356
426
  @allow_dynamic_pages = false
@@ -369,33 +439,45 @@ class CgiOptions < Wiki2Go::#{baseconfig}
369
439
  # If you want to enable CVS commit/update support for your wiki, uncomment the following line
370
440
  # and fill in the CVSROOT and the name of the module as parameters
371
441
  # The CVS repository and module must exist and the webserver user must have commit access to it
372
- # You need to have the rscm 0.3 gem installed
442
+ # You need to have the rscm 0.3.x gem installed
373
443
  # use_repository('MYCVSROOT','mymodule')
374
444
 
445
+ # The wiki calculates checksums for pages submitted and stored. This can be used for 2 purposes
446
+ # - Check that the save was not performed by a robot: the checksum from the edit page is missing
447
+ # - Check for edit collisions: the checksum submitted is not the same as the checksum of the file on disk
448
+ # For compatibility reasons, this functionality is disabled by default
449
+
450
+ # Set to true to enable checksum checking when saving files
451
+ @checksum_required = false
452
+ # Set to a unique string to make your checksums unique
453
+ @checksum_salt = '#{config.directory}'
454
+ # Set to true to add users who save without checksum to the blacklist
455
+ @blacklist_when_no_checksum = false
375
456
  end
376
457
 
377
458
  end
378
459
  TEMPLATE_END
379
460
 
380
461
  dest = File.join(config.directory,'site','scripts','CgiOptions.rb')
381
- if !File.exists?(dest) then
382
- File.open(dest,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
383
- f.puts template
384
- end
462
+ if File.exists?(dest) then
463
+ dest += '.new'
385
464
  end
386
-
465
+ File.open(dest,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
466
+ f.puts template
467
+ end
468
+
387
469
  logdir = File.join(config.directory,'logs')
388
470
  mkdir_p(logdir,{ :mode => 0775}) unless File.exists?(logdir)
389
-
471
+
390
472
  logfile = File.join(logdir,'wiki.log')
391
473
  if !File.exists?(logfile) then
392
474
  touch logfile
393
475
  end
394
-
476
+
395
477
  securedir = File.join(config.directory,'site','scripts','secure')
396
478
  if File.exists?(securedir) then
397
479
  secure = File.join(securedir,'CgiOptions.rb')
398
-
480
+
399
481
  begin
400
482
  ln_sf(dest,secure)
401
483
  rescue NotImplementedError
@@ -404,15 +486,14 @@ TEMPLATE_END
404
486
  end
405
487
  return dest
406
488
  end
407
-
489
+
408
490
  def Install.install_html(config)
409
491
  dest = File.join(config.directory,'site')
410
492
  mkdir_p(File.join(dest,'html'),{ :mode => 0775})
411
- source = File.join(config.source_dir,'site','.')
412
- cp_r source,dest
413
- Dir["#{dest}/**/CVS"].each { |name| rm_r name }
493
+ source = File.join(config.source_dir,'site')
494
+ copy_if_not_exists source,dest
414
495
  end
415
-
496
+
416
497
  def Install.do_make_wiki(config)
417
498
  wikiname = config.default_wiki
418
499
  textdir = File.join('texts',wikiname)
@@ -421,60 +502,69 @@ TEMPLATE_END
421
502
  if !File.exists?(frontpage) then
422
503
  touch frontpage
423
504
  end
424
-
505
+
425
506
  templatedir = File.join('templates',wikiname)
426
507
  mkdir_p(templatedir,{ :mode => 0775})
427
508
  source = File.join(config.source_dir,'templates')
428
509
  dest = templatedir
429
510
  copy_if_not_exists(source,dest)
430
-
511
+
431
512
  source = File.join(config.source_dir,'wiki','.')
432
513
  wiki_html = File.join('site','html',wikiname)
433
514
  mkdir_p(wiki_html,{ :mode => 0775})
434
515
  copy_if_not_exists(source,wiki_html)
435
516
 
436
517
  make_static_homepage(config)
437
-
518
+
438
519
  end
439
-
520
+
440
521
  def Install.copy_if_not_exists(source,dest)
441
522
  Dir.glob(File.join(source,'*')).each do |sourcefile|
442
523
  if FileTest.file?(sourcefile) then
443
524
  name = File.basename(sourcefile)
444
525
  destfile = File.join(dest,name)
445
- if !File.exists?(destfile) then
446
- cp sourcefile,destfile
526
+ cp sourcefile,destfile unless File.exists?(destfile)
527
+ elsif FileTest.directory?(sourcefile) then
528
+ name = File.basename(sourcefile)
529
+ unless name == 'CVS' then
530
+ destdir = File.join(dest,name)
531
+ mkdir_p destdir unless File.exists?(destdir)
532
+ copy_if_not_exists sourcefile,destdir
447
533
  end
448
534
  end
449
535
  end
450
536
  end
451
-
537
+
452
538
  def Install.write_apache_config(config,contents)
453
539
  config_dir = File.join(config.directory,'config')
454
540
  mkdir_p(config_dir,{ :mode => 0775}) unless File.exists?(config_dir)
455
-
541
+
456
542
  configfile = File.join(config_dir,'site.conf')
457
- File.open(configfile,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
458
- f.puts contents
543
+ unless File.exists?(configfile) then
544
+ File.open(configfile,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
545
+ f.puts contents
546
+ end
459
547
  end
460
-
548
+
461
549
  source = File.join(config.source_dir,'config')
462
550
  copy_if_not_exists(source,config_dir)
463
551
  end
464
-
552
+
465
553
  def Install.write_lighttpd_config(config,contents)
466
554
  config_dir = File.join(config.directory,'config')
467
555
  mkdir_p(config_dir,{ :mode => 0775}) unless File.exists?(config_dir)
468
-
556
+
469
557
  configfile = File.join(config_dir,'lighttpd.conf')
470
- File.open(configfile,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
471
- f.puts contents
558
+ unless File.exists?(configfile) then
559
+ File.open(configfile,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
560
+ f.puts contents
561
+ end
472
562
  end
473
-
563
+
474
564
  source = File.join(config.source_dir,'config')
475
565
  copy_if_not_exists(source,config_dir)
476
566
  end
477
-
567
+
478
568
  def Install.make_public_apache_config(config)
479
569
  template = <<-END_TEMPLATE
480
570
  <VirtualHost *#{config.dotted_port}>
@@ -482,11 +572,10 @@ ServerName #{config.server}
482
572
  DocumentRoot #{config.directory}/site
483
573
  RedirectMatch ^/$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
484
574
  RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
485
- ScriptAlias /scripts/secure #{config.directory}/site/scripts/secure
486
575
  ScriptAlias /scripts #{config.directory}/site/scripts
487
576
  <Directory "#{config.directory}/site/scripts/secure">
488
577
  AuthType Basic
489
- AuthName "#{config.default_wiki} wiki site"
578
+ AuthName "#{config.server} wiki site"
490
579
  AuthUserFile #{config.directory}/config/passwords
491
580
  require valid-user
492
581
  Options ExecCGI FollowSymLinks
@@ -495,7 +584,7 @@ Options ExecCGI FollowSymLinks
495
584
  Options ExecCGI FollowSymLinks
496
585
  </Directory>
497
586
  ErrorLog #{config.directory}/logs/error.log
498
- CustomLog #{config.directory}/logs/access.log.log combined
587
+ CustomLog #{config.directory}/logs/access.log combined
499
588
 
500
589
  </VirtualHost>
501
590
  END_TEMPLATE
@@ -503,12 +592,11 @@ END_TEMPLATE
503
592
  subsite_template = <<-END_TEMPLATE
504
593
  RedirectMatch ^#{config.subsite}/$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
505
594
  RedirectMatch ^#{config.subsite}$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
506
- ScriptAlias #{config.subsite}/scripts/secure #{config.directory}/site/scripts/secure
507
595
  ScriptAlias #{config.subsite}/scripts #{config.directory}/site/scripts
508
596
  Alias #{config.subsite} #{config.directory}/site
509
597
  <Directory "#{config.directory}/site/scripts/secure">
510
598
  AuthType Basic
511
- AuthName "#{config.default_wiki} wiki site"
599
+ AuthName "#{config.server} wiki site"
512
600
  AuthUserFile #{config.directory}/config/passwords
513
601
  require valid-user
514
602
  Options ExecCGI FollowSymLinks
@@ -517,10 +605,10 @@ Options ExecCGI FollowSymLinks
517
605
  Options ExecCGI FollowSymLinks
518
606
  </Directory>
519
607
  END_TEMPLATE
520
-
608
+
521
609
  write_apache_config(config,(config.subsite.empty? ? template : subsite_template))
522
610
  end
523
-
611
+
524
612
  def Install.make_public_lighttpd_config( config)
525
613
  template = <<-END_OF_TEMPLATE
526
614
  # Configuration generated by Wiki2Go
@@ -589,11 +677,10 @@ ServerName #{config.server}
589
677
  DocumentRoot #{config.directory}/site
590
678
  RedirectMatch ^/$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
591
679
  RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
592
- ScriptAlias /scripts/secure #{config.directory}/site/scripts/secure
593
680
  ScriptAlias /scripts #{config.directory}/site/scripts
594
681
  <Directory "#{config.directory}/site/scripts/secure">
595
682
  AuthType Basic
596
- AuthName "#{config.default_wiki} wiki site"
683
+ AuthName "#{config.server} wiki site"
597
684
  AuthUserFile #{config.directory}/config/passwords
598
685
  require valid-user
599
686
  Options ExecCGI FollowSymLinks
@@ -602,7 +689,7 @@ Options ExecCGI FollowSymLinks
602
689
  Options ExecCGI FollowSymLinks
603
690
  </Directory>
604
691
  ErrorLog #{config.directory}/logs/error.log
605
- CustomLog #{config.directory}/logs/access.log.log combined
692
+ CustomLog #{config.directory}/logs/access.log combined
606
693
 
607
694
  </VirtualHost>
608
695
  END_TEMPLATE
@@ -610,12 +697,11 @@ END_TEMPLATE
610
697
  subsite_template = <<-END_TEMPLATE
611
698
  RedirectMatch ^#{config.subsite}/$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
612
699
  RedirectMatch ^#{config.subsite}$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
613
- ScriptAlias #{config.subsite}/scripts/secure #{config.directory}/site/scripts/secure
614
700
  ScriptAlias #{config.subsite}/scripts #{config.directory}/site/scripts
615
701
  Alias #{config.subsite} #{config.directory}/site
616
702
  <Directory "#{config.directory}/site/scripts/secure">
617
703
  AuthType Basic
618
- AuthName "#{config.default_wiki} wiki site"
704
+ AuthName "#{config.server} wiki site"
619
705
  AuthUserFile #{config.directory}/config/passwords
620
706
  require valid-user
621
707
  Options ExecCGI FollowSymLinks
@@ -624,10 +710,10 @@ Options ExecCGI FollowSymLinks
624
710
  Options ExecCGI FollowSymLinks
625
711
  </Directory>
626
712
  END_TEMPLATE
627
-
713
+
628
714
  write_apache_config(config,(config.subsite.empty? ? template : subsite_template))
629
715
  end
630
-
716
+
631
717
  def Install.make_readwrite_lighttpd_config( config)
632
718
  template = <<-END_OF_TEMPLATE
633
719
  # Configuration generated by Wiki2Go
@@ -699,7 +785,7 @@ RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'Front
699
785
  ScriptAlias /scripts #{config.directory}/site/scripts
700
786
  <Directory "#{config.directory}/site/">
701
787
  AuthType Basic
702
- AuthName "#{config.default_wiki} wiki site"
788
+ AuthName "#{config.server} wiki site"
703
789
  AuthUserFile #{config.directory}/config/passwords
704
790
  require valid-user
705
791
  Options ExecCGI FollowSymLinks
@@ -708,19 +794,19 @@ Options ExecCGI FollowSymLinks
708
794
  Options ExecCGI FollowSymLinks
709
795
  </Directory>
710
796
  ErrorLog #{config.directory}/logs/error.log
711
- CustomLog #{config.directory}/logs/access.log.log combined
797
+ CustomLog #{config.directory}/logs/access.log combined
712
798
 
713
799
  </VirtualHost>
714
800
  END_TEMPLATE
715
801
 
716
- subsite_template = <<-END_TEMPLATE
802
+ subsite_template = <<-END_TEMPLATE
717
803
  RedirectMatch ^#{config.subsite}/$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
718
804
  RedirectMatch ^#{config.subsite}$ http://#{File.join(config.server_url,config.subsite,config.default_wiki,'FrontPage.html')}
719
805
  ScriptAlias #{config.subsite}/scripts #{config.directory}/site/scripts
720
806
  Alias #{config.subsite} #{config.directory}/site
721
807
  <Directory "#{config.directory}/site/">
722
808
  AuthType Basic
723
- AuthName "#{config.default_wiki} wiki site"
809
+ AuthName "#{config.server} wiki site"
724
810
  AuthUserFile #{config.directory}/config/passwords
725
811
  require valid-user
726
812
  Options ExecCGI FollowSymLinks
@@ -730,10 +816,10 @@ Options ExecCGI FollowSymLinks
730
816
  </Directory>
731
817
 
732
818
  END_TEMPLATE
733
-
819
+
734
820
  write_apache_config(config,(config.subsite.empty? ? template : subsite_template))
735
821
  end
736
-
822
+
737
823
  def Install.make_private_lighttpd_config( config)
738
824
  template = <<-END_OF_TEMPLATE
739
825
  # Configuration generated by Wiki2Go
@@ -812,7 +898,7 @@ END_OF_TEMPLATE
812
898
  wiki.generate_html(web)
813
899
  end
814
900
  end
815
-
901
+
816
902
  private
817
903
 
818
904
  def Install.ensure_path_exists(path)