10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/staticmatic/server.rb', line 10
def process(request, response)
@staticmatic.load_helpers
path_info = request.params[Mongrel::Const::PATH_INFO]
get_or_head = @@file_only_methods.include? request.params[Mongrel::Const::REQUEST_METHOD]
file_dir, file_name, file_ext = expand_path(path_info)
file_dir.gsub!(/^\/stylesheets\/?/, "")
file_dir = CGI::unescape(file_dir)
file_name = CGI::unescape(file_name)
if file_ext && file_ext.match(/html|css/)
response.start(200) do |head, out|
head["Content-Type"] = "text/#{file_ext}"
output = ""
if @staticmatic.template_exists?(file_name, file_dir) && !(File.basename(file_name) =~ /^\_/)
begin
if file_ext == "css"
output = @staticmatic.generate_css(file_name, file_dir)
else
output = @staticmatic.generate_html_with_layout(file_name, file_dir)
end
rescue StaticMatic::Error => e
output = e.message
end
else
if @files.can_serve(path_info)
@files.process(request,response)
else
output = "File not Found"
end
end
out.write output
end
else
if @files.can_serve(path_info)
@files.process(request,response)
end
end
end
|