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
File without changes
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'Webrick/httputils'
|
2
|
+
|
3
|
+
module Web2Go
|
4
|
+
|
5
|
+
class WebrickFile
|
6
|
+
def initialize(file)
|
7
|
+
@file = file
|
8
|
+
end
|
9
|
+
|
10
|
+
def filename
|
11
|
+
@file.filename
|
12
|
+
end
|
13
|
+
|
14
|
+
def content
|
15
|
+
@file.list[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class WebrickRequest
|
21
|
+
|
22
|
+
attr_reader :server_variable
|
23
|
+
attr_reader :params
|
24
|
+
attr_reader :user
|
25
|
+
attr_reader :authenticated
|
26
|
+
|
27
|
+
def initialize(request)
|
28
|
+
@request = request
|
29
|
+
@server_variable = request.meta_vars
|
30
|
+
@server_variable['SCRIPT_NAME'], @server_variable['PATH_INFO'] = split_script_and_path(clean(request.path))
|
31
|
+
find_user(request)
|
32
|
+
@params = parse_parameters
|
33
|
+
end
|
34
|
+
|
35
|
+
def path
|
36
|
+
@server_variable['PATH_INFO']
|
37
|
+
end
|
38
|
+
|
39
|
+
def host
|
40
|
+
@request.host
|
41
|
+
end
|
42
|
+
|
43
|
+
def port
|
44
|
+
@request.port
|
45
|
+
end
|
46
|
+
|
47
|
+
def parameter(name,default_value=nil)
|
48
|
+
value = @params[name]
|
49
|
+
if value.nil? then
|
50
|
+
return default_value
|
51
|
+
else
|
52
|
+
return value[0]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def uploaded_file(name,pos=0)
|
57
|
+
file = @request.query[name]
|
58
|
+
if !file.nil? then
|
59
|
+
return WebrickFile.new(file)
|
60
|
+
end
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def cookie(name)
|
66
|
+
return @request.cookies.find { |cookie| cookie.name == name }
|
67
|
+
end
|
68
|
+
|
69
|
+
def cookies
|
70
|
+
@request.cookies
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def find_user(req)
|
76
|
+
@user = ENV['USER'] || ENV['USERNAME']
|
77
|
+
if @user.nil? or @user.length == 0 then
|
78
|
+
@user = req.peeraddr[2]
|
79
|
+
if @user.nil? or @user.length == 0 then
|
80
|
+
@user = req.peeraddr[3]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@authenticated = true
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_parameters(form,values)
|
87
|
+
values.each { |key,value|
|
88
|
+
if form.has_key?(key)
|
89
|
+
form[key].push(value)
|
90
|
+
else
|
91
|
+
form[key] = [ value ]
|
92
|
+
end
|
93
|
+
}
|
94
|
+
form
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_parameters
|
98
|
+
form = { }
|
99
|
+
form = add_parameters(form,WEBrick::HTTPUtils::parse_query(@request.body))
|
100
|
+
form = add_parameters(form,WEBrick::HTTPUtils::parse_query(@request.query_string))
|
101
|
+
form
|
102
|
+
end
|
103
|
+
|
104
|
+
def split_script_and_path(path)
|
105
|
+
if path =~ /\// then
|
106
|
+
path =~ /^([^\/]+)\/(.*)$/
|
107
|
+
return $1,$2
|
108
|
+
else
|
109
|
+
return path,""
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def clean(path)
|
115
|
+
if path.nil? then
|
116
|
+
return ""
|
117
|
+
else
|
118
|
+
return path.squeeze('/').gsub(/^\//,'').gsub(/\/$/,'')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'Webrick/httputils'
|
2
|
+
require 'Webrick/cookie'
|
3
|
+
|
4
|
+
module Web2Go
|
5
|
+
|
6
|
+
class WebrickResponse
|
7
|
+
|
8
|
+
def initialize(response)
|
9
|
+
@response = response
|
10
|
+
end
|
11
|
+
|
12
|
+
def body=(content)
|
13
|
+
@response.body=(content)
|
14
|
+
end
|
15
|
+
|
16
|
+
def content_type=(type)
|
17
|
+
@response['Content-Type'] = type
|
18
|
+
end
|
19
|
+
|
20
|
+
def redirect_to=(url)
|
21
|
+
@response.set_redirect(WEBrick::HTTPStatus[302],url)
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_cookie(cookie)
|
25
|
+
@response.cookies.delete_if { |item| item.name == cookie.name }
|
26
|
+
@response.cookies.push(cookie)
|
27
|
+
end
|
28
|
+
|
29
|
+
def cookies
|
30
|
+
@response.cookies
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_cookie(name,value,domain=nil,path=nil,expires=nil)
|
34
|
+
cookie = WEBrick::Cookie.new(name,value)
|
35
|
+
cookie.expires = expires unless expires.nil?
|
36
|
+
cookie.domain = domain unless domain.nil?
|
37
|
+
cookie.path = path unless path.nil?
|
38
|
+
set_cookie(cookie)
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_cookies(cookies)
|
42
|
+
cookies.each do |cookie|
|
43
|
+
set_cookie(cookie)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/lib/Wiki2Go.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
module Wiki2Go
|
3
|
+
|
4
|
+
class BlackList
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(name,items)
|
9
|
+
@name = name
|
10
|
+
items = items.collect {|line|
|
11
|
+
line.strip!
|
12
|
+
(line.empty? || line[0] == '#' ? nil : line)
|
13
|
+
}
|
14
|
+
@banned = items.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def all
|
18
|
+
return @banned
|
19
|
+
end
|
20
|
+
|
21
|
+
def add(item)
|
22
|
+
item = escape_regex(item)
|
23
|
+
@banned << item
|
24
|
+
@banned = @banned.sort.uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
def length
|
28
|
+
return @banned.length
|
29
|
+
end
|
30
|
+
|
31
|
+
def contains(user)
|
32
|
+
match = @banned.find { |ban| user =~ Regexp.new(ban,Regexp::IGNORECASE) }
|
33
|
+
! match.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def found_in(lines)
|
37
|
+
lines = lines.join(' ') if lines.kind_of? Array
|
38
|
+
@banned.each do | pattern |
|
39
|
+
match = Regexp.new(pattern,Regexp::IGNORECASE)
|
40
|
+
return true if lines =~ match
|
41
|
+
end
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def escape_regex(item)
|
48
|
+
item.gsub(/\./,'\.')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
|
5
|
+
module Wiki2Go
|
6
|
+
|
7
|
+
#
|
8
|
+
#
|
9
|
+
|
10
|
+
class DotGraphics
|
11
|
+
|
12
|
+
def initialize(path)
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
|
16
|
+
def process(config,web,content)
|
17
|
+
config.log("Processing #{web.current_page}")
|
18
|
+
save_if_necessary(config,web,content,false)
|
19
|
+
end
|
20
|
+
|
21
|
+
def save(config,web,content)
|
22
|
+
config.log("Saving #{web.current_page}")
|
23
|
+
save_if_necessary(config,web,content,true)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def save_if_necessary(config,web,content,force)
|
29
|
+
image = content
|
30
|
+
result = ''
|
31
|
+
if image =~ /^([^\s]*)\s/ then
|
32
|
+
filename = $1
|
33
|
+
image = $POSTMATCH
|
34
|
+
image = image.gsub('\n',' ').gsub('\r',' ')
|
35
|
+
result = generate_image(config,web,filename,image,force)
|
36
|
+
end
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_image(config,web,filename,image,force)
|
41
|
+
path = config.site_directory
|
42
|
+
type = File.extname(filename).gsub(/\./,'')
|
43
|
+
fullname = File.join(path,web.name,'graphics',filename)
|
44
|
+
if force || !File.exists?(fullname) then
|
45
|
+
ensure_directory_exists(fullname)
|
46
|
+
config.log("Writing image file to #{fullname}")
|
47
|
+
write(image,type,fullname)
|
48
|
+
end
|
49
|
+
return "<img src=\"#{web.name}/graphics/#{filename}\" border=0 alt=\"#{filename}\">"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def write(graph,format,output)
|
54
|
+
cmdline = "#{File.join(@path,'dot')} -T#{format} -o#{output}"
|
55
|
+
IO.popen(cmdline,"w+") do |f|
|
56
|
+
f.puts graph
|
57
|
+
f.close_write
|
58
|
+
f.read
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def ensure_directory_exists(path)
|
64
|
+
dir,filename = File.split(path)
|
65
|
+
FileUtils.makedirs(dir) unless File.directory?(dir)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'Wiki2Go/Page.rb'
|
4
|
+
require 'Wiki2Go/BlackList.rb'
|
5
|
+
require 'Wiki2Go/WhiteList.rb'
|
6
|
+
require 'Wiki2Go/GreyList.rb'
|
7
|
+
|
8
|
+
require 'fileutils.rb'
|
9
|
+
|
10
|
+
module Wiki2Go
|
11
|
+
|
12
|
+
class FileStorage
|
13
|
+
|
14
|
+
def initialize(dynamic_files,static_files)
|
15
|
+
@path = dynamic_files
|
16
|
+
@html = static_files
|
17
|
+
end
|
18
|
+
|
19
|
+
def exists?(path)
|
20
|
+
return FileTest.exists?(text_path(path,"txt"))
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :exists :exists?
|
24
|
+
|
25
|
+
def load_page(subwiki,name)
|
26
|
+
lines = Array.new(1)
|
27
|
+
lines[0] = ""
|
28
|
+
modified_time = Time.now
|
29
|
+
if exists(File.join(subwiki,name)) then
|
30
|
+
path = text_filename(subwiki,name,"txt")
|
31
|
+
File.open(path) do |f|
|
32
|
+
lines = f.readlines
|
33
|
+
modified_time = File.mtime(path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
return Page.make_page(name,lines,modified_time)
|
37
|
+
end
|
38
|
+
|
39
|
+
def save_page(subwiki,page)
|
40
|
+
path = text_filename(subwiki,page.title,"txt")
|
41
|
+
logfile = text_filename(subwiki,page.title,"log")
|
42
|
+
ensure_directory_exists(path)
|
43
|
+
append_current_text_to_logfile(path,logfile,page.author)
|
44
|
+
File.open(path,File::CREAT|File::TRUNC|File::RDWR) do |file|
|
45
|
+
page.write(file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def save_spam(subwiki,name,content,author)
|
50
|
+
path = text_filename(subwiki,name,"spam")
|
51
|
+
ensure_directory_exists(path)
|
52
|
+
File.open(path,File::CREAT|File::APPEND|File::WRONLY) do |file|
|
53
|
+
file.puts("=== SPAM by #{author} on #{Time.now.strftime("%d/%m/%Y %H:%M")} ===")
|
54
|
+
file.puts(content)
|
55
|
+
file.puts("$LASTMODIFIED:#{Time.now.to_i}$")
|
56
|
+
file.puts("$AUTHOR:#{author}$")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def save_html(subwiki,page, content)
|
61
|
+
path = File.join(@html,subwiki,page + ".html")
|
62
|
+
ensure_directory_exists(path)
|
63
|
+
File.open(path,File::CREAT|File::TRUNC|File::RDWR) do |file|
|
64
|
+
file.puts content
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def store_page(subwiki,page)
|
69
|
+
save_page(subwiki,page)
|
70
|
+
end
|
71
|
+
|
72
|
+
def load_template(subwiki,name)
|
73
|
+
path = template_filename(subwiki,name)
|
74
|
+
template = ""
|
75
|
+
File.open(path) do |f|
|
76
|
+
template = f.gets(nil)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def store_web_file(subwiki,page,content)
|
81
|
+
path = static_filename(subwiki,page)
|
82
|
+
ensure_directory_exists(path)
|
83
|
+
File.open(path,"wb") do |f|
|
84
|
+
f.puts content
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def search(subwiki,phrase)
|
89
|
+
pages = Array.new
|
90
|
+
to_search_for = Regexp.new(phrase)
|
91
|
+
topics = all_pages_in(subwiki)
|
92
|
+
topics.each do |topic|
|
93
|
+
page = load_page(subwiki,topic)
|
94
|
+
page.lines.each do |line|
|
95
|
+
if line =~ to_search_for then
|
96
|
+
pages << page
|
97
|
+
break
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
return pages
|
102
|
+
end
|
103
|
+
|
104
|
+
def all_pages_in(subwiki)
|
105
|
+
textdir = text_directory(subwiki)
|
106
|
+
pattern = File.join(textdir,"**/*.txt")
|
107
|
+
dirlen = pattern.length - 8
|
108
|
+
files = Dir[pattern].sort {|a,b| File.mtime(b) <=> File.mtime(a) }
|
109
|
+
files = files.collect {|file| file[dirlen..-5] }
|
110
|
+
return files
|
111
|
+
end
|
112
|
+
|
113
|
+
def wikis
|
114
|
+
textdir = text_directory('')
|
115
|
+
pattern = File.join(textdir,"*")
|
116
|
+
dirs = Dir[pattern]
|
117
|
+
dirs = dirs.find_all { |name|
|
118
|
+
FileTest.directory?(name) && name[0] != '.' && File.basename(name) != 'CVS'
|
119
|
+
}
|
120
|
+
dirs = dirs.collect { |name| File.basename(name) }
|
121
|
+
end
|
122
|
+
|
123
|
+
def read_changes_in(subwiki,max_number,with_body)
|
124
|
+
files = all_pages_in(subwiki)
|
125
|
+
nbfiles = (max_number < files.length ? max_number : files.length)
|
126
|
+
changed_pages = Array.new
|
127
|
+
for i in 0..nbfiles-1
|
128
|
+
changed_pages << load_page(subwiki,files[i])
|
129
|
+
end
|
130
|
+
return changed_pages
|
131
|
+
end
|
132
|
+
|
133
|
+
def all_versions_of(subwiki,topic)
|
134
|
+
logfile = text_filename(subwiki,topic,"log")
|
135
|
+
versions = Array.new
|
136
|
+
if File.exists?(logfile) then
|
137
|
+
pattern = /^\*\*\* Modified by (.*) \*\*$/
|
138
|
+
lines = Array.new
|
139
|
+
File.open(logfile,"r") do |f|
|
140
|
+
f.each do |line|
|
141
|
+
if line =~ pattern then
|
142
|
+
add_new_version_to(versions,topic,lines,File.mtime(logfile))
|
143
|
+
lines = Array.new
|
144
|
+
else
|
145
|
+
lines << line
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
add_new_version_to(versions,topic,lines,File.mtime(logfile))
|
150
|
+
end
|
151
|
+
|
152
|
+
versions << load_page(subwiki,topic)
|
153
|
+
return versions.reverse
|
154
|
+
end
|
155
|
+
|
156
|
+
def load_blacklist(type = 'user')
|
157
|
+
filename = config_filename(type + "_blacklist","txt")
|
158
|
+
banned = Array.new
|
159
|
+
if File.exists?(filename) then
|
160
|
+
File.open(filename,"r") do |f|
|
161
|
+
banned = f.readlines
|
162
|
+
end
|
163
|
+
end
|
164
|
+
return BlackList.new(filename,banned)
|
165
|
+
end
|
166
|
+
|
167
|
+
def load_whitelist
|
168
|
+
filename = config_filename("whitelist","txt")
|
169
|
+
allowed = Array.new
|
170
|
+
if File.exists?(filename) then
|
171
|
+
File.open(filename,"r") do |f|
|
172
|
+
allowed = f.readlines
|
173
|
+
end
|
174
|
+
end
|
175
|
+
return WhiteList.new(allowed)
|
176
|
+
end
|
177
|
+
|
178
|
+
def load_greylist
|
179
|
+
filename = config_filename("greylist","txt")
|
180
|
+
listed = Array.new
|
181
|
+
if File.exists?(filename) then
|
182
|
+
File.open(filename,"r") do |f|
|
183
|
+
listed = f.readlines
|
184
|
+
end
|
185
|
+
end
|
186
|
+
return GreyList.new(filename,listed)
|
187
|
+
end
|
188
|
+
|
189
|
+
def save_list(list)
|
190
|
+
filename = list.name
|
191
|
+
ensure_directory_exists(filename)
|
192
|
+
File.open(filename,File::CREAT|File::TRUNC|File::RDWR) do |f|
|
193
|
+
f.puts list.all
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
private
|
198
|
+
|
199
|
+
def add_new_version_to(versions,topic,lines,modified_time)
|
200
|
+
if !lines.empty? then
|
201
|
+
page = Page.make_page(topic,lines,modified_time)
|
202
|
+
versions << page
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def append_current_text_to_logfile(file,logfile,author)
|
207
|
+
if File.exists?(file) then
|
208
|
+
File.open(file,"r") do |f|
|
209
|
+
text = f.read
|
210
|
+
File.open(logfile,"a") do |log|
|
211
|
+
log.puts "*** Modified by #{author} **"
|
212
|
+
log.puts text
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def ensure_directory_exists(path)
|
219
|
+
dir,filename = File.split(path)
|
220
|
+
FileUtils.mkdir_p(dir,{ :mode => 0775}) unless File.directory?(dir)
|
221
|
+
end
|
222
|
+
|
223
|
+
def text_path(path,ext)
|
224
|
+
dir = File.dirname(path)
|
225
|
+
file = File.basename(path) + '.' + ext
|
226
|
+
File.join(text_directory(dir),file)
|
227
|
+
end
|
228
|
+
|
229
|
+
def text_filename(subwiki,page,ext)
|
230
|
+
return File.join(text_directory(subwiki),"#{page}.#{ext}")
|
231
|
+
end
|
232
|
+
|
233
|
+
def text_directory(subwiki)
|
234
|
+
dir = File.join(@path,"texts",subwiki)
|
235
|
+
ensure_directory_exists(dir)
|
236
|
+
return dir
|
237
|
+
end
|
238
|
+
|
239
|
+
def config_filename(page,ext)
|
240
|
+
return File.join(config_directory,"#{page}.#{ext}")
|
241
|
+
end
|
242
|
+
|
243
|
+
def config_directory
|
244
|
+
dir = File.join(@path,"config")
|
245
|
+
ensure_directory_exists(dir)
|
246
|
+
return dir
|
247
|
+
end
|
248
|
+
|
249
|
+
def template_filename(subwiki,name)
|
250
|
+
template_dir = File.join(@path,"templates")
|
251
|
+
path = File.join(template_dir,subwiki,name)
|
252
|
+
if !File.exists?(path) then
|
253
|
+
path = File.join(template_dir,name)
|
254
|
+
if !File.exists?(path) then
|
255
|
+
path = File.join(File.dirname(__FILE__),"Install","templates",name)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
return path
|
259
|
+
end
|
260
|
+
|
261
|
+
def static_filename(subwiki,name)
|
262
|
+
return File.join(@html,"html",subwiki,name)
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|