Wiki2Go 1.17.5 → 1.22.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/Wiki2Go_firewall_blacklist.rb +8 -0
- data/bin/Wiki2Go_make_cvs_repository.rb +1 -0
- data/bin/Wiki2Go_make_site.rb +1 -2
- data/bin/Wiki2Go_update_site.rb +1 -2
- data/lib/Web2Go/CGIRequest.rb +8 -2
- data/lib/Web2Go/CGIResponse.rb +17 -14
- data/lib/Web2Go/MockRequest.rb +12 -2
- data/lib/Web2Go/MockResponse.rb +10 -7
- data/lib/Web2Go/WebrickRequest.rb +106 -101
- data/lib/Web2Go/WebrickResponse.rb +4 -8
- data/lib/Wiki2Go/BlackList.rb +48 -25
- data/lib/Wiki2Go/DotGraphics.rb +1 -1
- data/lib/Wiki2Go/FileStorage.rb +266 -266
- data/lib/Wiki2Go/HTMLFormatter.rb +28 -0
- data/lib/Wiki2Go/Install/config/chonqed_blacklist.txt +418 -0
- data/lib/Wiki2Go/Install/config/passwords +1 -1
- data/lib/Wiki2Go/Install/config/url_blacklist.txt +3855 -0
- data/lib/Wiki2Go/Install/make_repository.rb +32 -26
- data/lib/Wiki2Go/Install/make_site.rb +197 -111
- data/lib/Wiki2Go/Install/site/error.html +1 -1
- data/lib/Wiki2Go/Install/site/robots.txt +10 -1
- data/lib/Wiki2Go/Install/site/style.css +129 -64
- data/lib/Wiki2Go/Install/templates/admin.htm +1 -1
- data/lib/Wiki2Go/Install/templates/admin_pages/edit.txt +2 -1
- data/lib/Wiki2Go/Install/templates/admin_pages/format_for_fck.txt +31 -0
- data/lib/Wiki2Go/Install/templates/admin_pages/passwords.txt +1 -1
- data/lib/Wiki2Go/Install/templates/edit.htm +62 -46
- data/lib/Wiki2Go/Install/templates/full_footer.htm +31 -33
- data/lib/Wiki2Go/Install/templates/header.htm +0 -1
- data/lib/Wiki2Go/Install/templates/menu.htm +29 -0
- data/lib/Wiki2Go/Install/templates/pagelist.htm +46 -43
- data/lib/Wiki2Go/Install/templates/simple_footer.htm +20 -16
- data/lib/Wiki2Go/Install/templates/versionlist.htm +52 -40
- data/lib/Wiki2Go/Install/templates/view.htm +46 -29
- data/lib/Wiki2Go/Install/templates/wikiedit.htm +63 -0
- data/lib/Wiki2Go/Install/wiki/delete.png +0 -0
- data/lib/Wiki2Go/Install/wiki/style.css +133 -63
- data/lib/Wiki2Go/LineFormatter.rb +345 -197
- data/lib/Wiki2Go/Page.rb +16 -3
- data/lib/Wiki2Go/PrivateWikiConfig.rb +5 -5
- data/lib/Wiki2Go/PublicWikiConfig.rb +83 -37
- data/lib/Wiki2Go/ReadWriteWikiConfig.rb +8 -8
- data/lib/Wiki2Go/Server.rb +6 -1
- data/lib/Wiki2Go/SpamFilter.rb +32 -41
- data/lib/Wiki2Go/Web.rb +10 -3
- data/lib/Wiki2Go/Wiki2Go.rb +301 -94
- data/lib/Wiki2Go/Wiki2GoConfig.rb +87 -6
- data/lib/Wiki2Go/Wiki2GoServlet.rb +66 -12
- data/lib/Wiki2Go/WikiFormatter.rb +60 -30
- data/lib/Wiki2Go/cgi/diff.rb +20 -0
- data/lib/Wiki2Go/cgi/secure/log_rss.rb +21 -0
- data/lib/Wiki2Go/cgi/sidebyside.rb +20 -0
- data/lib/Wiki2Go/cgi/wikiedit.rb +20 -0
- data/lib/Wiki2Go/firewall_blacklist.rb +88 -0
- data/test/All.rb +5 -2
- data/test/TestBlackList.rb +70 -14
- data/test/TestConfig.rb +5 -5
- data/test/TestDiff.rb +95 -0
- data/test/TestFormatter.rb +14 -16
- data/test/TestHTMLFormatter.rb +37 -0
- data/test/TestInstall.rb +70 -27
- data/test/TestLineFormatter.rb +71 -15
- data/test/TestRSS.rb +8 -7
- data/test/TestRepository.rb +50 -0
- data/test/TestServer.rb +3 -8
- data/test/TestSpamFilter.rb +33 -1
- data/test/TestStorage.rb +11 -0
- data/test/TestWeb.rb +2 -2
- data/test/TestWiki2Go.rb +766 -166
- data/test/TestWiki2GoServlet.rb +1122 -524
- data/test/UnitTestFiles.rb +7 -3
- data/test/Wiki2GoConfigForTest.rb +40 -6
- data/test/checksite.rb +17 -50
- data/test/test_firewall_blacklist.rb +131 -0
- data/test/test_page.rb +45 -0
- data/test/testdata/Registration.rbl.txt +7 -0
- data/test/testdata/config/url_blacklist.txt +38822 -0
- data/test/testdata/expected_changes.html +1 -2
- data/test/testdata/expected_edit.html +108 -59
- data/test/testdata/expected_full_rss.xml +2 -2
- data/test/testdata/expected_out.html +97 -61
- data/test/testdata/expected_put.html +88 -53
- data/test/testdata/expected_save.html +88 -52
- data/test/testdata/expected_savehtml.html +88 -52
- data/test/testdata/expected_search.html +68 -53
- data/test/testdata/expected_upload.html +88 -53
- data/test/testdata/expected_versions.html +97 -82
- data/test/testdata/expected_view.html +97 -61
- data/test/testdata/firewall/iptables.config +37 -0
- data/test/testdata/firewall/user_blacklist.txt +162 -0
- data/test/testdata/logs/wiki.log +652 -0
- data/test/testdata/logs/wiki.log.0 +113 -0
- data/test/testdata/logs/wiki.log.1 +113 -0
- data/test/testdata/logs/wiki.log.2 +113 -0
- data/test/testdata/logs/wiki.log.3 +115 -0
- data/test/testdata/logs/wiki.log.4 +5 -0
- data/test/testdata/logs/wiki.log.5 +7 -0
- data/test/testdata/logs/wiki.log.6 +5 -0
- data/test/testdata/logs/wiki.log.7 +118 -0
- data/test/testdata/logs/wiki.log.8 +12 -0
- data/test/testdata/site/html/Xpday/rss.xml +53 -103
- data/test/testdata/texts/Bugs/FrontPage.txt +6 -0
- data/test/testdata/texts/Bugs/NoHidden.spam +17850 -0
- data/test/testdata/texts/Bugs/PairProgrammingParties.spam +102 -0
- data/test/testdata/texts/Bugs/PairProgrammingParties.txt +99 -0
- metadata +53 -7
- data/test/TestMail.rb +0 -29
- data/test/gc.log +0 -2
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
require "Wiki2Go/FileStorage.rb"
|
5
|
+
require "Wiki2Go/Install/make_repository.rb"
|
5
6
|
require 'fileutils'
|
6
7
|
require 'logger'
|
7
8
|
|
@@ -18,6 +19,9 @@ module Wiki2Go
|
|
18
19
|
attr_accessor :root_directory
|
19
20
|
attr_accessor :site_directory
|
20
21
|
|
22
|
+
attr_accessor :user
|
23
|
+
attr_accessor :group
|
24
|
+
|
21
25
|
attr_accessor :generate_html
|
22
26
|
attr_accessor :debug
|
23
27
|
attr_accessor :multi_wiki
|
@@ -27,6 +31,16 @@ module Wiki2Go
|
|
27
31
|
attr_accessor :subsite
|
28
32
|
attr_accessor :blog_style
|
29
33
|
attr_accessor :maximum_urls
|
34
|
+
attr_accessor :pages_in_recent_changes
|
35
|
+
attr_accessor :pages_in_rss
|
36
|
+
attr_accessor :editor
|
37
|
+
attr_accessor :delete_spam
|
38
|
+
# User must submit a checksum of the original page when saving
|
39
|
+
attr_accessor :checksum_required
|
40
|
+
# Salt to make checksum unique and unguessable
|
41
|
+
attr_accessor :checksum_salt
|
42
|
+
# When a document is submitted without a checksum, blacklist the sender (default = false)
|
43
|
+
attr_accessor :blacklist_when_no_checksum
|
30
44
|
|
31
45
|
# directory = base directory of the wiki. Current directory by default
|
32
46
|
def initialize(directory=nil)
|
@@ -50,8 +64,25 @@ module Wiki2Go
|
|
50
64
|
@subsite = ''
|
51
65
|
@blog_style = false
|
52
66
|
@maximum_urls = 5
|
53
|
-
|
67
|
+
|
68
|
+
@pages_in_recent_changes = 20
|
69
|
+
@pages_in_rss = 20
|
70
|
+
@editor = 'wikiedit'
|
71
|
+
@delete_spam = false
|
72
|
+
|
73
|
+
@checksum_required = false
|
74
|
+
@checksum_salt = '^$%wiki#§}'
|
75
|
+
@blacklist_when_no_checksum = false
|
76
|
+
|
54
77
|
@logger = nil
|
78
|
+
|
79
|
+
@user = nil
|
80
|
+
@group = nil
|
81
|
+
|
82
|
+
@banned_users = nil
|
83
|
+
@banned_urls = nil
|
84
|
+
@chonqed_urls = nil
|
85
|
+
@greylist = nil
|
55
86
|
end
|
56
87
|
|
57
88
|
# return current Storage object.
|
@@ -68,6 +99,26 @@ module Wiki2Go
|
|
68
99
|
@logger
|
69
100
|
end
|
70
101
|
|
102
|
+
def banned_users
|
103
|
+
@banned_users ||= storage.load_blacklist('user')
|
104
|
+
@banned_users
|
105
|
+
end
|
106
|
+
|
107
|
+
def banned_urls
|
108
|
+
@banned_urls ||= storage.load_blacklist('url',true)
|
109
|
+
@banned_urls
|
110
|
+
end
|
111
|
+
|
112
|
+
def chonqed_urls
|
113
|
+
@chonqed_urls ||= storage.load_blacklist('chonqed')
|
114
|
+
@chonqed_urls
|
115
|
+
end
|
116
|
+
|
117
|
+
def greylist
|
118
|
+
@greylist ||= storage.load_greylist
|
119
|
+
@greylist
|
120
|
+
end
|
121
|
+
|
71
122
|
# Discard configuration. Closes logger object, if present
|
72
123
|
def close
|
73
124
|
@logger.close unless @logger.nil?
|
@@ -126,8 +177,38 @@ module Wiki2Go
|
|
126
177
|
true
|
127
178
|
end
|
128
179
|
|
180
|
+
# Check if we want to accept calls from the user before doing anything
|
181
|
+
# web:: a Web object describing the request
|
182
|
+
# true by default, subclasses can override
|
183
|
+
def accept_user?(web)
|
184
|
+
true
|
185
|
+
end
|
186
|
+
|
187
|
+
# Check if the edit is correct (not by a spammer, no editing clash)
|
188
|
+
# old_page:: the page as it is on disk
|
189
|
+
# checksum:: the checksum submitted with the edit
|
190
|
+
def accept_edit?(web,old_page,checksum)
|
191
|
+
checksum = checksum.strip
|
192
|
+
if @checksum_required then
|
193
|
+
check = old_page.checksum(@checksum_salt)
|
194
|
+
if check != checksum then
|
195
|
+
author = web.user
|
196
|
+
pagename = web.name.length > 0 ? "#{web.name}/#{web.current_page}" : web.current_page
|
197
|
+
|
198
|
+
log("User #{author} gave wrong checksum when editing '#{pagename}': #{checksum} vs #{check}.")
|
199
|
+
end
|
200
|
+
return check == checksum
|
201
|
+
end
|
202
|
+
true
|
203
|
+
end
|
204
|
+
|
205
|
+
# Add the spammer IP address to the blacklist
|
206
|
+
def blacklist_user(spammer)
|
207
|
+
|
208
|
+
end
|
209
|
+
|
129
210
|
def redirect_to_html?(web)
|
130
|
-
@generate_html && !web.secure
|
211
|
+
@generate_html && !web.secure?
|
131
212
|
end
|
132
213
|
|
133
214
|
def add_processor(type,proc)
|
@@ -180,7 +261,7 @@ module Wiki2Go
|
|
180
261
|
require 'Wiki2Go/Install/make_repository'
|
181
262
|
|
182
263
|
def update_from_repository
|
183
|
-
cvs = RepositoryMaker.new(@root,logger)
|
264
|
+
cvs = Wiki2Go::RepositoryMaker.new(@root,logger)
|
184
265
|
updated,clashed = cvs.update(@root_directory,@modulename)
|
185
266
|
log("UPDATE: Updated files : #{updated.join(', ')}")
|
186
267
|
log("UPDATE: Clashed files : #{clashed.join(', ')}")
|
@@ -188,14 +269,14 @@ module Wiki2Go
|
|
188
269
|
end
|
189
270
|
|
190
271
|
def commit_to_repository(comment='No Comment')
|
191
|
-
cvs = RepositoryMaker.new(@root,logger)
|
272
|
+
cvs = Wiki2Go::RepositoryMaker.new(@root,logger)
|
192
273
|
report = cvs.add_wiki(@root_directory,@modulename,comment)
|
193
274
|
log("COMMIT: #{report.join}")
|
194
275
|
return report
|
195
276
|
end
|
196
277
|
|
197
278
|
def instant_commit_to_repository(comment='No Comment')
|
198
|
-
cvs = RepositoryMaker.new(@root,logger)
|
279
|
+
cvs = Wiki2Go::RepositoryMaker.new(@root,logger)
|
199
280
|
if cvs.is_local?(@root_directory,@modulename) then
|
200
281
|
report = cvs.add_wiki(@root_directory,@modulename,comment)
|
201
282
|
log("COMMIT: #{report.join}")
|
@@ -229,7 +310,7 @@ module Wiki2Go
|
|
229
310
|
def make_logger
|
230
311
|
dir = File.dirname(logfile)
|
231
312
|
FileUtils::mkdir_p(dir, { :mode => 0775 }) unless File.exists?(dir)
|
232
|
-
@logger = Logger.new(logfile, 10,
|
313
|
+
@logger = Logger.new(logfile, 10, 256000)
|
233
314
|
@logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
234
315
|
@logger
|
235
316
|
end
|
@@ -20,14 +20,17 @@ module Wiki2Go
|
|
20
20
|
result
|
21
21
|
end
|
22
22
|
|
23
|
-
def perform_view(req,res,
|
23
|
+
def perform_view(req,res,web)
|
24
24
|
wiki = Wiki2Go::Wiki.new(@config)
|
25
25
|
|
26
|
+
version = -1
|
27
|
+
version = web.request.parameter('version',-1).to_i unless web.request.nil?
|
28
|
+
|
26
29
|
res.content_type = 'text/html'
|
27
|
-
if @config.allow_dynamic_pages &&
|
28
|
-
res.body = wiki.perform(
|
30
|
+
if @config.allow_dynamic_pages && web.current_page =~ /\.rbl$/i then
|
31
|
+
res.body = wiki.perform(web,req)
|
29
32
|
else
|
30
|
-
res.body = wiki.view(
|
33
|
+
res.body = wiki.view(web,version)
|
31
34
|
end
|
32
35
|
true
|
33
36
|
end
|
@@ -39,15 +42,46 @@ module Wiki2Go
|
|
39
42
|
res.body = wiki.perform(wikiweb,req)
|
40
43
|
true
|
41
44
|
end
|
45
|
+
|
46
|
+
def perform_diff(req,res,wikiweb)
|
47
|
+
from = -1
|
48
|
+
from = wikiweb.request.parameter('from',-1).to_i unless wikiweb.request.nil?
|
49
|
+
|
50
|
+
to = -1
|
51
|
+
to = wikiweb.request.parameter('to',-1).to_i unless wikiweb.request.nil?
|
52
|
+
|
53
|
+
wiki = Wiki2Go::Wiki.new(@config)
|
54
|
+
|
55
|
+
res.content_type = 'text/html'
|
56
|
+
res.body = wiki.diff(wikiweb,from,to)
|
57
|
+
true
|
58
|
+
end
|
42
59
|
|
60
|
+
def perform_sidebyside(req,res,wikiweb)
|
61
|
+
from = -1
|
62
|
+
from = wikiweb.request.parameter('from',-1).to_i unless wikiweb.request.nil?
|
63
|
+
|
64
|
+
to = -1
|
65
|
+
to = wikiweb.request.parameter('to',-1).to_i unless wikiweb.request.nil?
|
66
|
+
|
67
|
+
wiki = Wiki2Go::Wiki.new(@config)
|
68
|
+
|
69
|
+
res.content_type = 'text/html'
|
70
|
+
res.body = wiki.sidebyside(wikiweb,from,to)
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
43
74
|
def perform_save(req,res,wikiweb)
|
44
75
|
|
76
|
+
return false if req.request_method != 'POST'
|
77
|
+
|
45
78
|
content = req.parameter('text','')
|
46
79
|
name = req.parameter('title',wikiweb.current_page)
|
47
80
|
author = req.parameter('author')
|
48
81
|
remember_me = req.parameter('remember_me')
|
49
|
-
|
50
|
-
|
82
|
+
checksum = req.parameter('iznorobot','')
|
83
|
+
|
84
|
+
if !author.nil? && author.length > 0 then # !wikiweb.secure? &&
|
51
85
|
wikiweb.alias = author
|
52
86
|
timeout = Time.now + 7 * 24 * 3600
|
53
87
|
res.add_cookie(USER_COOKIE,author,nil,'/',timeout) unless remember_me.nil?
|
@@ -57,7 +91,7 @@ module Wiki2Go
|
|
57
91
|
|
58
92
|
wikiweb.title = name
|
59
93
|
|
60
|
-
redirect_to = wiki.save(wikiweb,content)
|
94
|
+
redirect_to = wiki.save(wikiweb,content,checksum)
|
61
95
|
res.redirect_to = redirect_to
|
62
96
|
res.content_type = "text/html"
|
63
97
|
res.body = "Redirect to #{redirect_to}"
|
@@ -98,6 +132,14 @@ module Wiki2Go
|
|
98
132
|
true
|
99
133
|
end
|
100
134
|
|
135
|
+
def perform_wikiedit(req,res,wikiweb)
|
136
|
+
wiki = Wiki2Go::Wiki.new(@config)
|
137
|
+
|
138
|
+
res.content_type = "text/html"
|
139
|
+
res.body = wiki.wikiedit(wikiweb)
|
140
|
+
true
|
141
|
+
end
|
142
|
+
|
101
143
|
def perform_redirect(req,res,wikiweb)
|
102
144
|
redirect_to = req.parameter('url')
|
103
145
|
|
@@ -128,8 +170,11 @@ module Wiki2Go
|
|
128
170
|
wiki.blacklist(user)
|
129
171
|
end
|
130
172
|
|
173
|
+
redirect_to = wiki.remove_spam(wikiweb)
|
174
|
+
res.redirect_to = redirect_to
|
131
175
|
res.content_type = "text/html"
|
132
|
-
res.body =
|
176
|
+
res.body = "Redirect to #{redirect_to}"
|
177
|
+
@config.log("Remove spam done. Redirecting to #{redirect_to}")
|
133
178
|
true
|
134
179
|
end
|
135
180
|
|
@@ -175,6 +220,11 @@ module Wiki2Go
|
|
175
220
|
|
176
221
|
def execute_command(req,res)
|
177
222
|
wikiweb = Wiki2Go::Web.from_request(req,@config)
|
223
|
+
if !@config.accept_user?(wikiweb) then
|
224
|
+
res.failed
|
225
|
+
return false
|
226
|
+
end
|
227
|
+
|
178
228
|
command = wikiweb.verb
|
179
229
|
begin
|
180
230
|
if command =~ /^([^\.]+)\./ then
|
@@ -191,18 +241,19 @@ module Wiki2Go
|
|
191
241
|
end
|
192
242
|
end
|
193
243
|
end
|
244
|
+
|
194
245
|
return false
|
195
246
|
end
|
196
247
|
|
197
248
|
def perform(method,req,res,wikiweb)
|
198
|
-
@config.log(">> #{method} #{req.cookies.inspect}")
|
249
|
+
@config.log(">> #{method}(#{wikiweb.name},#{wikiweb.current_page}) #{req.cookies.inspect}")
|
199
250
|
start_time = Time.now.to_f
|
200
251
|
begin
|
201
252
|
cookie = req.cookie(USER_COOKIE)
|
202
|
-
|
253
|
+
|
203
254
|
author = cookie.value.to_s unless cookie.nil?
|
204
255
|
|
205
|
-
if !author.nil? && author.length > 0 then # !wikiweb.secure &&
|
256
|
+
if !author.nil? && author.length > 0 then # !wikiweb.secure? &&
|
206
257
|
wikiweb.alias = author
|
207
258
|
end
|
208
259
|
|
@@ -210,9 +261,12 @@ module Wiki2Go
|
|
210
261
|
return result
|
211
262
|
rescue WEBrick::HTTPStatus::Redirect => redirect then
|
212
263
|
raise redirect
|
264
|
+
rescue Wiki2Go::SpamException then
|
265
|
+
res.failed
|
266
|
+
return false
|
213
267
|
rescue Exception => e then
|
214
268
|
@config.errorlog("Caught exception in #{method}: #{e.inspect}" + $/ + "Stack: #{$@}")
|
215
|
-
redirect_url =
|
269
|
+
redirect_url = wikiweb.error_page
|
216
270
|
|
217
271
|
res.redirect_to = redirect_url
|
218
272
|
res.body = "redirect to view <a href=\"#{redirect_url}\">view</a><br>"
|
@@ -17,6 +17,8 @@ module Wiki2Go
|
|
17
17
|
attr_reader :searchtopic
|
18
18
|
attr_reader :config
|
19
19
|
attr_accessor :title
|
20
|
+
attr_reader :from
|
21
|
+
attr_reader :to
|
20
22
|
|
21
23
|
def initialize(config,formatter,text,page,web,pages,searchtopic,title)
|
22
24
|
@config = config
|
@@ -26,7 +28,19 @@ module Wiki2Go
|
|
26
28
|
@text = text
|
27
29
|
@pages = pages
|
28
30
|
@searchtopic = searchtopic
|
29
|
-
@title = title
|
31
|
+
@title = title
|
32
|
+
@from = -1
|
33
|
+
@to = -1
|
34
|
+
end
|
35
|
+
|
36
|
+
def versions(from,to)
|
37
|
+
if to > 0 then
|
38
|
+
@to = to
|
39
|
+
@from = from
|
40
|
+
else
|
41
|
+
@from = -1
|
42
|
+
@to = -1
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
@@ -38,11 +52,12 @@ module Wiki2Go
|
|
38
52
|
|
39
53
|
public
|
40
54
|
|
41
|
-
def format_page_in_template(template,page)
|
55
|
+
def format_page_in_template(template,page,version=-1)
|
42
56
|
formatted_page = format_page(page.content)
|
43
57
|
template = splice_variable_values(template,page,formatted_page)
|
44
58
|
erb = ERB.new(template)
|
45
59
|
context = PageContext.new(@config,self,formatted_page,page,@web,nil,nil,nil)
|
60
|
+
context.versions(version-1,version)
|
46
61
|
template = evaluate(erb,context)
|
47
62
|
return template
|
48
63
|
end
|
@@ -56,7 +71,7 @@ module Wiki2Go
|
|
56
71
|
end
|
57
72
|
|
58
73
|
def put_page_in_template(template,page)
|
59
|
-
formatted_page = page.content
|
74
|
+
formatted_page = CGI::escapeHTML(page.content)
|
60
75
|
|
61
76
|
template = splice_variable_values(template,page,formatted_page)
|
62
77
|
erb = ERB.new(template)
|
@@ -65,6 +80,17 @@ module Wiki2Go
|
|
65
80
|
return template
|
66
81
|
end
|
67
82
|
|
83
|
+
def dump_page_in_template(template,page,from,to)
|
84
|
+
formatted_page = page.content
|
85
|
+
|
86
|
+
template = splice_variable_values(template,page,formatted_page)
|
87
|
+
erb = ERB.new(template)
|
88
|
+
context = PageContext.new(@config,self,formatted_page,page,@web,nil,nil,nil)
|
89
|
+
context.versions(from,to)
|
90
|
+
template = evaluate(erb,context)
|
91
|
+
return template
|
92
|
+
end
|
93
|
+
|
68
94
|
def format_page(content)
|
69
95
|
result = format_page_content(content)
|
70
96
|
result += formatting_done
|
@@ -73,41 +99,45 @@ module Wiki2Go
|
|
73
99
|
|
74
100
|
|
75
101
|
def generate_rss(template,changes)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
102
|
+
|
103
|
+
# RSS must contain absolute URLs because some feedreaders don't honor the relative
|
104
|
+
# URLs to the content of the <link> tag
|
105
|
+
old_absolute_urls = @absolute_urls
|
106
|
+
@absolute_urls = true
|
107
|
+
|
108
|
+
template_after_items = <<-END_OF_AFTER_ITEMS_XML
|
83
109
|
</channel>
|
84
110
|
</rss>
|
85
111
|
END_OF_AFTER_ITEMS_XML
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
112
|
+
|
113
|
+
items = ""
|
114
|
+
|
115
|
+
changes.each do |page|
|
116
|
+
items = items + <<-END_OF_ITEMS
|
91
117
|
<item>
|
92
118
|
<title>#{CGI::escapeHTML(page.name)}</title>
|
93
119
|
<author>#{page.alias}</author>
|
94
120
|
<pubDate>#{@config.blog_style ? page.created_on.strftime("%d %B %Y %H:%M GMT") : page.lastmodified.strftime("%d %B %Y %H:%M GMT")}</pubDate>
|
95
121
|
<link>#{absolute_url_of_topic(page.filename)}</link>
|
96
|
-
<guid isPermaLink="true">#{
|
97
|
-
<description><![CDATA[#{format_page(page.content).strip}]]></description>
|
98
|
-
</item>
|
122
|
+
<guid isPermaLink="true">#{absolute_url_of_topic(page.filename)}</guid>
|
99
123
|
END_OF_ITEMS
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
124
|
+
|
125
|
+
if !Page.is_dynamic?(page.filename) then
|
126
|
+
items += "<description><![CDATA[#{format_page(page.content).strip}]]></description>\n"
|
127
|
+
end
|
128
|
+
items += "</item>\n"
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
template = template + items + template_after_items
|
133
|
+
|
134
|
+
# We're using hard coded GMT, because %Z returns something strange
|
135
|
+
time = Time.new.gmtime.strftime("%d %B %Y %H:%M GMT")
|
136
|
+
template.gsub!(/\$DATE\$/, time)
|
137
|
+
template = splice_web_values(template)
|
138
|
+
|
139
|
+
@absolute_urls = old_absolute_urls
|
140
|
+
return template
|
111
141
|
end
|
112
142
|
|
113
143
|
def generate_rss_from_log(log)
|
@@ -143,7 +173,7 @@ END_OF_HEADER
|
|
143
173
|
<link>#{File.join(@web.base_url,'scripts/secure/admin/show_log')}</link>
|
144
174
|
<author>Wiki2Go</author>
|
145
175
|
<pubDate>#{parse_log_date(datetime).strftime("%d %B %Y %H:%M GMT")}</pubDate>
|
146
|
-
<description><![CDATA[#{message}]]></description>
|
176
|
+
<description><![CDATA[#{CGI::escapeHTML(message)}]]></description>
|
147
177
|
</item>
|
148
178
|
END_OF_ITEMS
|
149
179
|
end
|