mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Dynamic HTML title
This commit is contained in:
parent
5685dd1cc5
commit
af0913df64
@ -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}"
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="X-UA-Compatible" content="IE=edge">
|
||||
<title>Mango</title>
|
||||
<title>Mango - <%= page.split("-").map(&.capitalize).join(" ") %></title>
|
||||
<meta name="description" content="Mango - Manga Server and Web Reader">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="<%= base_url %>css/uikit.css" />
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<% page = "Login" %>
|
||||
<%= render_component "head" %>
|
||||
|
||||
<body>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reader-bg">
|
||||
|
||||
<% page = "Reader" %>
|
||||
<%= render_component "head" %>
|
||||
|
||||
<body style="position:relative;">
|
||||
@ -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
|
||||
}">
|
||||
|
||||
<div @keydown.window.debounce="keyHandler($event)"></div>
|
||||
|
||||
@ -29,18 +30,18 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="{'uk-container': true, 'uk-container-small': mode === 'continuous', 'uk-container-expand': mode !== 'continuous'}">
|
||||
:class="{'uk-container': true, 'uk-container-small': mode === 'continuous', 'uk-container-expand': mode !== 'continuous'}">
|
||||
<div x-show="!loading && mode === 'continuous'" x-cloak>
|
||||
<template x-for="item in items">
|
||||
<img
|
||||
uk-img
|
||||
class="uk-align-center"
|
||||
:data-src="item.url"
|
||||
:width="item.width"
|
||||
:height="item.height"
|
||||
:id="item.id"
|
||||
:onclick="`showControl('${item.id}')`"
|
||||
/>
|
||||
uk-img
|
||||
class="uk-align-center"
|
||||
:data-src="item.url"
|
||||
:width="item.width"
|
||||
:height="item.height"
|
||||
:id="item.id"
|
||||
:onclick="`showControl('${item.id}')`"
|
||||
/>
|
||||
</template>
|
||||
<%- if next_entry_url -%>
|
||||
<button id="next-btn" class="uk-align-center uk-button uk-button-primary" @click="nextEntry('<%= next_entry_url %>')">Next Entry</button>
|
||||
@ -52,14 +53,14 @@
|
||||
<div x-cloak x-show="!loading && mode !== 'continuous'" class="uk-flex uk-flex-middle" style="height:100vh">
|
||||
|
||||
<img uk-img :class="{
|
||||
'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;
|
||||
`" />
|
||||
'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;
|
||||
`" />
|
||||
|
||||
<div style="position:absolute;z-index:1; top:0;left:0; width:30%;height:100%;" @click="flipPage(false)"></div>
|
||||
<div style="position:absolute;z-index:1; top:0;right:0; width:30%;height:100%;" @click="flipPage(true)"></div>
|
||||
@ -107,7 +108,7 @@
|
||||
|
||||
<script>
|
||||
const base_url = "<%= base_url %>";
|
||||
const page = <%= page %>;
|
||||
const page = <%= page_idx %>;
|
||||
const tid = "<%= title.id %>";
|
||||
const eid = "<%= entry.id %>";
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user