diff --git a/cps/book_formats.py b/cps/book_formats.py index 5ed8d29c..36212732 100644 --- a/cps/book_formats.py +++ b/cps/book_formats.py @@ -101,7 +101,7 @@ def default_meta(tmp_file_path, original_file_name, original_file_extension): def pdf_meta(tmp_file_path, original_file_name, original_file_extension): if use_pdf_meta: - pdf = PdfFileReader(open(tmp_file_path, 'rb')) + pdf = PdfFileReader(open(tmp_file_path, 'rb'), strict=False) doc_info = pdf.getDocumentInfo() else: doc_info = None diff --git a/cps/helper.py b/cps/helper.py index e4f33956..ea9e035c 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -230,7 +230,10 @@ def get_valid_filename(value, replace_whitespace=True): value = value[:128] if not value: raise ValueError("Filename cannot be empty") - return value + if sys.version_info.major == 3: + return value + else: + return value.decode('utf-8') def get_sorted_author(value): diff --git a/cps/static/js/caliBlur.js b/cps/static/js/caliBlur.js index d23c473d..b1c3ffa3 100644 --- a/cps/static/js/caliBlur.js +++ b/cps/static/js/caliBlur.js @@ -490,19 +490,19 @@ if ( $( 'body.shelf' ).length > 0 ) { .addClass( 'order-shelf-btn' ); $( '.delete-shelf-btn' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Delete Shelf', + 'title': $( '.delete-shelf-btn' ).text(), // 'Delete Shelf' 'data-placement': 'bottom' }) .addClass('delete-btn-tooltip'); $( '.edit-shelf-btn' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Edit Shelf', + 'title': $( '.edit-shelf-btn' ).text(), // 'Edit Shelf' 'data-placement': 'bottom' }) .addClass('edit-btn-tooltip'); $( '.order-shelf-btn' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Reorder Shelf', + 'title': $( '.order-shelf-btn' ).text(), //'Reorder Shelf' 'data-placement': 'bottom' }) .addClass('order-btn-tooltip'); } @@ -510,32 +510,32 @@ if ( $( 'body.shelf' ).length > 0 ) { // Rest of Tooltips $( '.home-btn > a' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Home', + 'title': $(document.body).attr('data-text'), // Home 'data-placement': 'bottom' }) .addClass('home-btn-tooltip'); $( '.plexBack > a' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Back', + 'title': $(document.body).attr('data-textback'), // Back 'data-placement': 'bottom' }) .addClass('back-btn-tooltip'); $( '#top_tasks' ).attr({ 'data-toggle': 'tooltip', - 'title': $( '#top_tasks' ).text(), //'Tasks', + 'title': $( '#top_tasks' ).text(), // 'Tasks' 'data-placement': 'bottom', 'data-viewport': '#main-nav' }) .addClass('tasks-btn-tooltip'); $( '#top_admin' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Settings', + 'title': $( '#top_admin' ).attr('data-text'), // Settings 'data-placement': 'bottom', 'data-viewport': '#main-nav' }) .addClass('admin-btn-tooltip'); $( '.profileDrop' ).attr({ - 'title': 'Account', + 'title': $( '#top_user' ).attr('data-text'), //Account 'data-placement': 'bottom', 'data-toggle-two': 'tooltip', 'data-viewport': '#main-nav' }) @@ -543,78 +543,78 @@ $( '.profileDrop' ).attr({ $( '#btn-upload' ).attr({ 'data-toggle': 'tooltip', - 'title': $( '#btn-upload' ).parent().text() , // 'Upload', + 'title': $( '#btn-upload' ).parent().text() , // 'Upload' 'data-placement': 'bottom', 'data-viewport': '#main-nav' }) .addClass('upload-btn-tooltip'); $( '#add-to-shelf' ).attr({ 'data-toggle-two': 'tooltip', - 'title': $( '#add-to-shelf' ).text() , // 'Add to Shelf', + 'title': $( '#add-to-shelf' ).text() , // 'Add to Shelf' 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('addtoshelf-btn-tooltip'); $( '#have_read_cb' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Mark As Read', + 'title': $( '#have_read_cb').attr('data-unchecked'), 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('readunread-btn-tooltip'); $( '#have_read_cb:checked' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Mark As Unread', + 'title': $( '#have_read_cb').attr('data-checked'), 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('readunread-btn-tooltip'); $( 'button#delete' ).attr({ 'data-toggle-two': 'tooltip', - 'title': $( 'button#delete' ).text(), //'Delete', + 'title': $( 'button#delete' ).text(), //'Delete' 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('delete-book-btn-tooltip'); $( '#have_read_cb' ).click(function() { if ( $( '#have_read_cb:checked' ).length > 0 ) { - $( this ).attr('data-original-title', 'Mark as Unread'); + $( this ).attr('data-original-title', $('#have_read_cb').attr('data-checked')); } else { - $( this).attr('data-original-title', 'Mark as Read'); + $( this).attr('data-original-title', $('#have_read_cb').attr('data-unchecked')); } }); $( '.btn-group[aria-label="Edit/Delete book"] a' ).attr({ 'data-toggle': 'tooltip', - 'title': $( '#edit_book' ).text(), // 'Edit', + 'title': $( '#edit_book' ).text(), // 'Edit' 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('edit-btn-tooltip'); $( '#sendbtn' ).attr({ 'data-toggle': 'tooltip', - 'title': 'Send to Kindle', + 'title': $( '#sendbtn' ).attr('data-text'), 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('send-btn-tooltip'); $( '#sendbtn2' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Send to Kindle', + 'title': $( '#sendbtn2' ).text(), // 'Send to Kindle', 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }) .addClass('send-btn-tooltip'); $( '#read-in-browser' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Read', + 'title': $( '#read-in-browser' ).text(), 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar'}) .addClass('send-btn-tooltip'); $( '#btnGroupDrop1' ).attr({ 'data-toggle-two': 'tooltip', - 'title': 'Download', + 'title': $( '#btnGroupDrop1' ).text(), 'data-placement': 'bottom', 'data-viewport': '.btn-toolbar' }); diff --git a/cps/static/js/uploadprogress.js b/cps/static/js/uploadprogress.js index b28d17f3..23c3f931 100644 --- a/cps/static/js/uploadprogress.js +++ b/cps/static/js/uploadprogress.js @@ -6,41 +6,41 @@ * Version 1.0.0 * Licensed under the MIT license. */ -(function($){ +(function($) { "use strict"; $.support.xhrFileUpload = !!(window.FileReader && window.ProgressEvent); $.support.xhrFormData = !!window.FormData; - if(!$.support.xhrFileUpload || !$.support.xhrFormData){ + if (!$.support.xhrFileUpload || !$.support.xhrFormData) { // skip decorating form return; } - var template = '
' + response_text + ''; + var responseText = xhr.responseText; + // Handle no response error + if (contentType) { + if (contentType.indexOf("text/plain") !== -1) { + responseText = "
" + responseText + ""; + } + document.write(xhr.responseText); } - document.write(xhr.responseText); } }, set_progress: function(percent){ - var txt = percent + '%'; + var txt = percent + "%"; if (percent == 100) { - txt = this.options.uploaded_msg; + txt = this.options.uploadedMsg; } - this.$modal_bar.attr('aria-valuenow', percent); - this.$modal_bar.text(txt); - this.$modal_bar.css('width', percent + '%'); + this.$modalBar.attr("aria-valuenow", percent); + this.$modalBar.text(txt); + this.$modalBar.css("width", percent + "%"); }, progress: function(/*ProgressEvent*/e){ @@ -163,24 +166,23 @@ // replace_form replaces the contents of the current form // with the form in the html argument. // We use the id of the current form to find the new form in the html - replace_form: function(html){ - var new_form; - var form_id = this.$form.attr('id'); - if(form_id !== undefined){ - new_form = $(html).find('#' + form_id); + replace_form: function(html) { + var newForm; + var formId = this.$form.attr("id"); + if(formId !== undefined){ + newForm = $(html).find("#" + formId); } else{ - new_form = $(html).find('form'); + newForm = $(html).find("form"); } - // add the filestyle again - new_form.find(':file').filestyle({buttonBefore: true}); - this.$form.html(new_form.children()); + newForm.find(":file").filestyle({buttonBefore: true}); + this.$form.html(newForm.children()); } }; $.fn.uploadprogress = function(options, value){ - return this.each(function(){ + return this.each(function() { var _options = $.extend({}, $.fn.uploadprogress.defaults, options); var file_progress = new UploadProgress(this, _options); file_progress.constructor(); @@ -189,9 +191,11 @@ $.fn.uploadprogress.defaults = { template: template, - uploaded_msg: "Upload done, processing, please wait..." + uploadedMsg: "Upload done, processing, please wait...", + modalTitle: "Uploading", + modalFooter: "Close", + modalTitleFailed: "Upload failed" //redirect_url: ... - // need to customize stuff? Add here, and change code accordingly. }; diff --git a/cps/templates/detail.html b/cps/templates/detail.html index f9e89cbb..e1c398ed 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -18,7 +18,7 @@ {% if entry.data|length %}