Merge branch 'Develop'

# Conflicts:
#	MANIFEST.in
#	README.md
#	cps/helper.py
#	cps/static/js/archive/archive.js
#	cps/translations/nl/LC_MESSAGES/messages.mo
#	cps/translations/nl/LC_MESSAGES/messages.po
#	cps/ub.py
#	cps/updater.py
#	cps/web.py
#	cps/worker.py
#	optional-requirements.txt
This commit is contained in:
Ozzieisaacs
2019-07-13 20:54:21 +02:00
parent 37736e11d5
commit 4708347c16
189 changed files with 33354 additions and 17681 deletions
+33 -28
View File
@@ -24,40 +24,45 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* ********************************************************************
* Alphanum sort() function version - case insensitive
* - Slower, but easier to modify for arrays of objects which contain
* string properties
*
*/
/* ********************************************************************
* Alphanum sort() function version - case insensitive
* - Slower, but easier to modify for arrays of objects which contain
* string properties
*
*/
/* exported alphanumCase */
function alphanumCase(a, b) {
function chunkify(t) {
var tz = new Array();
var x = 0, y = -1, n = 0, i, j;
function chunkify(t) {
var tz = new Array();
var x = 0, y = -1, n = 0, i, j;
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
var m = (i == 46 || (i >=48 && i <= 57));
if (m !== n) {
tz[++y] = "";
n = m;
}
tz[y] += j;
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
var m = (i === 46 || (i >= 48 && i <= 57));
if (m !== n) {
tz[++y] = "";
n = m;
}
tz[y] += j;
}
return tz;
}
return tz;
}
var aa = chunkify(a.filename.toLowerCase());
var bb = chunkify(b.filename.toLowerCase());
var aa = chunkify(a.filename.toLowerCase());
var bb = chunkify(b.filename.toLowerCase());
for (x = 0; aa[x] && bb[x]; x++) {
if (aa[x] !== bb[x]) {
var c = Number(aa[x]), d = Number(bb[x]);
if (c == aa[x] && d == bb[x]) {
return c - d;
} else return (aa[x] > bb[x]) ? 1 : -1;
for (var x = 0; aa[x] && bb[x]; x++) {
if (aa[x] !== bb[x]) {
var c = Number(aa[x]), d = Number(bb[x]);
if (c === aa[x] && d === bb[x]) {
return c - d;
} else {
return (aa[x] > bb[x]) ? 1 : -1;
}
}
}
}
return aa.length - bb.length;
return aa.length - bb.length;
}
// ===========================================================================
+2 -2
View File
@@ -74,8 +74,8 @@ var ZipLocalFile = function(bstream) {
this.extraField = null;
if (this.extraFieldLength > 0) {
this.extraField = bstream.readString(this.extraFieldLength);
info(" extra field=" + this.extraField);
this.extraField = bstream.readString(this.extraFieldLength);
info(" extra field=" + this.extraField);
}
// read in the compressed data
+195
View File
@@ -0,0 +1,195 @@
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
* Copyright (C) 2018 OzzieIsaacs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var direction = 0; // Descending order
var sort = 0; // Show sorted entries
$("#sort_name").click(function() {
var count = 0;
var index = 0;
var store;
// Append 2nd half of list to first half for easier processing
var cnt = $("#second").contents();
$("#list").append(cnt);
// Count no of elements
var listItems = $("#list").children(".row");
var listlength = listItems.length;
// check for each element if its Starting character matches
$(".row").each(function() {
if ( sort === 1) {
store = this.attributes["data-name"];
} else {
store = this.attributes["data-id"];
}
$(this).find("a").html(store.value);
if ($(this).css("display") !== "none") {
count++;
}
});
/*listItems.sort(function(a,b){
return $(a).children()[1].innerText.localeCompare($(b).children()[1].innerText)
});*/
// Find count of middle element
if (count > 20) {
var middle = parseInt(count / 2) + (count % 2);
// search for the middle of all visibe elements
$(".row").each(function() {
index++;
if ($(this).css("display") !== "none") {
middle--;
if (middle <= 0) {
return false;
}
}
});
// Move second half of visible elements
$("#second").append(listItems.slice(index, listlength));
}
sort = (sort + 1) % 2;
});
$("#desc").click(function() {
if (direction === 0) {
return;
}
var index = 0;
var list = $("#list");
var second = $("#second");
// var cnt = ;
list.append(second.contents());
var listItems = list.children(".row");
var reversed, elementLength, middle;
reversed = listItems.get().reverse();
elementLength = reversed.length;
// Find count of middle element
var count = $(".row:visible").length;
if (count > 20) {
middle = parseInt(count / 2) + (count % 2);
//var middle = parseInt(count / 2) + (count % 2);
// search for the middle of all visible elements
$(reversed).each(function() {
index++;
if ($(this).css("display") !== "none") {
middle--;
if (middle <= 0) {
return false;
}
}
});
list.append(reversed.slice(0, index));
second.append(reversed.slice(index, elementLength));
} else {
list.append(reversed.slice(0, elementLength));
}
direction = 0;
});
$("#asc").click(function() {
if (direction === 1) {
return;
}
var index = 0;
var list = $("#list");
var second = $("#second");
list.append(second.contents());
var listItems = list.children(".row");
var reversed = listItems.get().reverse();
var elementLength = reversed.length;
// Find count of middle element
var count = $(".row:visible").length;
if (count > 20) {
var middle = parseInt(count / 2) + (count % 2);
//var middle = parseInt(count / 2) + (count % 2);
// search for the middle of all visible elements
$(reversed).each(function() {
index++;
if ($(this).css("display") !== "none") {
middle--;
if (middle <= 0) {
return false;
}
}
});
// middle = parseInt(elementLength / 2) + (elementLength % 2);
list.append(reversed.slice(0, index));
second.append(reversed.slice(index, elementLength));
} else {
list.append(reversed.slice(0, elementLength));
}
direction = 1;
});
$("#all").click(function() {
var cnt = $("#second").contents();
$("#list").append(cnt);
// Find count of middle element
var listItems = $("#list").children(".row");
var listlength = listItems.length;
var middle = parseInt(listlength / 2) + (listlength % 2);
// go through all elements and make them visible
listItems.each(function() {
$(this).show();
});
// Move second half of all elements
if (listlength > 20) {
$("#second").append(listItems.slice(middle, listlength));
}
});
$(".char").click(function() {
var character = this.innerText;
var count = 0;
var index = 0;
// Append 2nd half of list to first half for easier processing
var cnt = $("#second").contents();
$("#list").append(cnt);
// Count no of elements
var listItems = $("#list").children(".row");
var listlength = listItems.length;
// check for each element if its Starting character matches
$(".row").each(function() {
if (this.attributes["data-id"].value.charAt(0).toUpperCase() !== character) {
$(this).hide();
} else {
$(this).show();
count++;
}
});
if (count > 20) {
// Find count of middle element
var middle = parseInt(count / 2) + (count % 2);
// search for the middle of all visibe elements
$(".row").each(function() {
index++;
if ($(this).css("display") !== "none") {
middle--;
if (middle <= 0) {
return false;
}
}
});
// Move second half of visible elements
$("#second").append(listItems.slice(index, listlength));
}
});
+1
View File
@@ -141,6 +141,7 @@ $(function () {
}
},
complete: function complete() {
ggDone = true;
showResult();
$("#show-google").trigger("change");
}
Executable → Regular
View File
+29
View File
@@ -101,6 +101,35 @@ bitjs.io = bitjs.io || {};
};
/**
* ToDo: Returns the next n bytes as a signed number and advances the stream pointer.
* @param {number} n The number of bytes to read.
* @return {number} The bytes interpreted as a signed number.
*/
bitjs.io.ByteStream.prototype.movePointer = function(n) {
this.ptr += n;
// end of buffer reached
if ((this.bytes.byteLength - this.ptr) < 0 ) {
this.ptr = this.bytes.byteLength;
}
}
/**
* ToDo: Returns the next n bytes as a signed number and advances the stream pointer.
* @param {number} n The number of bytes to read.
* @return {number} The bytes interpreted as a signed number.
*/
bitjs.io.ByteStream.prototype.moveTo = function(n) {
if ( n < 0 ) {
n = 0;
}
this.ptr = n;
// end of buffer reached
if ((this.bytes.byteLength - this.ptr) < 0 ) {
this.ptr = this.bytes.byteLength;
}
}
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true.
+1745
View File
File diff suppressed because it is too large Load Diff
+74 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+74
View File
@@ -0,0 +1,74 @@
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
* Copyright (C) 2018 OzzieIsaacs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Upon loading load the logfile for the first option (event log)
$(function() {
init(0);
});
// After change the radio option load the corresponding log file
$("#log_group input").on("change", function() {
var element = $("#log_group input[type='radio']:checked").val();
init(element);
});
// Handle reloading of the log file and display the content
function init(logType) {
var d = document.getElementById("renderer");
d.innerHTML = "loading ...";
/*var r = new XMLHttpRequest();
r.open("GET", "/ajax/log/" + logType, true);
r.responseType = "text";
r.onload = function() {
var text;
text = (r.responseText).split("\n");
$("#renderer").text("");
console.log(text.length);
for (var i = 0; i < text.length; i++) {
$("#renderer").append( "<div>" + _sanitize(text[i]) + "</div>" );
}
};
r.send();*/
$.ajax({
url: "/ajax/log/" + logType,
datatype: "text",
cache: false
})
.done( function(data) {
var text;
$("#renderer").text("");
text = (data).split("\n");
// console.log(text.length);
for (var i = 0; i < text.length; i++) {
$("#renderer").append( "<div>" + _sanitize(text[i]) + "</div>" );
}
});
}
function _sanitize(t) {
t = t
.replace(/&/g, "&amp;")
.replace(/ /g, "&nbsp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
return t;
}
+27 -2
View File
@@ -29,6 +29,23 @@ $(document).on("change", "input[type=\"checkbox\"][data-control]", function () {
});
});
// Generic control/related handler to show/hide fields based on a select' value
$(document).on("change", "select[data-control]", function() {
var $this = $(this);
var name = $this.data("control");
var showOrHide = parseInt($this.val());
// var showOrHideLast = $("#" + name + " option:last").val()
for (var i = 0; i < $(this)[0].length; i++) {
if (parseInt($(this)[0][i].value) === showOrHide) {
$("[data-related=\"" + name + "-" + i + "\"]").show();
} else {
$("[data-related=\"" + name + "-" + i + "\"]").hide();
}
}
});
$(function() {
var updateTimerID;
var updateText;
@@ -77,6 +94,13 @@ $(function() {
layoutMode : "fitRows"
});
$(".grid").isotope({
// options
itemSelector : ".grid-item",
layoutMode : "fitColumns"
});
var $loadMore = $(".load-more .row").infiniteScroll({
debug: false,
// selector for the paged navigation (it will be hidden)
@@ -181,6 +205,7 @@ $(function() {
// Init all data control handlers to default
$("input[data-control]").trigger("change");
$("select[data-control]").trigger("change");
$("#bookDetailsModal")
.on("show.bs.modal", function(e) {
@@ -205,12 +230,12 @@ $(function() {
$(window).resize(function() {
$(".discover .row").isotope("layout");
});
$(".author-expand").click(function() {
$(this).parent().find("a.author-name").slice($(this).data("authors-max")).toggle();
$(this).parent().find("span.author-hidden-divider").toggle();
$(this).html() === $(this).data("collapse-caption") ? $(this).html("(...)") : $(this).html($(this).data("collapse-caption"));
$(".discover .row").isotope("layout");
});
});
+4 -2
View File
@@ -15,18 +15,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* exported TableActions */
$(function() {
$("#domain_submit").click(function(event) {
event.preventDefault();
$("#domain_add").ajaxForm();
$(this).closest("form").submit();
$.ajax({
$.ajax ({
method:"get",
url: window.location.pathname + "/../../ajax/domainlist",
async: true,
timeout: 900,
success:function(data){
success:function(data) {
$("#domain-table").bootstrapTable("load", data);
}
});
+4 -7
View File
@@ -57,7 +57,7 @@
this.$modalBar = this.$modal.find(".progress-bar");
// Translate texts
this.$modalTitle.text(this.options.modalTitle)
this.$modalTitle.text(this.options.modalTitle);
this.$modalFooter.children("button").text(this.options.modalFooter);
this.$modal.on("hidden.bs.modal", $.proxy(this.reset, this));
@@ -113,8 +113,7 @@
if (contentType.indexOf("application/json") !== -1) {
var response = $.parseJSON(xhr.responseText);
url = response.location;
}
else{
} else {
url = this.options.redirect_url;
}
window.location.href = url;
@@ -136,12 +135,10 @@
if (contentType.indexOf("text/plain") !== -1) {
responseText = "<pre>" + responseText + "</pre>";
document.write(responseText);
}
else {
} else {
this.$modalBar.text(responseText);
}
}
else {
} else {
this.$modalBar.text(this.options.modalTitleFailed);
}
},