Class: Wiki2Go::Servlet

Inherits:
Object
  • Object
show all
Defined in:
lib/Wiki2Go/Wiki2GoServlet.rb

Constant Summary collapse

'Wiki2Go_user'

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Servlet


13
14
15
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 13

def initialize(config)
  @config = config
end

Instance Method Details

#execute(request, response) ⇒ Object


17
18
19
20
21
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 17

def execute(request,response)
  result = false
  result = execute_command(request,response)
  result
end

#perform_admin(req, res, wikiweb) ⇒ Object


154
155
156
157
158
159
160
161
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 154

def perform_admin(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)
  result = wiki.admin(req)

  res.content_type = "text/html"
  res.body = result
  true
end

#perform_changes(req, res, wikiweb) ⇒ Object


101
102
103
104
105
106
107
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 101

def perform_changes(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.changes(wikiweb)
  true
end

#perform_diff(req, res, wikiweb) ⇒ Object


46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 46

def perform_diff(req,res,wikiweb)
  from = -1
  from = wikiweb.request.parameter('from',-1).to_i unless wikiweb.request.nil?
        
  to = -1
  to = wikiweb.request.parameter('to',-1).to_i unless wikiweb.request.nil?
        
  wiki = Wiki2Go::Wiki.new(@config)
        
  res.content_type = 'text/html'
  res.body = wiki.diff(wikiweb,from,to)
  true
end

#perform_edit(req, res, wikiweb) ⇒ Object


127
128
129
130
131
132
133
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 127

def perform_edit(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.edit(wikiweb)
  true
end

#perform_generate_static(req, res, wikiweb) ⇒ Object


181
182
183
184
185
186
187
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 181

def perform_generate_static(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.generate_html(wikiweb)
  true
end

#perform_log_rss(req, res, wikiweb) ⇒ Object


210
211
212
213
214
215
216
217
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 210

def perform_log_rss(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  errorlog = IO::readlines(@config.logfile)
  res.content_type = "text/xml"
  res.body = wiki.generate_rss_from_log(wikiweb,errorlog)
  true
end

#perform_perform(req, res, wikiweb) ⇒ Object


38
39
40
41
42
43
44
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 38

def perform_perform(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = 'text/html'
  res.body = wiki.perform(wikiweb,req)
  true
end

#perform_redirect(req, res, wikiweb) ⇒ Object


143
144
145
146
147
148
149
150
151
152
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 143

def perform_redirect(req,res,wikiweb)
  redirect_to = req.parameter('url')

  wiki = Wiki2Go::Wiki.new(@config)

  res.redirect_to = redirect_to
  res.content_type = "text/html"
  res.body = "Redirect to #{redirect_to}"
  true
end

#perform_removespam(req, res, wikiweb) ⇒ Object


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 163

def perform_removespam(req,res,wikiweb)

  user = req.parameter('user') 

  wiki = Wiki2Go::Wiki.new(@config)

  if !user.nil? && !user.empty? then
    wiki.blacklist(user)
  end

  redirect_to = wiki.remove_spam(wikiweb) 
  res.redirect_to = redirect_to
  res.content_type = "text/html"
  res.body = "Redirect to #{redirect_to}"
  @config.log("Remove spam done. Redirecting to #{redirect_to}")
  true
end

#perform_save(req, res, wikiweb) ⇒ Object


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 74

def perform_save(req,res,wikiweb)

  return false if req.request_method != 'POST'

  content = req.parameter('text','')
  name    = req.parameter('title',wikiweb.current_page)
  author = req.parameter('author') 
  remember_me = req.parameter('remember_me')
  checksum = req.parameter('iznorobot','')
  
  if !author.nil? && author.length > 0 then # !wikiweb.secure? && 
    wikiweb.alias = author
    timeout = Time.now + 7 * 24 * 3600
    res.add_cookie(USER_COOKIE,author,nil,'/',timeout) unless remember_me.nil?
  end

  wiki = Wiki2Go::Wiki.new(@config)

  wikiweb.title = name

  redirect_to = wiki.save(wikiweb,content,checksum) 
  res.redirect_to = redirect_to
  res.content_type = "text/html"
  res.body = "Redirect to #{redirect_to}"
  true
end

#perform_search(req, res, wikiweb) ⇒ Object


109
110
111
112
113
114
115
116
117
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 109

def perform_search(req,res,wikiweb)
  topic = req.parameter('text')

  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.search(wikiweb,topic)
  true
end

#perform_sidebyside(req, res, wikiweb) ⇒ Object


60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 60

def perform_sidebyside(req,res,wikiweb)
  from = -1
  from = wikiweb.request.parameter('from',-1).to_i unless wikiweb.request.nil?
        
  to = -1
  to = wikiweb.request.parameter('to',-1).to_i unless wikiweb.request.nil?
        
  wiki = Wiki2Go::Wiki.new(@config)
        
  res.content_type = 'text/html'
  res.body = wiki.sidebyside(wikiweb,from,to)
  true
end

#perform_upload(req, res, wikiweb) ⇒ Object


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 189

def perform_upload(req,res,wikiweb)

  uploaded_file = req.uploaded_file('FILE')
  wiki = Wiki2Go::Wiki.new(@config)

  filename = uploaded_file.filename
  if filename =~ /\\/ then
    filename = filename.split('\\').pop
  end

  if filename =~ /\// then
    filename = filename.split('/').pop
  end

  redirect_to = wiki.upload(wikiweb,filename,uploaded_file.content) 
  res.redirect_to = redirect_to
  res.content_type = "text/html"
  res.body = "Redirect to #{redirect_to}"
  true
end

#perform_versions(req, res, wikiweb) ⇒ Object


119
120
121
122
123
124
125
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 119

def perform_versions(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.versions(wikiweb)
  true
end

#perform_view(req, res, web) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 23

def perform_view(req,res,web)
  wiki = Wiki2Go::Wiki.new(@config)

  version = -1
  version = web.request.parameter('version',-1).to_i unless web.request.nil?
 
  res.content_type = 'text/html'
  if @config.allow_dynamic_pages && web.current_page =~ /\.rbl$/i then
    res.body = wiki.perform(web,req)
  else
    res.body = wiki.view(web,version)
  end
  true
end

#perform_wikiedit(req, res, wikiweb) ⇒ Object


135
136
137
138
139
140
141
# File 'lib/Wiki2Go/Wiki2GoServlet.rb', line 135

def perform_wikiedit(req,res,wikiweb)
  wiki = Wiki2Go::Wiki.new(@config)

  res.content_type = "text/html"
  res.body = wiki.wikiedit(wikiweb)
  true
end