mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Support webp (#69, nice)
This commit is contained in:
parent
4c2cf64f53
commit
dc084aff7c
@ -4,6 +4,8 @@ require "uri"
|
||||
require "./util"
|
||||
require "./archive"
|
||||
|
||||
SUPPORTED_IMG_TYPES = ["image/jpeg", "image/png", "image/webp"]
|
||||
|
||||
struct Image
|
||||
property data : Bytes
|
||||
property mime : String
|
||||
@ -27,7 +29,7 @@ class Entry
|
||||
@size = (File.size path).humanize_bytes
|
||||
file = ArchiveFile.new path
|
||||
@pages = file.entries.count do |e|
|
||||
["image/jpeg", "image/png"].includes? \
|
||||
SUPPORTED_IMG_TYPES.includes? \
|
||||
MIME.from_filename? e.filename
|
||||
end
|
||||
file.close
|
||||
@ -72,7 +74,7 @@ class Entry
|
||||
ArchiveFile.open @zip_path do |file|
|
||||
page = file.entries
|
||||
.select { |e|
|
||||
["image/jpeg", "image/png"].includes? \
|
||||
SUPPORTED_IMG_TYPES.includes? \
|
||||
MIME.from_filename? e.filename
|
||||
}
|
||||
.sort { |a, b|
|
||||
|
@ -224,7 +224,7 @@ class APIRouter < Router
|
||||
entry_id = env.params.query["entry"]?
|
||||
title = @context.library.get_title(title_id).not_nil!
|
||||
|
||||
unless ["image/jpeg", "image/png"].includes? \
|
||||
unless SUPPORTED_IMG_TYPES.includes? \
|
||||
MIME.from_filename? filename
|
||||
raise "The uploaded image must be either JPEG or PNG"
|
||||
end
|
||||
|
@ -72,7 +72,7 @@
|
||||
<span uk-icon="icon: cloud-upload"></span>
|
||||
<span class="uk-text-middle">Upload a cover image by dropping it here or</span>
|
||||
<div uk-form-custom>
|
||||
<input type="file" accept="image/jpeg, image/png">
|
||||
<input type="file" accept="<%= SUPPORTED_IMG_TYPES.join ", " %>">
|
||||
<span class="uk-link">selecting one</span>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user