mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-05 12:25:32 -04:00
Explicitly register supported mime types (#82)
This commit is contained in:
parent
fe082e7537
commit
f5cdf8b7b6
@ -536,6 +536,8 @@ class Library
|
|||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@storage = Storage.default
|
@storage = Storage.default
|
||||||
|
register_mime_types
|
||||||
|
|
||||||
@dir = Config.current.library_path
|
@dir = Config.current.library_path
|
||||||
@scan_interval = Config.current.scan_interval
|
@scan_interval = Config.current.scan_interval
|
||||||
# explicitly initialize @titles to bypass the compiler check. it will
|
# explicitly initialize @titles to bypass the compiler check. it will
|
||||||
|
13
src/util.cr
13
src/util.cr
@ -41,8 +41,6 @@ def send_json(env, json)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def send_attachment(env, path)
|
def send_attachment(env, path)
|
||||||
MIME.register ".cbz", "application/vnd.comicbook+zip"
|
|
||||||
MIME.register ".cbr", "application/vnd.comicbook-rar"
|
|
||||||
send_file env, path, filename: File.basename(path), disposition: "attachment"
|
send_file env, path, filename: File.basename(path), disposition: "attachment"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -164,3 +162,14 @@ def escape_xml(str)
|
|||||||
'&' => "&",
|
'&' => "&",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def register_mime_types
|
||||||
|
{
|
||||||
|
".zip" => "application/zip",
|
||||||
|
".rar" => "application/x-rar-compressed",
|
||||||
|
".cbz" => "application/vnd.comicbook+zip",
|
||||||
|
".cbr" => "application/vnd.comicbook-rar",
|
||||||
|
}.each do |k, v|
|
||||||
|
MIME.register k, v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user