Class: IcalIcsServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/vpim/agent/scraps.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, resp) ⇒ Object

Raises:

  • (WEBrick::HTTPStatus::OK)


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/vpim/agent/scraps.rb', line 151

def do_GET(req, resp)
  body = ''
#   body << @options.inspect

  folder, include, exclude = *@options

  path = req.path_info

#   body << "\n"
#   body << "path=#{path.inspect}\n"

  all = Dir.entries(folder).select do |f| f =~ /\.ics$/ end

  if include
    all.reject! do |f| !(f =~ include) end
  end
  if exclude
    all.reject! do |f| f =~ exclude end
  end

#   body << "#{all.inspect}\n"

  if(path == '')
    body << "<ul>\n"
    all.each do |f|
      n = f.sub('.ics', '')
      body << "<li><a href=\"webcal://#{$host}:#{$port}/calfile/#{f}\">#{n}</a>\n"
    end
    body << "</ul>\n"
  end

  resp.body = body
  resp['content-type'] = 'text/html'
  raise WEBrick::HTTPStatus::OK
end