mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Revert "Support all image types (resolves #192)"
This reverts commit f67e4e6cb9994fd86cafe8b9d8c0541be3b894cb.
This commit is contained in:
parent
f67e4e6cb9
commit
d9adb49c27
@ -40,7 +40,8 @@ class Entry
|
|||||||
|
|
||||||
file = ArchiveFile.new @zip_path
|
file = ArchiveFile.new @zip_path
|
||||||
@pages = file.entries.count do |e|
|
@pages = file.entries.count do |e|
|
||||||
filename_is_image e.filename
|
SUPPORTED_IMG_TYPES.includes? \
|
||||||
|
MIME.from_filename? e.filename
|
||||||
end
|
end
|
||||||
file.close
|
file.close
|
||||||
end
|
end
|
||||||
@ -102,7 +103,8 @@ class Entry
|
|||||||
ArchiveFile.open @zip_path do |file|
|
ArchiveFile.open @zip_path do |file|
|
||||||
entries = file.entries
|
entries = file.entries
|
||||||
.select { |e|
|
.select { |e|
|
||||||
filename_is_image e.filename
|
SUPPORTED_IMG_TYPES.includes? \
|
||||||
|
MIME.from_filename? e.filename
|
||||||
}
|
}
|
||||||
.sort! { |a, b|
|
.sort! { |a, b|
|
||||||
compare_numerically a.filename, b.filename
|
compare_numerically a.filename, b.filename
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
SUPPORTED_IMG_TYPES = ["image/jpeg", "image/png", "image/webp"]
|
||||||
|
|
||||||
enum SortMethod
|
enum SortMethod
|
||||||
Auto
|
Auto
|
||||||
Title
|
Title
|
||||||
|
@ -456,8 +456,9 @@ struct APIRouter
|
|||||||
entry_id = env.params.query["eid"]?
|
entry_id = env.params.query["eid"]?
|
||||||
title = Library.default.get_title(title_id).not_nil!
|
title = Library.default.get_title(title_id).not_nil!
|
||||||
|
|
||||||
unless filename_is_image filename
|
unless SUPPORTED_IMG_TYPES.includes? \
|
||||||
raise "The uploaded file must be an image"
|
MIME.from_filename? filename
|
||||||
|
raise "The uploaded image must be either JPEG or PNG"
|
||||||
end
|
end
|
||||||
|
|
||||||
ext = File.extname filename
|
ext = File.extname filename
|
||||||
|
@ -120,7 +120,3 @@ class String
|
|||||||
match / s.size
|
match / s.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename_is_image(fn : String) : Bool
|
|
||||||
MIME.from_filename?(fn).try(&.starts_with?("image/")) || false
|
|
||||||
end
|
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
<span uk-icon="icon: cloud-upload"></span>
|
<span uk-icon="icon: cloud-upload"></span>
|
||||||
<span class="uk-text-middle">Upload a cover image by dropping it here or</span>
|
<span class="uk-text-middle">Upload a cover image by dropping it here or</span>
|
||||||
<div uk-form-custom>
|
<div uk-form-custom>
|
||||||
<input type="file" accept="image/*">
|
<input type="file" accept="<%= SUPPORTED_IMG_TYPES.join ", " %>">
|
||||||
<span class="uk-link">selecting one</span>
|
<span class="uk-link">selecting one</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user