mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Merge branch 'feature/default-env-vars' of https://github.com/crainte/Mango into feature/default-env-vars
This commit is contained in:
commit
49425ff714
@ -29,14 +29,16 @@ const readerComponent = () => {
|
|||||||
return {
|
return {
|
||||||
id: i + 1,
|
id: i + 1,
|
||||||
url: `${base_url}api/page/${tid}/${eid}/${i+1}`,
|
url: `${base_url}api/page/${tid}/${eid}/${i+1}`,
|
||||||
width: d.width,
|
width: d.width == 0 ? "100%" : d.width,
|
||||||
height: d.height,
|
height: d.height == 0 ? "100%" : d.height,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const avgRatio = this.items.reduce((acc, cur) => {
|
// Note: for image types not supported by image_size.cr, the width and height will be 0, and so `avgRatio` will be `Infinity`.
|
||||||
|
// TODO: support more image types in image_size.cr
|
||||||
|
const avgRatio = dimensions.reduce((acc, cur) => {
|
||||||
return acc + cur.height / cur.width
|
return acc + cur.height / cur.width
|
||||||
}, 0) / this.items.length;
|
}, 0) / dimensions.length;
|
||||||
|
|
||||||
console.log(avgRatio);
|
console.log(avgRatio);
|
||||||
this.longPages = avgRatio > 2;
|
this.longPages = avgRatio > 2;
|
||||||
|
@ -8,16 +8,21 @@ class Config
|
|||||||
property host : String = (ENV["LISTEN_HOST"]? || "0.0.0.0")
|
property host : String = (ENV["LISTEN_HOST"]? || "0.0.0.0")
|
||||||
property port : Int32 = (ENV["LISTEN_PORT"]? || 9000).to_i
|
property port : Int32 = (ENV["LISTEN_PORT"]? || 9000).to_i
|
||||||
property base_url : String = (ENV["BASE_URL"]? || "/")
|
property base_url : String = (ENV["BASE_URL"]? || "/")
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property session_secret : String = (ENV["SESSION_SECRET"]? || "mango-session-secret")
|
property session_secret : String = (ENV["SESSION_SECRET"]? || "mango-session-secret")
|
||||||
property library_path : String = (ENV["LIBRARY_PATH"]? || "~/mango/library")
|
property library_path : String = (ENV["LIBRARY_PATH"]? || "~/mango/library")
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property library_cache_path : String = (ENV["LIBRARY_CACHE_PATH"]? || "~/mango/library.yml.gz")
|
property library_cache_path : String = (ENV["LIBRARY_CACHE_PATH"]? || "~/mango/library.yml.gz")
|
||||||
property db_path : String = (ENV["DB_PATH"]? || "~/mango/mango.db")
|
property db_path : String = (ENV["DB_PATH"]? || "~/mango/mango.db")
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property queue_db_path : String = (ENV["QUEUE_DB_PATH"]? || "~/mango/queue.db")
|
property queue_db_path : String = (ENV["QUEUE_DB_PATH"]? || "~/mango/queue.db")
|
||||||
property scan_interval_minutes : Int32 = (ENV["SCAN_INTERVAL"]? || 5).to_i
|
property scan_interval_minutes : Int32 = (ENV["SCAN_INTERVAL"]? || 5).to_i
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property thumbnail_generation_interval_hours : Int32 = (ENV["THUMBNAIL_INTERVAL"]? || 24).to_i
|
property thumbnail_generation_interval_hours : Int32 = (ENV["THUMBNAIL_INTERVAL"]? || 24).to_i
|
||||||
property log_level : String = (ENV["LOG_LEVEL"]? || "info")
|
property log_level : String = (ENV["LOG_LEVEL"]? || "info")
|
||||||
property upload_path : String = (ENV["UPLOAD_PATH"]? || "~/mango/uploads")
|
property upload_path : String = (ENV["UPLOAD_PATH"]? || "~/mango/uploads")
|
||||||
property plugin_path : String = (ENV["PLUGIN_PATH"]? || "~/mango/plugins")
|
property plugin_path : String = (ENV["PLUGIN_PATH"]? || "~/mango/plugins")
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property download_timeout_seconds : Int32 = (ENV["DOWNLOAD_TIMEOUT"]? || 30).to_i
|
property download_timeout_seconds : Int32 = (ENV["DOWNLOAD_TIMEOUT"]? || 30).to_i
|
||||||
property cache_enabled : Bool = env_is_true?("CACHE_ENABLED", true)
|
property cache_enabled : Bool = env_is_true?("CACHE_ENABLED", true)
|
||||||
property cache_size_mbs : Int32 = (ENV["CACHE_SIZE"]? || 50).to_i
|
property cache_size_mbs : Int32 = (ENV["CACHE_SIZE"]? || 50).to_i
|
||||||
@ -25,6 +30,7 @@ class Config
|
|||||||
property disable_login : Bool = env_is_true?("DISABLE_LOGIN", false)
|
property disable_login : Bool = env_is_true?("DISABLE_LOGIN", false)
|
||||||
property default_username : String = (ENV["DEFAULT_USERNAME"]? || "")
|
property default_username : String = (ENV["DEFAULT_USERNAME"]? || "")
|
||||||
property auth_proxy_header_name : String = (ENV["AUTH_PROXY_HEADER"]? || "")
|
property auth_proxy_header_name : String = (ENV["AUTH_PROXY_HEADER"]? || "")
|
||||||
|
# ameba:disable Layout/LineLength
|
||||||
property plugin_update_interval_hours : Int32 = (ENV["PLUGIN_UPDATE_INTERVAL"]? || 24).to_i
|
property plugin_update_interval_hours : Int32 = (ENV["PLUGIN_UPDATE_INTERVAL"]? || 24).to_i
|
||||||
|
|
||||||
@@singlet : Config?
|
@@singlet : Config?
|
||||||
|
@ -632,6 +632,16 @@ class Title
|
|||||||
|
|
||||||
if last_read_entry && last_read_entry.finished? username
|
if last_read_entry && last_read_entry.finished? username
|
||||||
last_read_entry = last_read_entry.next_entry username
|
last_read_entry = last_read_entry.next_entry username
|
||||||
|
if last_read_entry.nil?
|
||||||
|
# The last entry is finished. Return the first unfinished entry
|
||||||
|
# (if any)
|
||||||
|
sorted_entries(username).each do |e|
|
||||||
|
unless e.finished? username
|
||||||
|
last_read_entry = e
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
last_read_entry
|
last_read_entry
|
||||||
|
@ -11,6 +11,7 @@ SUPPORTED_IMG_TYPES = %w(
|
|||||||
image/avif
|
image/avif
|
||||||
image/gif
|
image/gif
|
||||||
image/svg+xml
|
image/svg+xml
|
||||||
|
image/jxl
|
||||||
)
|
)
|
||||||
|
|
||||||
def random_str
|
def random_str
|
||||||
@ -49,6 +50,7 @@ def register_mime_types
|
|||||||
# defiend by Crystal in `MIME.DEFAULT_TYPES`
|
# defiend by Crystal in `MIME.DEFAULT_TYPES`
|
||||||
".apng" => "image/apng",
|
".apng" => "image/apng",
|
||||||
".avif" => "image/avif",
|
".avif" => "image/avif",
|
||||||
|
".jxl" => "image/jxl",
|
||||||
}.each do |k, v|
|
}.each do |k, v|
|
||||||
MIME.register k, v
|
MIME.register k, v
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user