diff --git a/src/routes/reader.cr b/src/routes/reader.cr index 9685f5b..e61b9a0 100644 --- a/src/routes/reader.cr +++ b/src/routes/reader.cr @@ -10,12 +10,12 @@ struct ReaderRouter next layout "reader-error" if entry.err_msg # load progress - page = [1, entry.load_progress username].max + page_idx = [1, entry.load_progress username].max # start from page 1 if the user has finished reading the entry - page = 1 if entry.finished? username + page_idx = 1 if entry.finished? username - redirect env, "/reader/#{title.id}/#{entry.id}/#{page}" + redirect env, "/reader/#{title.id}/#{entry.id}/#{page_idx}" rescue e Logger.error e env.response.status_code = 404 @@ -30,8 +30,10 @@ struct ReaderRouter title = (Library.default.get_title env.params.url["title"]).not_nil! entry = (title.get_entry env.params.url["entry"]).not_nil! - page = env.params.url["page"].to_i - raise "" if page > entry.pages || page <= 0 + page_idx = env.params.url["page"].to_i + if page_idx > entry.pages || page_idx <= 0 + raise "Page #{page_idx} not found." + end exit_url = "#{base_url}book/#{title.id}" diff --git a/src/util/web.cr b/src/util/web.cr index a6db2e1..ee4108e 100644 --- a/src/util/web.cr +++ b/src/util/web.cr @@ -19,6 +19,7 @@ macro layout(name) rescue e message = e.to_s Logger.error message + page = "Error" render "src/views/message.html.ecr", "src/views/layout.html.ecr" end end diff --git a/src/views/components/head.html.ecr b/src/views/components/head.html.ecr index 2fe57ef..49d3032 100644 --- a/src/views/components/head.html.ecr +++ b/src/views/components/head.html.ecr @@ -1,7 +1,7 @@ - Mango + Mango - <%= page.split("-").map(&.capitalize).join(" ") %> diff --git a/src/views/login.html.ecr b/src/views/login.html.ecr index 052f118..3840a67 100644 --- a/src/views/login.html.ecr +++ b/src/views/login.html.ecr @@ -1,6 +1,7 @@ + <% page = "Login" %> <%= render_component "head" %> diff --git a/src/views/reader.html.ecr b/src/views/reader.html.ecr index 9136071..fc72e30 100644 --- a/src/views/reader.html.ecr +++ b/src/views/reader.html.ecr @@ -1,6 +1,7 @@ + <% page = "Reader" %> <%= render_component "head" %> @@ -8,14 +9,14 @@ id="root" :style="mode === 'continuous' ? '' : 'padding:0'" x-data="{ - loading: true, - mode: 'continuous', // can be 'continuous', 'height' or 'width' - msg: 'Loading the web reader. Please wait...', - alertClass: 'uk-alert-primary', - items: [], - curItem: {}, - flipAnimation: null - }"> + loading: true, + mode: 'continuous', // can be 'continuous', 'height' or 'width' + msg: 'Loading the web reader. Please wait...', + alertClass: 'uk-alert-primary', + items: [], + curItem: {}, + flipAnimation: null + }">
@@ -29,18 +30,18 @@
+ :class="{'uk-container': true, 'uk-container-small': mode === 'continuous', 'uk-container-expand': mode !== 'continuous'}">
<%- if next_entry_url -%> @@ -52,14 +53,14 @@
+ 'uk-align-center': true, + 'uk-animation-slide-left': flipAnimation === 'left', + 'uk-animation-slide-right': flipAnimation === 'right' + }" :data-src="curItem.url" :width="curItem.width" :height="curItem.height" :id="curItem.id" :onclick="`showControl('${curItem.id}')`" :style="` + width:${mode === 'width' ? '100vw' : 'auto'}; + height:${mode === 'height' ? '100vh' : 'auto'}; + margin-bottom:0; + `" />
@@ -107,7 +108,7 @@