Module: Staticfy::Handlers
- Defined in:
- lib/staticfy/handlers.rb,
lib/staticfy/handlers/css.rb,
lib/staticfy/handlers/raw.rb,
lib/staticfy/handlers/base.rb,
lib/staticfy/handlers/html.rb
Defined Under Namespace
Classes: Base, CSS, HTML, Raw
Constant Summary
collapse
- KNOW_EXTENSIONS =
[".htm", ".js", ".css", ".gif", ".jpg", ".jpeg", ".png", ".swf"]
Class Method Summary
collapse
Class Method Details
.factory(ext) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/staticfy/handlers.rb', line 31
def factory(ext)
ext_table = {
".css" => CSS
}
unless klass = ext_table[ext.to_s.downcase]
klass = HTML
end
klass
end
|
.local_uri(uri) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/staticfy/handlers.rb', line 43
def local_uri(uri)
invalid_chars = /[*?\\\/=&]/
current_ext = File.extname(uri.path)
ext = KNOW_EXTENSIONS.include?(current_ext) ? current_ext : ".html"
local = uri.path[1..-1]
local = "index" unless local.length > 0
if uri.query
local += "?" + uri.query.to_s
local += ext
else
local += ext unless current_ext == ext
end
local.gsub(invalid_chars, "_")
end
|