1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 10:00:37 +00:00

Merge branch 'comic_server' into comic_server

This commit is contained in:
Andriy Zasypkin 2017-11-19 14:09:17 -05:00 committed by GitHub
commit 6ab4ff9a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 145 additions and 92 deletions

View File

@ -508,3 +508,22 @@ class Updater(threading.Thread):
logging.getLogger('cps.web').debug("Could not remove:" + item_path) logging.getLogger('cps.web').debug("Could not remove:" + item_path)
shutil.rmtree(source, ignore_errors=True) shutil.rmtree(source, ignore_errors=True)
def check_unrar(unrarLocation):
error = False
if os.path.exists(unrarLocation):
try:
p = subprocess.Popen(unrarLocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()
for lines in p.stdout.readlines():
if isinstance(lines, bytes):
lines = lines.decode('utf-8')
value=re.search('UNRAR (.*) freeware', lines)
if value:
version = value.group(1)
except Exception:
error = True
version=_(u'Excecution permissions missing')
else:
version = _(u'Unrar binary file not found')
error=True
return (error, version)

View File

@ -298,7 +298,6 @@ function loadFromArrayBuffer(ab) {
</a> \ </a> \
</li>" </li>"
); );
//}
} }
var percentage = (ab.page+1) / (ab.last+1); var percentage = (ab.page+1) / (ab.last+1);
totalImages = ab.last+1; totalImages = ab.last+1;
@ -339,10 +338,21 @@ function setImage(url) {
updateScale(true); updateScale(true);
canvas.width = innerWidth - 100; canvas.width = innerWidth - 100;
canvas.height = 200; canvas.height = 200;
x.fillStyle = "red"; x.fillStyle = "black";
x.font = "50px sans-serif"; x.textAlign="center";
x.font = "24px sans-serif";
x.strokeStyle = "black"; x.strokeStyle = "black";
x.fillText("Loading Page #" + (currentImage + 1), 100, 100); x.fillText("Loading Page #" + (currentImage + 1), innerWidth/2, 100);
} else {
if (url === "error") {
updateScale(true);
canvas.width = innerWidth - 100;
canvas.height = 200;
x.fillStyle = "black";
x.textAlign="center";
x.font = "24px sans-serif";
x.strokeStyle = "black";
x.fillText("Unable to decompress image #" + (currentImage + 1), innerWidth/2, 100);
} else { } else {
if ($("body").css("scrollHeight") / innerHeight > 1) { if ($("body").css("scrollHeight") / innerHeight > 1) {
$("body").css("overflowY", "scroll"); $("body").css("overflowY", "scroll");
@ -353,13 +363,13 @@ function setImage(url) {
canvas.width = innerWidth - 100; canvas.width = innerWidth - 100;
canvas.height = 300; canvas.height = 300;
updateScale(true); updateScale(true);
x.fillStyle = "orange"; x.fillStyle = "black";
x.font = "50px sans-serif"; x.font = "50px sans-serif";
x.strokeStyle = "black"; x.strokeStyle = "black";
x.fillText("Page #" + (currentImage + 1) + " (" + x.fillText("Page #" + (currentImage + 1) + " (" +
imageFiles[currentImage].filename + ")", 100, 100); imageFiles[currentImage].filename + ")", innerWidth/2, 100);
x.fillStyle = "red"; x.fillStyle = "black";
x.fillText("Is corrupt or not an image", 100, 200); x.fillText("Is corrupt or not an image", innerWidth/2, 200);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
if (/(html|htm)$/.test(imageFiles[currentImage].filename)) { if (/(html|htm)$/.test(imageFiles[currentImage].filename)) {
@ -416,6 +426,7 @@ function setImage(url) {
img.src = url; img.src = url;
} }
} }
}
function showPrevPage() { function showPrevPage() {
currentImage--; currentImage--;
@ -528,6 +539,12 @@ function keyHandler(evt) {
function ImageLoadCallback(event) { function ImageLoadCallback(event) {
var jso=this.response; var jso=this.response;
// Unable to decompress file, or no response from server
if (jso === null){
setImage("error");
}
else
{
if (jso.page !== jso.last) if (jso.page !== jso.last)
{ {
// var secRequest = new XMLHttpRequest(); // var secRequest = new XMLHttpRequest();
@ -542,6 +559,7 @@ function ImageLoadCallback(event) {
} }
loadFromArrayBuffer(jso); loadFromArrayBuffer(jso);
} }
}
function init(fileid) { function init(fileid) {
start = (new Date).getTime(); start = (new Date).getTime();
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();

View File

@ -42,6 +42,10 @@
<th>Kindlegen</th> <th>Kindlegen</th>
<td>{{versions['KindlegenVersion']}}</td> <td>{{versions['KindlegenVersion']}}</td>
</tr> </tr>
<tr>
<th>Unrar</th>
<td>{{versions['unrarVersion']}}</td>
</tr>
<tr> <tr>
<th>ImageMagick</th> <th>ImageMagick</th>
<td>{{versions['ImageVersion']}}</td> <td>{{versions['ImageVersion']}}</td>

View File

@ -941,11 +941,11 @@ def get_comic_book(book_id, book_format, page):
extractedfile="data:image/png;base64," + b64 extractedfile="data:image/png;base64," + b64
fileData={"name": rarNames[page],"page":page, "last":rarNames.__len__()-1, "content": extractedfile} fileData={"name": rarNames[page],"page":page, "last":rarNames.__len__()-1, "content": extractedfile}
except: except:
return ""
# rarfile not valid # rarfile not valid
# ToDo: error handling app.logger.error('Unrar binary not found unable to decompress file ' + cbr_file)
return ""
else: else:
app.logger.info('Unrar is not supported please install python rarfile extension')
# no support means return nothing # no support means return nothing
return "" return ""
if book_format == "cbz": if book_format == "cbz":
@ -1523,7 +1523,13 @@ def stats():
versions['requests'] = requests.__version__ versions['requests'] = requests.__version__
versions['pysqlite'] = db.engine.dialect.dbapi.version versions['pysqlite'] = db.engine.dialect.dbapi.version
versions['sqlite'] = db.engine.dialect.dbapi.sqlite_version versions['sqlite'] = db.engine.dialect.dbapi.sqlite_version
if rar_support:
rarVersion = helper.check_unrar(config.config_rarfile_location)
if not rarVersion[0]:
versions['unrarVersion'] = rarVersion[1]
else:
versions['unrarVersion'] = _('not installed')
app.logger.info(rarVersion[1])
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=versions, return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=versions,
categorycounter=categorys, seriecounter=series, title=_(u"Statistics")) categorycounter=categorys, seriecounter=series, title=_(u"Statistics"))
@ -2551,8 +2557,14 @@ def configuration_helper(origin):
# Rarfile Content configuration # Rarfile Content configuration
# ToDo check: location valid # ToDo check: location valid
if "config_rarfile_location" in to_save: if "config_rarfile_location" in to_save:
check = helper.check_unrar(to_save["config_rarfile_location"].strip())
if not check[0] :
content.config_rarfile_location = to_save["config_rarfile_location"].strip() content.config_rarfile_location = to_save["config_rarfile_location"].strip()
else:
flash(check[1], category="error")
return render_title_template("config_edit.html", content=config, origin=origin, gdrive=gdrive_support,
goodreads=goodreads_support, rarfile_support=rar_support,
title=_(u"Basic Configuration"))
content.config_default_role = 0 content.config_default_role = 0
if "admin_role" in to_save: if "admin_role" in to_save: