mobi ios workaround, improve style up recieve page
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<title>Send to Kobo/Kindle</title>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css?l"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -12,25 +12,40 @@
|
||||
<h1 class="center">Send to Kobo/Kindle</h1>
|
||||
|
||||
<div class="center">
|
||||
<div style="font-size: 1.4em;">Unique key:</div>
|
||||
<div id="key">––––</div>
|
||||
<br/>
|
||||
<button id="keygen">Generate new key</button>
|
||||
<div style="font-size: 1.3em;">Unique key:</div>
|
||||
<div id="key">
|
||||
<span id="keyoutput">––––</span>
|
||||
<button id="keygen" title="Generate new key">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M19.146 4.854l-1.489 1.489A8 8 0 1 0 12 20a8.094 8.094 0 0 0 7.371-4.886 1 1 0 1 0-1.842-.779A6.071 6.071 0 0 1 12 18a6 6 0 1 1 4.243-10.243l-1.39 1.39a.5.5 0 0 0 .354.854H19.5A.5.5 0 0 0 20 9.5V5.207a.5.5 0 0 0-.854-.353z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
<div class="center" id="downloads">
|
||||
<div style="font-size: 1.3em;"><em>Downloads</em></div>
|
||||
<br/>
|
||||
<div><a id="downloadlink"></a></div>
|
||||
<br/>
|
||||
</div>
|
||||
<hr/>
|
||||
<br/>
|
||||
<div class="center" id="downloads">
|
||||
<a id="downloadlink"></a>
|
||||
<div class="center">
|
||||
Visit this on other devices to send ebooks to this ereader:<br/><a id="siteurl">https://send.djazz.se</a><br/>
|
||||
<br/>
|
||||
Created by djazz. Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var keyOutput = document.getElementById('key')
|
||||
var keyOutput = document.getElementById('keyoutput')
|
||||
var keyGenBtn = document.getElementById('keygen')
|
||||
var downloads = document.getElementById('downloads')
|
||||
var downloadlink = document.getElementById('downloadlink')
|
||||
var siteurl = document.getElementById('siteurl')
|
||||
var key = null
|
||||
var pollTimer = null
|
||||
|
||||
@@ -97,6 +112,10 @@ window.onload = function () {
|
||||
generateKey()
|
||||
}
|
||||
|
||||
siteurl.textContent = window.location.origin
|
||||
siteurl.href = siteurl.textContent
|
||||
siteurl.target = '_self'
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
4
index.js
4
index.js
@@ -97,7 +97,7 @@ const upload = multer({
|
||||
cb(null, false)
|
||||
return
|
||||
}
|
||||
if (!allowedTypes.includes(file.mimetype) || !allowedExtensions.includes(extname(file.originalname.toLowerCase()).substr(1))) {
|
||||
if (!allowedTypes.includes(file.mimetype) || !allowedExtensions.includes(extname(file.originalname.toLowerCase()).substring(1))) {
|
||||
console.error('FileFilter: File is of an invalid type ', file)
|
||||
cb(null, false)
|
||||
return
|
||||
@@ -198,7 +198,7 @@ router.post('/upload', upload.single('file'), async ctx => {
|
||||
|
||||
const type = await FileType.fromFile(ctx.request.file.path)
|
||||
|
||||
if (!type || !allowedTypes.includes(type.mime)) {
|
||||
if ((!type || !allowedTypes.includes(type.mime)) && !allowedTypes.includes(mimetype)) {
|
||||
flash(ctx, {
|
||||
message: 'Uploaded file is of an invalid type: ' + ctx.request.file.originalname + ' (' + (type? type.mime : 'unknown mimetype') + ')',
|
||||
success: false,
|
||||
|
||||
19
style.css
19
style.css
@@ -14,14 +14,15 @@ h1 {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
#key {
|
||||
#keyoutput {
|
||||
font-size: 5em;
|
||||
display: block;
|
||||
display: inline-block;
|
||||
letter-spacing: 0.2em;
|
||||
margin: 10px 0;
|
||||
font-family: sans-serif;
|
||||
font-family: monospace, sans-serif;
|
||||
white-space: nowrap;
|
||||
text-transform: uppercase;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.center {
|
||||
text-align: center;
|
||||
@@ -39,11 +40,23 @@ h1 {
|
||||
display: inline-block;
|
||||
font-family: inherit;
|
||||
font-size: 1.2em;
|
||||
margin: 0 0.5em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#keygen {
|
||||
margin-left: 1em;
|
||||
margin-right: -4.7em;
|
||||
padding: 1em;
|
||||
}
|
||||
#keygen:focus {
|
||||
background: black;
|
||||
color: white;
|
||||
}
|
||||
#keygen svg {
|
||||
display: block;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
}
|
||||
#downloads {
|
||||
display: none;
|
||||
}
|
||||
|
||||
45
upload.html
45
upload.html
@@ -14,7 +14,7 @@
|
||||
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||
<table style="margin: 0 auto;" cellpadding=0 cellspacing=0>
|
||||
<tr><td class="right"><label for="keyinput">Unique key</label></td><td><input type="text" name="key" id="keyinput" autocomplete="off" pattern="...." placeholder="––––" required style="text-transform: uppercase;" maxlength=4/></td></tr>
|
||||
<tr><td class="right"><label for="fileinput">EPUB/MOBI file</label></td><td><input type="file" name="file" id="fileinput" accept=".epub,.mobi,.pdf,.cbz,.cbr,application/epub+zip,application/x-mobipocket-ebook,application/pdf,application/vnd.comicbook+zip,application/vnd.comicbook-rar" required /></td></tr>
|
||||
<tr><td class="right"><label for="fileinput">EPUB/MOBI file</label></td><td><input type="file" name="file" id="fileinput" accept=".txt,.epub,.mobi,.pdf,.cbz,.cbr,application/epub+zip,application/x-mobipocket-ebook,application/pdf,application/vnd.comicbook+zip,application/vnd.comicbook-rar" required /></td></tr>
|
||||
<tr><td></td><td id="fileinfo"></td></tr>
|
||||
<tr><td class="right"><label for="kepubify">Kepubify</label></td><td><input type="checkbox" name="kepubify" id="kepubify" checked /></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Upload and send" /></td></tr>
|
||||
@@ -33,6 +33,7 @@
|
||||
Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a> - <a id="siteurl">https://send.djazz.se</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function getCookies() {
|
||||
var cookieRegex = /([\w\.]+)\s*=\s*(?:"((?:\\"|[^"])*)"|(.*?))\s*(?:[;,]|$)/g
|
||||
@@ -51,12 +52,17 @@ function deleteCookie(name) {
|
||||
document.cookie = name + "= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"
|
||||
}
|
||||
|
||||
|
||||
var uploadstatus = document.getElementById('uploadstatus')
|
||||
var keyinput = document.getElementById('keyinput')
|
||||
var fileinput = document.getElementById('fileinput')
|
||||
var fileinputAccept = fileinput.accept.split(',') // cache it
|
||||
var fileinfo = document.getElementById('fileinfo')
|
||||
var siteurl = document.getElementById('siteurl')
|
||||
|
||||
|
||||
var isIOS = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
|
||||
|
||||
var flash = getCookies().flash
|
||||
deleteCookie('flash')
|
||||
|
||||
@@ -80,20 +86,53 @@ uploadstatus.addEventListener('click', function () {
|
||||
uploadstatus.className = ''
|
||||
}, 500)
|
||||
}, false)
|
||||
|
||||
function fileinputChange () {
|
||||
if (!fileinput.files[0]) {
|
||||
if (!fileinput.files[0] || fileinput.files.length === 0) {
|
||||
fileinfo.textContent = ''
|
||||
fileinput.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
if (fileinput.accept == '') {
|
||||
var filename = fileinput.files[0].name
|
||||
var type = fileinput.files[0].type
|
||||
var found = false
|
||||
for (var i = 0; i < fileinputAccept.length; i++) {
|
||||
var item = fileinputAccept[i]
|
||||
if (item.length > 1 && item[0] == '.') {
|
||||
if (filename.toLowerCase().endsWith(item.toLowerCase())) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
} else if (type == item) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
fileinfo.textContent = ''
|
||||
fileinput.value = ''
|
||||
alert("Invalid file: " + filename)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fileinfo.textContent = Math.ceil(fileinput.files[0].size / 1024) + ' kB'
|
||||
}
|
||||
fileinput.addEventListener('change', fileinputChange, false)
|
||||
fileinputChange()
|
||||
|
||||
siteurl.textContent = window.location.href
|
||||
if (isIOS) {
|
||||
// Can't accept .mobi files otherwise (iOS thinks it's an unknown type)
|
||||
fileinput.accept = ''
|
||||
}
|
||||
|
||||
siteurl.textContent = window.location.origin
|
||||
siteurl.href = siteurl.textContent
|
||||
siteurl.target = '_self'
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user