mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-30 23:03:02 +00:00 
			
		
		
		
	Config Options for limiting email size, change username to e-mail adress, use kepubify
Added work on Unrar5 decompression (breaks comic reader totally)
This commit is contained in:
		| @@ -26,7 +26,7 @@ from datetime import datetime | |||||||
|  |  | ||||||
| from sqlalchemy import create_engine | from sqlalchemy import create_engine | ||||||
| from sqlalchemy import Table, Column, ForeignKey, CheckConstraint | from sqlalchemy import Table, Column, ForeignKey, CheckConstraint | ||||||
| from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float, DateTime, REAL | from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float, DateTime | ||||||
| from sqlalchemy.orm import relationship, sessionmaker, scoped_session | from sqlalchemy.orm import relationship, sessionmaker, scoped_session | ||||||
| from sqlalchemy.ext.declarative import declarative_base | from sqlalchemy.ext.declarative import declarative_base | ||||||
|  |  | ||||||
| @@ -253,8 +253,8 @@ class Books(Base): | |||||||
|     sort = Column(String(collation='NOCASE')) |     sort = Column(String(collation='NOCASE')) | ||||||
|     author_sort = Column(String(collation='NOCASE')) |     author_sort = Column(String(collation='NOCASE')) | ||||||
|     timestamp = Column(TIMESTAMP, default=datetime.utcnow) |     timestamp = Column(TIMESTAMP, default=datetime.utcnow) | ||||||
|     pubdate = Column(TIMESTAMP, default=datetime.utcnow) |     pubdate = Column(String) # , default=datetime.utcnow) | ||||||
|     series_index = Column(REAL, nullable=False, default=1.0) |     series_index = Column(String, nullable=False, default="1.0") | ||||||
|     last_modified = Column(TIMESTAMP, default=datetime.utcnow) |     last_modified = Column(TIMESTAMP, default=datetime.utcnow) | ||||||
|     path = Column(String, default="", nullable=False) |     path = Column(String, default="", nullable=False) | ||||||
|     has_cover = Column(Integer, default=0) |     has_cover = Column(Integer, default=0) | ||||||
|   | |||||||
| @@ -30,7 +30,6 @@ from uuid import uuid4 | |||||||
| from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response | from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response | ||||||
| from flask_babel import gettext as _ | from flask_babel import gettext as _ | ||||||
| from flask_login import current_user, login_required | from flask_login import current_user, login_required | ||||||
| from sqlalchemy import func |  | ||||||
|  |  | ||||||
| from . import constants, logger, isoLanguages, gdriveutils, uploader, helper | from . import constants, logger, isoLanguages, gdriveutils, uploader, helper | ||||||
| from . import config, get_locale, db, ub, worker | from . import config, get_locale, db, ub, worker | ||||||
| @@ -182,6 +181,8 @@ def delete_book(book_id, book_format): | |||||||
|                 if not result: |                 if not result: | ||||||
|                     flash(error, category="error") |                     flash(error, category="error") | ||||||
|                     return redirect(url_for('editbook.edit_book', book_id=book_id)) |                     return redirect(url_for('editbook.edit_book', book_id=book_id)) | ||||||
|  |                 if error: | ||||||
|  |                     flash(error, category="warning") | ||||||
|                 if not book_format: |                 if not book_format: | ||||||
|                     # delete book from Shelfs, Downloads, Read list |                     # delete book from Shelfs, Downloads, Read list | ||||||
|                     ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).delete() |                     ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).delete() | ||||||
| @@ -689,6 +690,15 @@ def upload(): | |||||||
|                     flash(_(u"Uploaded book probably exists in the library, consider to change before upload new: ") |                     flash(_(u"Uploaded book probably exists in the library, consider to change before upload new: ") | ||||||
|                         + Markup(render_title_template('book_exists_flash.html', entry=entry)), category="warning") |                         + Markup(render_title_template('book_exists_flash.html', entry=entry)), category="warning") | ||||||
|  |  | ||||||
|  |             # handle authors | ||||||
|  |             is_author = db.session.query(db.Authors).filter(db.Authors.name == authr).first() | ||||||
|  |             if is_author: | ||||||
|  |                 db_author = is_author | ||||||
|  |                 authr= is_author.name | ||||||
|  |             else: | ||||||
|  |                 db_author = db.Authors(authr, helper.get_sorted_author(authr), "") | ||||||
|  |                 db.session.add(db_author) | ||||||
|  |  | ||||||
|             title_dir = helper.get_valid_filename(title) |             title_dir = helper.get_valid_filename(title) | ||||||
|             author_dir = helper.get_valid_filename(authr) |             author_dir = helper.get_valid_filename(authr) | ||||||
|             filepath = os.path.join(config.config_calibre_dir, author_dir, title_dir) |             filepath = os.path.join(config.config_calibre_dir, author_dir, title_dir) | ||||||
| @@ -722,14 +732,6 @@ def upload(): | |||||||
|             else: |             else: | ||||||
|                 has_cover = 1 |                 has_cover = 1 | ||||||
|  |  | ||||||
|             # handle authors |  | ||||||
|             is_author = db.session.query(db.Authors).filter(db.Authors.name == func.binary(authr)).first() |  | ||||||
|             if is_author: |  | ||||||
|                 db_author = is_author |  | ||||||
|             else: |  | ||||||
|                 db_author = db.Authors(authr, helper.get_sorted_author(authr), "") |  | ||||||
|                 db.session.add(db_author) |  | ||||||
|  |  | ||||||
|             # handle series |             # handle series | ||||||
|             db_series = None |             db_series = None | ||||||
|             is_series = db.session.query(db.Series).filter(db.Series.name == series).first() |             is_series = db.session.query(db.Series).filter(db.Series.name == series).first() | ||||||
|   | |||||||
| @@ -315,7 +315,7 @@ def delete_book_file(book, calibrepath, book_format=None): | |||||||
|                 return True, None |                 return True, None | ||||||
|             else: |             else: | ||||||
|                 log.error("Deleting book %s failed, book path not valid: %s", book.id, book.path) |                 log.error("Deleting book %s failed, book path not valid: %s", book.id, book.path) | ||||||
|                 return False, _("Deleting book %(id)s failed, book path not valid: %(path)s", |                 return True, _("Deleting book %(id)s, book path not valid: %(path)s", | ||||||
|                                      id=book.id, |                                      id=book.id, | ||||||
|                                      path=book.path) |                                      path=book.path) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,10 +14,10 @@ | |||||||
| /* global VM_FIXEDGLOBALSIZE, VM_GLOBALMEMSIZE, MAXWINMASK, VM_GLOBALMEMADDR, MAXWINSIZE */ | /* global VM_FIXEDGLOBALSIZE, VM_GLOBALMEMSIZE, MAXWINMASK, VM_GLOBALMEMADDR, MAXWINSIZE */ | ||||||
|  |  | ||||||
| // This file expects to be invoked as a Worker (see onmessage below). | // This file expects to be invoked as a Worker (see onmessage below). | ||||||
| importScripts("../io/bitstream.js"); | /*importScripts("../io/bitstream.js"); | ||||||
| importScripts("../io/bytebuffer.js"); | importScripts("../io/bytebuffer.js"); | ||||||
| importScripts("archive.js"); | importScripts("archive.js"); | ||||||
| importScripts("rarvm.js"); | importScripts("rarvm.js");*/ | ||||||
|  |  | ||||||
| // Progress variables. | // Progress variables. | ||||||
| var currentFilename = ""; | var currentFilename = ""; | ||||||
| @@ -29,19 +29,21 @@ var totalFilesInArchive = 0; | |||||||
|  |  | ||||||
| // Helper functions. | // Helper functions. | ||||||
| var info = function(str) { | var info = function(str) { | ||||||
|     postMessage(new bitjs.archive.UnarchiveInfoEvent(str)); |     console.log(str); | ||||||
|  |     // postMessage(new bitjs.archive.UnarchiveInfoEvent(str)); | ||||||
| }; | }; | ||||||
| var err = function(str) { | var err = function(str) { | ||||||
|     postMessage(new bitjs.archive.UnarchiveErrorEvent(str)); |     console.log(str); | ||||||
|  |     // postMessage(new bitjs.archive.UnarchiveErrorEvent(str)); | ||||||
| }; | }; | ||||||
| var postProgress = function() { | var postProgress = function() { | ||||||
|     postMessage(new bitjs.archive.UnarchiveProgressEvent( |     /*postMessage(new bitjs.archive.UnarchiveProgressEvent( | ||||||
|         currentFilename, |         currentFilename, | ||||||
|         currentFileNumber, |         currentFileNumber, | ||||||
|         currentBytesUnarchivedInFile, |         currentBytesUnarchivedInFile, | ||||||
|         currentBytesUnarchived, |         currentBytesUnarchived, | ||||||
|         totalUncompressedBytesInArchive, |         totalUncompressedBytesInArchive, | ||||||
|         totalFilesInArchive)); |         totalFilesInArchive));*/ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // shows a byte value as its hex representation | // shows a byte value as its hex representation | ||||||
| @@ -1298,7 +1300,7 @@ var unrar = function(arrayBuffer) { | |||||||
|     totalUncompressedBytesInArchive = 0; |     totalUncompressedBytesInArchive = 0; | ||||||
|     totalFilesInArchive = 0; |     totalFilesInArchive = 0; | ||||||
|  |  | ||||||
|     postMessage(new bitjs.archive.UnarchiveStartEvent()); |     //postMessage(new bitjs.archive.UnarchiveStartEvent()); | ||||||
|     var bstream = new bitjs.io.BitStream(arrayBuffer, false /* rtl */); |     var bstream = new bitjs.io.BitStream(arrayBuffer, false /* rtl */); | ||||||
|  |  | ||||||
|     var header = new RarVolumeHeader(bstream); |     var header = new RarVolumeHeader(bstream); | ||||||
| @@ -1348,7 +1350,7 @@ var unrar = function(arrayBuffer) { | |||||||
|                 localfile.unrar(); |                 localfile.unrar(); | ||||||
|  |  | ||||||
|                 if (localfile.isValid) { |                 if (localfile.isValid) { | ||||||
|                     postMessage(new bitjs.archive.UnarchiveExtractEvent(localfile)); |                     // postMessage(new bitjs.archive.UnarchiveExtractEvent(localfile)); | ||||||
|                     postProgress(); |                     postProgress(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -1358,7 +1360,7 @@ var unrar = function(arrayBuffer) { | |||||||
|     } else { |     } else { | ||||||
|         err("Invalid RAR file"); |         err("Invalid RAR file"); | ||||||
|     } |     } | ||||||
|     postMessage(new bitjs.archive.UnarchiveFinishEvent()); |     // postMessage(new bitjs.archive.UnarchiveFinishEvent()); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // event.data.file has the ArrayBuffer. | // event.data.file has the ArrayBuffer. | ||||||
|   | |||||||
							
								
								
									
										1371
									
								
								cps/static/js/archive/unrar5.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1371
									
								
								cps/static/js/archive/unrar5.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -162,10 +162,15 @@ function initProgressClick() { | |||||||
| function loadFromArrayBuffer(ab) { | function loadFromArrayBuffer(ab) { | ||||||
|     var start = (new Date).getTime(); |     var start = (new Date).getTime(); | ||||||
|     var h = new Uint8Array(ab, 0, 10); |     var h = new Uint8Array(ab, 0, 10); | ||||||
|  |     unrar5(ab); | ||||||
|     var pathToBitJS = "../../static/js/archive/"; |     var pathToBitJS = "../../static/js/archive/"; | ||||||
|     var lastCompletion = 0; |     var lastCompletion = 0; | ||||||
|     if (h[0] === 0x52 && h[1] === 0x61 && h[2] === 0x72 && h[3] === 0x21) { //Rar! |     /*if (h[0] === 0x52 && h[1] === 0x61 && h[2] === 0x72 && h[3] === 0x21) { //Rar! | ||||||
|         unarchiver = new bitjs.archive.Unrarrer(ab, pathToBitJS); |         if (h[7] === 0x01) { | ||||||
|  |             unarchiver = new bitjs.archive.Unrarrer(ab, pathToBitJS); | ||||||
|  |         } else { | ||||||
|  |             unarchiver = new bitjs.archive.Unrarrer5(ab, pathToBitJS); | ||||||
|  |         } | ||||||
|     } else if (h[0] === 80 && h[1] === 75) { //PK (Zip) |     } else if (h[0] === 80 && h[1] === 75) { //PK (Zip) | ||||||
|         unarchiver = new bitjs.archive.Unzipper(ab, pathToBitJS); |         unarchiver = new bitjs.archive.Unzipper(ab, pathToBitJS); | ||||||
|     } else if (h[0] === 255 && h[1] === 216) { // JPEG |     } else if (h[0] === 255 && h[1] === 216) { // JPEG | ||||||
| @@ -229,7 +234,7 @@ function loadFromArrayBuffer(ab) { | |||||||
|         unarchiver.start(); |         unarchiver.start(); | ||||||
|     } else { |     } else { | ||||||
|         alert("Some error"); |         alert("Some error"); | ||||||
|     } |     }*/ | ||||||
| } | } | ||||||
|  |  | ||||||
| function scrollTocToActive() { | function scrollTocToActive() { | ||||||
|   | |||||||
| @@ -14,8 +14,13 @@ | |||||||
|  |  | ||||||
|   <script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script> |   <script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script> | ||||||
|   <script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script> |   <script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/io/bytestream.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/io/bytebuffer.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/io/bitstream.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/archive/archive.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/archive/rarvm.js') }}"></script> | ||||||
|  |   <script src="{{ url_for('static', filename='js/archive/unrar5.js') }}"></script> | ||||||
|   <script src="{{ url_for('static', filename='js/kthoom.js') }}"></script> |   <script src="{{ url_for('static', filename='js/kthoom.js') }}"></script> | ||||||
| 	<script src="{{ url_for('static', filename='js/archive/archive.js') }}"></script> |  | ||||||
|   <script> |   <script> | ||||||
|     var updateArrows = function() { |     var updateArrows = function() { | ||||||
|       if ($('input[name="direction"]:checked').val() === "0") { |       if ($('input[name="direction"]:checked').val() === "0") { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ozzieisaacs
					Ozzieisaacs