Commit d414bf32 authored by OzzieIsaacs's avatar OzzieIsaacs

Massadd of books to shelfs (#203, #404) from advanced search

Code cosmetics
bugfix error message on failed emails
refactored language name generation
parent 34abf95f
......@@ -390,7 +390,7 @@ function rarMakeDecodeTables(BitLength, offset, dec, size) {
for (I = 1; I < 16; ++I) {
N = 2 * (N + LenCount[I]);
M = (N << (15 - I));
if (M > 0xFFFF){
if (M > 0xFFFF) {
M = 0xFFFF;
}
DecodeLen[I] = M;
......@@ -419,6 +419,8 @@ var lastLength = 0;
function Unpack20(bstream) { //, Solid) {
var destUnpSize = rBuffer.data.length;
var oldDistPtr = 0;
var Length;
var Distance;
rarReadTables20(bstream);
while (destUnpSize > rBuffer.ptr) {
var num = rarDecodeNumber(bstream, LD);
......@@ -428,12 +430,12 @@ function Unpack20(bstream) { //, Solid) {
continue;
}
if (num > 269) {
var Length = rLDecode[num -= 270] + 3;
Length = rLDecode[num -= 270] + 3;
if ((Bits = rLBits[num]) > 0) {
Length += bstream.readBits(Bits);
}
var DistNumber = rarDecodeNumber(bstream, DD);
var Distance = rDDecode[DistNumber] + 1;
Distance = rDDecode[DistNumber] + 1;
if ((Bits = rDBits[DistNumber]) > 0) {
Distance += bstream.readBits(Bits);
}
......@@ -459,16 +461,16 @@ function Unpack20(bstream) { //, Solid) {
continue;
}
if (num < 261) {
var Distance = rOldDist[(oldDistPtr - (num - 256)) & 3];
Distance = rOldDist[(oldDistPtr - (num - 256)) & 3];
var LengthNumber = rarDecodeNumber(bstream, RD);
var Length = rLDecode[LengthNumber] +2;
Length = rLDecode[LengthNumber] + 2;
if ((Bits = rLBits[LengthNumber]) > 0) {
Length += bstream.readBits(Bits);
}
if (Distance >= 0x101) {
Length++;
if (Distance >= 0x2000) {
Length++
Length++;
if (Distance >= 0x40000) Length++;
}
}
......@@ -488,7 +490,7 @@ function Unpack20(bstream) { //, Solid) {
continue;
}
}
rarUpdateProgress()
rarUpdateProgress();
}
function rarUpdateProgress() {
......@@ -511,12 +513,15 @@ function rarReadTables20(bstream) {
var BitLength = new Array(rBC20);
var Table = new Array(rMC20 * 4);
var TableSize, N, I;
var AudioBlock = bstream.readBits(1);
if (!bstream.readBits(1))
for (var i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
bstream.readBits(1);
if (!bstream.readBits(1)) {
var i;
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
}
TableSize = rNC20 + rDC20 + rRC20;
for (var I = 0; I < rBC20; I++)
for (I = 0; I < rBC20; I++) {
BitLength[I] = bstream.readBits(4);
}
rarMakeDecodeTables(BitLength, 0, BD, rBC20);
I = 0;
while (I < TableSize) {
......@@ -524,7 +529,7 @@ function rarReadTables20(bstream) {
if (num < 16) {
Table[I] = num + UnpOldTable20[I] & 0xf;
I++;
} else if(num === 16) {
} else if (num === 16) {
N = bstream.readBits(2) + 3;
while (N-- > 0 && I < TableSize) {
Table[I] = Table[I - 1];
......@@ -544,7 +549,7 @@ function rarReadTables20(bstream) {
rarMakeDecodeTables(Table, 0, LD, rNC20);
rarMakeDecodeTables(Table, rNC20, DD, rDC20);
rarMakeDecodeTables(Table, rNC20 + rDC20, RD, rRC20);
for (var i = UnpOldTable20.length; i--;) UnpOldTable20[i] = Table[i];
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = Table[i];
}
......@@ -554,9 +559,9 @@ function Unpack29(bstream, Solid) {
var DDecode = new Array(rDC);
var DBits = new Array(rDC);
var Dist=0,BitLength=0,Slot=0;
for (var I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
var Dist = 0, BitLength = 0, Slot = 0;
var I;
for (I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
for (var J = 0; J < rDBitLengthCounts[I]; J++,Slot++,Dist+=(1<<BitLength)) {
DDecode[Slot]=Dist;
DBits[Slot]=BitLength;
......@@ -570,8 +575,8 @@ function Unpack29(bstream, Solid) {
lastDist = 0;
lastLength = 0;
for (var i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
var i;
for (i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
// read in Huffman tables
RarReadTables(bstream);
......@@ -693,7 +698,7 @@ function RarReadVMCode(bstream) {
var Length = (FirstByte & 7) + 1;
if (Length === 7) {
Length = bstream.readBits(8) + 7;
} else if(Length === 8) {
} else if (Length === 8) {
Length = bstream.readBits(16);
}
var vmCode = [];
......@@ -725,9 +730,9 @@ function RarInsertOldDist(distance) {
//this is the real function, the other one is for debugging
function rarCopyString(length, distance) {
var destPtr = rBuffer.ptr - distance;
if(destPtr < 0){
if (destPtr < 0) {
var l = rOldBuffers.length;
while(destPtr < 0){
while (destPtr < 0) {
destPtr = rOldBuffers[--l].data.length + destPtr;
}
//TODO: lets hope that it never needs to read beyond file boundaries
......@@ -864,7 +869,7 @@ var unrar = function(arrayBuffer) {
return aname > bname ? 1 : -1;
});
info(localFiles.map(function(a){return a.filename}).join(', '));
info(localFiles.map(function(a) {return a.filename}).join(', '));
for (var i = 0; i < localFiles.length; ++i) {
var localfile = localFiles[i];
......@@ -883,8 +888,7 @@ var unrar = function(arrayBuffer) {
postProgress();
}
}
else {
} else {
err("Invalid RAR file");
}
postMessage(new bitjs.archive.UnarchiveFinishEvent());
......
......@@ -9,9 +9,32 @@
<h2>{{entries|length}} {{_('Results for:')}} {{searchterm}}</h2>
{%endif%}
{% if g.user.is_authenticated %}
<!--a href="{{ url_for('read_books') }}" class="btn btn-primary">{{ _('Search result to shelf') }} </a-->
{% endif %}
{% if g.user.shelf.all() or g.public_shelfes %}
<div id="shelf-actions" class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group" aria-label="Add to shelves">
<button id="add-to-shelf" type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-list"></span> {{_('Add to shelf')}}
<span class="caret"></span>
</button>
<ul id="add-to-shelves" class="dropdown-menu" aria-labelledby="add-to-shelf">
{% for shelf in g.user.shelf %}
{% if shelf.is_public != 1 %}
<li>
<a href="{{ url_for('search_to_shelf', shelf_id=shelf.id) }}"> {{shelf.name}}</a>
</li>
{% endif %}
{% endfor %}
{% for shelf in g.public_shelfes %}
<li>
<a href="{{ url_for('search_to_shelf', shelf_id=shelf.id) }}">{{shelf.name}}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% endif %}
<div class="row">
......
......@@ -5,7 +5,7 @@
{% if g.user.is_authenticated %}
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
<div data-toggle="modal" data-target="#DeleteShelfDialog" class="btn btn-danger">{{ _('Delete this Shelf') }} </div>
<a href="{{ url_for('edit_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Edit Shelf name') }} </a>
<a href="{{ url_for('edit_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Edit Shelf') }} </a>
<a href="{{ url_for('order_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Change order') }} </a>
{% endif %}
{% endif %}
......
......@@ -1515,8 +1515,8 @@ msgid "Delete this Shelf"
msgstr "Lösche dieses Bücherregal"
#: cps/templates/shelf.html:8
msgid "Edit Shelf name"
msgstr "Bücherregal umbenennen"
msgid "Edit Shelf"
msgstr "Bücherregal editieren"
#: cps/templates/shelf.html:9 cps/templates/shelf_order.html:11
msgid "Change order"
......
......@@ -46,9 +46,8 @@ DEFAULT_PASS = "admin123"
DEFAULT_PORT = int(os.environ.get("CALIBRE_PORT", 8083))
class UserBase:
@property
def is_authenticated(self):
return True
......@@ -170,7 +169,7 @@ class User(UserBase, Base):
theme = Column(Integer, default=0)
# Class for anonymous user is derived from User base and complets overrides methods and properties for the
# Class for anonymous user is derived from User base and completly overrides methods and properties for the
# anonymous user
class Anonymous(AnonymousUserMixin, UserBase):
def __init__(self):
......@@ -204,7 +203,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
return False
# Baseclass representing Shelfs in calibre-web inapp.db
# Baseclass representing Shelfs in calibre-web in app.db
class Shelf(Base):
__tablename__ = 'shelf'
......@@ -774,5 +773,6 @@ else:
migrate_Database()
clean_database()
# Generate global Settings Object accecable from every file
# Generate global Settings Object accessible from every file
config = Config()
searched_ids = {}
This diff is collapsed.
......@@ -414,7 +414,7 @@ class WorkerThread(threading.Thread):
sys.stderr = org_stderr
except (socket.error, smtplib.SMTPRecipientsRefused, smtplib.SMTPException) as e:
self._handleError(error_message)
self._handleError(e)
return None
def _formatRuntime(self, runtime):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment