From e086bec9dafa3141be21ed386adbc73c105ec778 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 6 Jan 2021 15:27:48 +0100 Subject: [PATCH 1/4] Added adjustable page gaps via config --- public/js/reader.js | 3 ++- src/config.cr | 1 + src/library/entry.cr | 1 + src/views/reader.html.ecr | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/js/reader.js b/public/js/reader.js index e890644..88ca8d6 100644 --- a/public/js/reader.js +++ b/public/js/reader.js @@ -25,7 +25,8 @@ const readerComponent = () => { id: i + 1, url: `${base_url}api/page/${tid}/${eid}/${i+1}`, width: d.width, - height: d.height + height: d.height, + style: `margin-top: ${d.margin}px; margin-bottom: ${d.margin}px;` }; }); diff --git a/src/config.cr b/src/config.cr index e85a2b7..845fc94 100644 --- a/src/config.cr +++ b/src/config.cr @@ -20,6 +20,7 @@ class Config property plugin_path : String = File.expand_path "~/mango/plugins", home: true property download_timeout_seconds : Int32 = 30 + property page_margin : Int32 = 30 property disable_login = false property default_username = "" property mangadex = Hash(String, String | Int32).new diff --git a/src/library/entry.cr b/src/library/entry.cr index 3e270cf..137b04d 100644 --- a/src/library/entry.cr +++ b/src/library/entry.cr @@ -117,6 +117,7 @@ class Entry sizes << { "width" => size.width, "height" => size.height, + "margin" => Config.current.page_margin, } rescue e Logger.warn "Failed to read page #{i} of entry #{zip_path}. #{e}" diff --git a/src/views/reader.html.ecr b/src/views/reader.html.ecr index 5475487..91beaf3 100644 --- a/src/views/reader.html.ecr +++ b/src/views/reader.html.ecr @@ -25,6 +25,7 @@ Date: Wed, 6 Jan 2021 15:28:09 +0100 Subject: [PATCH 2/4] Added new entry in example config --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 34944ca..9648669 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ log_level: info upload_path: ~/mango/uploads plugin_path: ~/mango/plugins download_timeout_seconds: 30 +page_margin: 30 mangadex: base_url: https://mangadex.org api_url: https://mangadex.org/api From aa707522449746aa88bc8f27b6e3107f2f976a2e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 6 Jan 2021 17:30:55 +0100 Subject: [PATCH 3/4] Moved margin value to the dimensions API --- public/js/reader.js | 2 +- src/library/entry.cr | 1 - src/routes/api.cr | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/reader.js b/public/js/reader.js index 88ca8d6..321f131 100644 --- a/public/js/reader.js +++ b/public/js/reader.js @@ -26,7 +26,7 @@ const readerComponent = () => { url: `${base_url}api/page/${tid}/${eid}/${i+1}`, width: d.width, height: d.height, - style: `margin-top: ${d.margin}px; margin-bottom: ${d.margin}px;` + style: `margin-top: ${data.margin}px; margin-bottom: ${data.margin}px;` }; }); diff --git a/src/library/entry.cr b/src/library/entry.cr index 137b04d..3e270cf 100644 --- a/src/library/entry.cr +++ b/src/library/entry.cr @@ -117,7 +117,6 @@ class Entry sizes << { "width" => size.width, "height" => size.height, - "margin" => Config.current.page_margin, } rescue e Logger.warn "Failed to read page #{i} of entry #{zip_path}. #{e}" diff --git a/src/routes/api.cr b/src/routes/api.cr index f48451e..73d922c 100644 --- a/src/routes/api.cr +++ b/src/routes/api.cr @@ -664,6 +664,7 @@ struct APIRouter send_json env, { "success" => true, "dimensions" => sizes, + "margin" => Config.current.page_margin }.to_json rescue e send_json env, { From 60134dc36467170730d905a4ff0f882cc00e9a08 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 6 Jan 2021 17:44:02 +0100 Subject: [PATCH 4/4] Formatting --- src/routes/api.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/api.cr b/src/routes/api.cr index 73d922c..c2a45c0 100644 --- a/src/routes/api.cr +++ b/src/routes/api.cr @@ -664,7 +664,7 @@ struct APIRouter send_json env, { "success" => true, "dimensions" => sizes, - "margin" => Config.current.page_margin + "margin" => Config.current.page_margin, }.to_json rescue e send_json env, {