Wiki2Go 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/Wiki2GoServer.rb +11 -0
- data/bin/Wiki2Go_make_site.rb +10 -0
- data/bin/Wiki2Go_make_wiki.rb +10 -0
- data/bin/Wiki2Go_update_site.rb +10 -0
- data/lib/Web2Go/CGIRequest.rb +99 -0
- data/lib/Web2Go/CGIResponse.rb +64 -0
- data/lib/Web2Go/ERB_Interpreter.rb +47 -0
- data/lib/Web2Go/MockCookie.rb +17 -0
- data/lib/Web2Go/MockRequest.rb +131 -0
- data/lib/Web2Go/MockResponse.rb +35 -0
- data/lib/Web2Go/Web2Go.rb +0 -0
- data/lib/Web2Go/WebrickRequest.rb +124 -0
- data/lib/Web2Go/WebrickResponse.rb +50 -0
- data/lib/Wiki2Go.rb +2 -0
- data/lib/Wiki2Go/BlackList.rb +52 -0
- data/lib/Wiki2Go/DotGraphics.rb +69 -0
- data/lib/Wiki2Go/FileStorage.rb +267 -0
- data/lib/Wiki2Go/GreyList.rb +88 -0
- data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +4743 -0
- data/lib/Wiki2Go/Install/config/passwords +1 -0
- data/lib/Wiki2Go/Install/make_site.rb +515 -0
- data/lib/Wiki2Go/Install/site/error.html +77 -0
- data/lib/Wiki2Go/Install/site/html/admin.css +135 -0
- data/lib/Wiki2Go/Install/site/html/xml.gif +0 -0
- data/lib/Wiki2Go/Install/site/robots.txt +13 -0
- data/lib/Wiki2Go/Install/site/style.css +135 -0
- data/lib/Wiki2Go/Install/templates/admin.htm +48 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/admin.txt +1 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/greylist.txt +72 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +67 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/regenerate.txt +26 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/removespam.txt +19 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/update.txt +13 -0
- data/lib/Wiki2Go/Install/templates/edit.htm +74 -0
- data/lib/Wiki2Go/Install/templates/pagelist.htm +82 -0
- data/lib/Wiki2Go/Install/templates/rss.xml +11 -0
- data/lib/Wiki2Go/Install/templates/versionlist.htm +84 -0
- data/lib/Wiki2Go/Install/templates/view.htm +72 -0
- data/lib/Wiki2Go/Install/wiki/style.css +135 -0
- data/lib/Wiki2Go/Page.rb +69 -0
- data/lib/Wiki2Go/PrivateWikiConfig.rb +27 -0
- data/lib/Wiki2Go/PublicWikiConfig.rb +52 -0
- data/lib/Wiki2Go/ReadWriteWikiConfig.rb +23 -0
- data/lib/Wiki2Go/Server.rb +94 -0
- data/lib/Wiki2Go/SpamFilter.rb +95 -0
- data/lib/Wiki2Go/UrlFinder.rb +26 -0
- data/lib/Wiki2Go/Web.rb +185 -0
- data/lib/Wiki2Go/WebrickServlet.rb +211 -0
- data/lib/Wiki2Go/WhiteList.rb +29 -0
- data/lib/Wiki2Go/Wiki2Go.rb +274 -0
- data/lib/Wiki2Go/Wiki2GoConfig.rb +144 -0
- data/lib/Wiki2Go/Wiki2GoServlet.rb +197 -0
- data/lib/Wiki2Go/WikiFormatter.rb +597 -0
- data/lib/Wiki2Go/WikiLogFile.rb +43 -0
- data/lib/Wiki2Go/cgi/changes.rb +20 -0
- data/lib/Wiki2Go/cgi/display.rb +20 -0
- data/lib/Wiki2Go/cgi/edit.rb +20 -0
- data/lib/Wiki2Go/cgi/redirect.rb +20 -0
- data/lib/Wiki2Go/cgi/save.rb +20 -0
- data/lib/Wiki2Go/cgi/search.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/admin.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/generate_static.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/removespam.rb +20 -0
- data/lib/Wiki2Go/cgi/upload.rb +20 -0
- data/lib/Wiki2Go/cgi/versions.rb +20 -0
- data/lib/Wiki2Go/cgi/view.rb +20 -0
- metadata +113 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
admin:PtbdbFXq/1qM6
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'etc'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'optparse'
|
|
6
|
+
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
WIKI2GO_VERSION = '0.1.14'
|
|
9
|
+
require_gem "Wiki2Go","=#{WIKI2GO_VERSION}"
|
|
10
|
+
|
|
11
|
+
require 'Wiki2Go/PublicWikiConfig'
|
|
12
|
+
require 'Wiki2Go/PrivateWikiConfig'
|
|
13
|
+
require 'Wiki2Go/ReadWriteWikiConfig'
|
|
14
|
+
|
|
15
|
+
include FileUtils
|
|
16
|
+
|
|
17
|
+
module Wiki2Go
|
|
18
|
+
|
|
19
|
+
class WebUser
|
|
20
|
+
attr_accessor :user, :group
|
|
21
|
+
|
|
22
|
+
def initialize(user,group)
|
|
23
|
+
@user = user
|
|
24
|
+
@group = group
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Configuration
|
|
29
|
+
attr_accessor :user
|
|
30
|
+
attr_accessor :server
|
|
31
|
+
attr_accessor :port
|
|
32
|
+
attr_accessor :default_wiki
|
|
33
|
+
attr_accessor :directory
|
|
34
|
+
attr_accessor :type
|
|
35
|
+
attr_reader :source_dir
|
|
36
|
+
|
|
37
|
+
def initialize
|
|
38
|
+
@user = WebUser.new('www-data',nil)
|
|
39
|
+
@server = 'localhost'
|
|
40
|
+
@port = '80'
|
|
41
|
+
@default_wiki = ''
|
|
42
|
+
@directory = Dir.getwd
|
|
43
|
+
@type = ''
|
|
44
|
+
@source_dir = File.expand_path(File.dirname(__FILE__))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def dotted_port
|
|
48
|
+
if @port.nil? || @port.empty? then
|
|
49
|
+
':80'
|
|
50
|
+
else
|
|
51
|
+
':' + @port
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def server_url
|
|
56
|
+
if @port.nil? || @port.empty? || @port == '80' then
|
|
57
|
+
server
|
|
58
|
+
else
|
|
59
|
+
server + dotted_port
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
module Install
|
|
65
|
+
|
|
66
|
+
def Install.make_site(args)
|
|
67
|
+
opts = OptionParser.new
|
|
68
|
+
|
|
69
|
+
configuration = Configuration.new
|
|
70
|
+
|
|
71
|
+
opts.on("-s URL",'--server URL',String) { |val| configuration.server = val }
|
|
72
|
+
opts.on("-p",'--port URL',"(default is port 80)",String) { |val| configuration.port = val }
|
|
73
|
+
opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
|
|
74
|
+
opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
|
|
75
|
+
opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val }
|
|
76
|
+
opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val }
|
|
77
|
+
opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
|
|
78
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
79
|
+
puts opts
|
|
80
|
+
exit
|
|
81
|
+
end
|
|
82
|
+
opts.parse(args)
|
|
83
|
+
|
|
84
|
+
puts "Installing Wiki2Go site in #{ configuration.directory}"
|
|
85
|
+
|
|
86
|
+
if configuration.server.empty? or configuration.type.empty? then
|
|
87
|
+
puts opts
|
|
88
|
+
else
|
|
89
|
+
ensure_path_exists(configuration.directory)
|
|
90
|
+
cd(configuration.directory) {
|
|
91
|
+
case configuration.type
|
|
92
|
+
when "private" then
|
|
93
|
+
do_make_private_site(configuration)
|
|
94
|
+
when "public" then
|
|
95
|
+
do_make_public_site(configuration)
|
|
96
|
+
else
|
|
97
|
+
do_make_readwrite_site(configuration)
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
set_owner(configuration.directory,configuration.user)
|
|
101
|
+
puts "Installed."
|
|
102
|
+
puts "Include #{configuration.directory}/config/site.conf in your Apache configuration"
|
|
103
|
+
puts " and restart Apache to activate your wiki."
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def Install.update_site(args)
|
|
108
|
+
opts = OptionParser.new
|
|
109
|
+
|
|
110
|
+
configuration = Configuration.new
|
|
111
|
+
opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
|
|
112
|
+
opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
|
|
113
|
+
opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
|
|
114
|
+
opts.on("-t",'--type wiki_type',"(public, private, readwrite)",String) { |val| configuration.type = val }
|
|
115
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
116
|
+
puts opts
|
|
117
|
+
exit
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
opts.parse(args)
|
|
121
|
+
|
|
122
|
+
if configuration.type.empty? then
|
|
123
|
+
puts opts
|
|
124
|
+
else
|
|
125
|
+
cd(configuration.directory) {
|
|
126
|
+
case configuration.type
|
|
127
|
+
when 'private' then
|
|
128
|
+
do_update_private_site( configuration)
|
|
129
|
+
when 'public'
|
|
130
|
+
do_update_public_site(configuration)
|
|
131
|
+
else
|
|
132
|
+
do_update_readwrite_site( configuration)
|
|
133
|
+
end
|
|
134
|
+
}
|
|
135
|
+
set_owner(configuration.directory,configuration.user)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def Install.make_wiki(args)
|
|
140
|
+
opts = OptionParser.new
|
|
141
|
+
|
|
142
|
+
configuration = Configuration.new
|
|
143
|
+
|
|
144
|
+
opts.on("-u",'--user username',String) { |val| configuration.user.user = val }
|
|
145
|
+
opts.on("-g",'--group groupname',String) { |val| configuration.user.group = val }
|
|
146
|
+
opts.on("-w",'--web default_web',String) { |val| configuration.default_wiki = val }
|
|
147
|
+
opts.on("-d",'--directory dir',"default = .",String) { |val| configuration.directory = File.expand_path(val) }
|
|
148
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
149
|
+
puts opts
|
|
150
|
+
exit
|
|
151
|
+
end
|
|
152
|
+
opts.parse(args)
|
|
153
|
+
|
|
154
|
+
cd(configuration.directory) {
|
|
155
|
+
do_make_wiki(configuration)
|
|
156
|
+
}
|
|
157
|
+
set_owner(configuration.directory,configuration.user)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
private
|
|
161
|
+
|
|
162
|
+
def Install.do_make_public_site(configuration)
|
|
163
|
+
do_update_public_site(configuration)
|
|
164
|
+
config_file = make_config( configuration,'PublicWikiConfig')
|
|
165
|
+
|
|
166
|
+
install_html(configuration)
|
|
167
|
+
|
|
168
|
+
do_make_wiki( configuration)
|
|
169
|
+
|
|
170
|
+
make_public_apache_config( configuration)
|
|
171
|
+
|
|
172
|
+
set_owner( configuration.directory, configuration.user)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def Install.do_make_readwrite_site( configuration)
|
|
176
|
+
do_update_readwrite_site( configuration)
|
|
177
|
+
config_file = make_config( configuration,'ReadWriteWikiConfig')
|
|
178
|
+
|
|
179
|
+
install_html(configuration)
|
|
180
|
+
|
|
181
|
+
do_make_wiki( configuration)
|
|
182
|
+
|
|
183
|
+
make_readwrite_apache_config( configuration)
|
|
184
|
+
|
|
185
|
+
set_owner( configuration.directory, configuration.user)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def Install.do_make_private_site(configuration)
|
|
189
|
+
|
|
190
|
+
do_update_private_site(configuration)
|
|
191
|
+
config_file = make_config( configuration,'PrivateWikiConfig')
|
|
192
|
+
|
|
193
|
+
install_html(configuration)
|
|
194
|
+
|
|
195
|
+
do_make_wiki( configuration)
|
|
196
|
+
|
|
197
|
+
make_apache_private_config( configuration)
|
|
198
|
+
|
|
199
|
+
set_owner( configuration.directory, configuration.user)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def Install.do_update_public_site(config)
|
|
204
|
+
mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
|
|
205
|
+
install_scripts(config)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def Install.do_update_readwrite_site(config)
|
|
209
|
+
mkdir_p(File.join('site','scripts','secure'),{ :mode => 0775})
|
|
210
|
+
install_readwrite_scripts(config)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def Install.do_update_private_site(config)
|
|
214
|
+
mkdir_p(File.join('site','scripts'),{ :mode => 0775})
|
|
215
|
+
install_scripts(config)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def Install.install_scripts(config)
|
|
220
|
+
source = File.join(config.source_dir,'..','cgi')
|
|
221
|
+
copy_scripts(source,'site/scripts')
|
|
222
|
+
copy_scripts(source,'site/scripts/secure')
|
|
223
|
+
source = File.join(source,'secure')
|
|
224
|
+
copy_scripts(source,'site/scripts/secure')
|
|
225
|
+
make_executable('site/scripts')
|
|
226
|
+
make_executable('site/scripts/secure')
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def Install.install_readwrite_scripts(config)
|
|
230
|
+
source = File.join(config.source_dir,'..','cgi')
|
|
231
|
+
copy_scripts(source,'site/scripts') { |name|
|
|
232
|
+
value = (name != 'save.rb' && name != 'edit.rb')
|
|
233
|
+
value
|
|
234
|
+
}
|
|
235
|
+
copy_scripts(source,'site/scripts/secure')
|
|
236
|
+
source = File.join(source,'secure')
|
|
237
|
+
copy_scripts(source,'site/scripts/secure')
|
|
238
|
+
make_executable('site/scripts')
|
|
239
|
+
make_executable('site/scripts/secure')
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def Install.copy_scripts(source,dest)
|
|
243
|
+
ensure_path_exists dest
|
|
244
|
+
Dir.glob(File.join(source,'*')).each do |filename|
|
|
245
|
+
name = File.basename(filename)
|
|
246
|
+
if FileTest.file?(filename) then
|
|
247
|
+
do_copy = true
|
|
248
|
+
do_copy = yield(name) if block_given?
|
|
249
|
+
if do_copy then
|
|
250
|
+
File.open(filename) do |f|
|
|
251
|
+
content = f.readlines
|
|
252
|
+
content.collect! { |line| line.chomp}
|
|
253
|
+
destname = File.join(dest,name)
|
|
254
|
+
File.open(destname,File::CREAT|File::TRUNC|File::RDWR,0775) do |d|
|
|
255
|
+
d.puts content
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def Install.make_executable(dir)
|
|
264
|
+
cd dir do
|
|
265
|
+
Dir['*.rb'].each do |file|
|
|
266
|
+
if file[0] != '.' then
|
|
267
|
+
basename = File.basename(file,'.rb')
|
|
268
|
+
perlname = basename + '.pl'
|
|
269
|
+
begin
|
|
270
|
+
ln_sf(file,basename)
|
|
271
|
+
ln_sf(file,perlname)
|
|
272
|
+
rescue NotImplementedError
|
|
273
|
+
#Symbolic links are not supported on Windows
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def Install.set_owner(dir,owner)
|
|
281
|
+
info = Etc.getpwnam(owner.user)
|
|
282
|
+
if !info.nil? then
|
|
283
|
+
user_id = info.uid
|
|
284
|
+
group_id = info.gid
|
|
285
|
+
if !owner.group.nil? then
|
|
286
|
+
group_id = Etc.getgrnam(owner.group).gid
|
|
287
|
+
end
|
|
288
|
+
Dir.glob('**/*').each do |file|
|
|
289
|
+
if file[0] != '.' then
|
|
290
|
+
puts "Changing ownership of #{file} to #{user_id}:#{group_id}"
|
|
291
|
+
File.chown(user_id,group_id,file)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def Install.make_config(config,baseconfig)
|
|
298
|
+
template = <<-TEMPLATE_END
|
|
299
|
+
#!/usr/bin/env ruby1.8
|
|
300
|
+
|
|
301
|
+
#
|
|
302
|
+
require 'rubygems'
|
|
303
|
+
require_gem "Wiki2Go","=#{WIKI2GO_VERSION}"
|
|
304
|
+
require "Wiki2Go/#{baseconfig}"
|
|
305
|
+
|
|
306
|
+
class CgiOptions < #{baseconfig}
|
|
307
|
+
|
|
308
|
+
def initialize
|
|
309
|
+
super('#{config.directory}')
|
|
310
|
+
|
|
311
|
+
# Set this to false when the site works ok.
|
|
312
|
+
@debug = true
|
|
313
|
+
# Choose whether to have a single wiki or several subwikis
|
|
314
|
+
@multi_wiki = #{ config.default_wiki.empty? ? 'false' : 'true' }
|
|
315
|
+
# Email of administrator of the site. Will be obfuscated on the page.
|
|
316
|
+
@site_admin = 'wiki2go@nayima.be'
|
|
317
|
+
|
|
318
|
+
# System user of the web server
|
|
319
|
+
@user = '#{config.user.user}'
|
|
320
|
+
# System group who has access to the files
|
|
321
|
+
@group = '#{config.user.group}'
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
end
|
|
325
|
+
TEMPLATE_END
|
|
326
|
+
|
|
327
|
+
dest = File.join(config.directory,'site','scripts','CgiOptions.rb')
|
|
328
|
+
if !File.exists?(dest) then
|
|
329
|
+
File.open(dest,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
|
|
330
|
+
f.puts template
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
logfile = File.join(config.directory,'wiki.log')
|
|
335
|
+
if !File.exists?(logfile) then
|
|
336
|
+
touch logfile
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
securedir = File.join(config.directory,'site','scripts','secure')
|
|
340
|
+
if File.exists?(securedir) then
|
|
341
|
+
secure = File.join(securedir,'CgiOptions.rb')
|
|
342
|
+
|
|
343
|
+
begin
|
|
344
|
+
ln_sf(dest,secure)
|
|
345
|
+
rescue NotImplementedError
|
|
346
|
+
#Symbolic links are not supported on Windows
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
return dest
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def Install.install_html(config)
|
|
353
|
+
dest = File.join(config.directory,'site')
|
|
354
|
+
mkdir_p(File.join(dest,'html'),{ :mode => 0775})
|
|
355
|
+
source = File.join(config.source_dir,'site','.')
|
|
356
|
+
cp_r source,dest
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def Install.do_make_wiki(config)
|
|
360
|
+
wikiname = config.default_wiki
|
|
361
|
+
textdir = File.join('texts',wikiname)
|
|
362
|
+
mkdir_p(textdir,{ :mode => 0775})
|
|
363
|
+
frontpage = File.join(textdir,'FrontPage.txt')
|
|
364
|
+
if !File.exists?(frontpage) then
|
|
365
|
+
touch frontpage
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
templatedir = File.join('templates',wikiname)
|
|
369
|
+
mkdir_p(templatedir,{ :mode => 0775})
|
|
370
|
+
source = File.join(config.source_dir,'templates')
|
|
371
|
+
dest = templatedir
|
|
372
|
+
copy_if_not_exists(source,dest)
|
|
373
|
+
|
|
374
|
+
source = File.join(config.source_dir,'wiki','.')
|
|
375
|
+
wiki_html = File.join('site','html',wikiname)
|
|
376
|
+
mkdir_p(wiki_html,{ :mode => 0775})
|
|
377
|
+
copy_if_not_exists(source,wiki_html)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
make_static_homepage(config)
|
|
381
|
+
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def Install.copy_if_not_exists(source,dest)
|
|
385
|
+
Dir.glob(File.join(source,'*')).each do |sourcefile|
|
|
386
|
+
if FileTest.file?(sourcefile) then
|
|
387
|
+
name = File.basename(sourcefile)
|
|
388
|
+
destfile = File.join(dest,name)
|
|
389
|
+
if !File.exists?(destfile) then
|
|
390
|
+
cp sourcefile,destfile
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def Install.write_apache_config(config,contents)
|
|
397
|
+
config_dir = File.join(config.directory,'config')
|
|
398
|
+
mkdir_p(config_dir,{ :mode => 0775}) unless File.exists?(config_dir)
|
|
399
|
+
|
|
400
|
+
configfile = File.join(config_dir,'site.conf')
|
|
401
|
+
File.open(configfile,File::CREAT|File::TRUNC|File::RDWR,0664) do |f|
|
|
402
|
+
f.puts contents
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
source = File.join(config.source_dir,'config')
|
|
406
|
+
copy_if_not_exists(source,config_dir)
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def Install.make_public_apache_config(config)
|
|
410
|
+
template = <<-END_TEMPLATE
|
|
411
|
+
<VirtualHost *#{config.dotted_port}>
|
|
412
|
+
ServerName #{config.server}
|
|
413
|
+
DocumentRoot #{config.directory}/site
|
|
414
|
+
RedirectMatch ^/$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
415
|
+
RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
416
|
+
ScriptAlias /scripts #{config.directory}/site/scripts
|
|
417
|
+
ScriptAlias /scripts/secure #{config.directory}/site/scripts/secure
|
|
418
|
+
<Directory "#{config.directory}/site/scripts">
|
|
419
|
+
Options ExecCGI FollowSymLinks
|
|
420
|
+
</Directory>
|
|
421
|
+
<Directory "#{config.directory}/site/scripts/secure">
|
|
422
|
+
AuthType Basic
|
|
423
|
+
AuthName "#{config.default_wiki} wiki site"
|
|
424
|
+
AuthUserFile #{config.directory}/config/passwords
|
|
425
|
+
require valid-user
|
|
426
|
+
Options ExecCGI FollowSymLinks
|
|
427
|
+
</Directory>
|
|
428
|
+
ErrorLog /var/log/apache/wiki_#{config.default_wiki}_err.log
|
|
429
|
+
CustomLog /var/log/apache/wiki_#{config.default_wiki}.log combined
|
|
430
|
+
|
|
431
|
+
</VirtualHost>
|
|
432
|
+
END_TEMPLATE
|
|
433
|
+
|
|
434
|
+
write_apache_config(config,template)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def Install.make_readwrite_apache_config(config)
|
|
438
|
+
template = <<-END_TEMPLATE
|
|
439
|
+
<VirtualHost *#{config.dotted_port}>
|
|
440
|
+
ServerName #{config.server}
|
|
441
|
+
DocumentRoot #{config.directory}/site
|
|
442
|
+
RedirectMatch ^/$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
443
|
+
RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
444
|
+
ScriptAlias /scripts #{config.directory}/site/scripts
|
|
445
|
+
ScriptAlias /scripts/secure #{config.directory}/site/scripts/secure
|
|
446
|
+
<Directory "#{config.directory}/site/scripts">
|
|
447
|
+
Options ExecCGI FollowSymLinks
|
|
448
|
+
</Directory>
|
|
449
|
+
<Directory "#{config.directory}/site/scripts/secure">
|
|
450
|
+
AuthType Basic
|
|
451
|
+
AuthName "#{config.default_wiki} wiki site"
|
|
452
|
+
AuthUserFile #{config.directory}/config/passwords
|
|
453
|
+
require valid-user
|
|
454
|
+
Options ExecCGI FollowSymLinks
|
|
455
|
+
</Directory>
|
|
456
|
+
ErrorLog /var/log/apache/wiki_#{config.default_wiki}_err.log
|
|
457
|
+
CustomLog /var/log/apache/wiki_#{config.default_wiki}.log combined
|
|
458
|
+
|
|
459
|
+
</VirtualHost>
|
|
460
|
+
END_TEMPLATE
|
|
461
|
+
|
|
462
|
+
write_apache_config(config,template)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def Install.make_apache_private_config(config)
|
|
466
|
+
template = <<-END_TEMPLATE
|
|
467
|
+
<VirtualHost *#{config.dotted_port}>
|
|
468
|
+
ServerName #{config.server}
|
|
469
|
+
DocumentRoot #{config.directory}/site
|
|
470
|
+
RedirectMatch ^/$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
471
|
+
RedirectMatch ^$ http://#{File.join(config.server_url,config.default_wiki,'FrontPage.html')}
|
|
472
|
+
ScriptAlias /scripts #{config.directory}/site/scripts
|
|
473
|
+
<Directory "#{config.directory}/site/">
|
|
474
|
+
AuthType Basic
|
|
475
|
+
AuthName "#{config.default_wiki} wiki site"
|
|
476
|
+
AuthUserFile #{config.directory}/config/passwords
|
|
477
|
+
require valid-user
|
|
478
|
+
Options ExecCGI FollowSymLinks
|
|
479
|
+
</Directory>
|
|
480
|
+
<Directory "#{config.directory}/site/scripts/">
|
|
481
|
+
Options ExecCGI FollowSymLinks
|
|
482
|
+
</Directory>
|
|
483
|
+
ErrorLog /var/log/apache/wiki_#{config.default_wiki}_err.log
|
|
484
|
+
CustomLog /var/log/apache/wiki_#{config.default_wiki}.log combined
|
|
485
|
+
|
|
486
|
+
</VirtualHost>
|
|
487
|
+
END_TEMPLATE
|
|
488
|
+
|
|
489
|
+
write_apache_config(config,template)
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def Install.make_static_homepage(configuration)
|
|
493
|
+
case configuration.type
|
|
494
|
+
when "private" then
|
|
495
|
+
configtype = PrivateWikiConfig
|
|
496
|
+
when "public" then
|
|
497
|
+
configtype = PublicWikiConfig
|
|
498
|
+
else
|
|
499
|
+
configtype =ReadWriteWikiConfig
|
|
500
|
+
end
|
|
501
|
+
config = configtype.new(configuration.directory)
|
|
502
|
+
if config.generate_html then
|
|
503
|
+
wiki = Wiki2Go::Wiki.new(config)
|
|
504
|
+
web = Wiki2Go::Web.new(configuration.server,configuration.port,"scripts","view.rb",configuration.default_wiki,"FrontPage")
|
|
505
|
+
wiki.generate_html(web)
|
|
506
|
+
end
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
private
|
|
510
|
+
|
|
511
|
+
def Install.ensure_path_exists(path)
|
|
512
|
+
mkdir_p(path,{ :mode => 0775}) unless File.exists?(path)
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
end
|