Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
b4bd7507
Commit
b4bd7507
authored
Oct 22, 2017
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://github.com/janeczku/calibre-web
parents
674baad4
9182d891
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
324 additions
and
300 deletions
+324
-300
.gitignore
.gitignore
+0
-2
Descript.ion
Descript.ion
+0
-1
archive.js
cps/static/js/archive.js
+13
-11
io.js
cps/static/js/io.js
+18
-16
epub.js
cps/static/js/reading/epub.js
+7
-2
unrar.js
cps/static/js/unrar.js
+52
-50
untar.js
cps/static/js/untar.js
+120
-121
unzip.js
cps/static/js/unzip.js
+75
-72
detail.html
cps/templates/detail.html
+2
-2
email_edit.html
cps/templates/email_edit.html
+1
-1
index.html
cps/templates/index.html
+2
-2
index.xml
cps/templates/index.xml
+1
-1
layout.html
cps/templates/layout.html
+9
-7
read.html
cps/templates/read.html
+2
-1
ub.py
cps/ub.py
+9
-3
web.py
cps/web.py
+13
-8
No files found.
.gitignore
View file @
b4bd7507
...
...
@@ -28,5 +28,3 @@ settings.yaml
gdrive_credentials
vendor
metadata.db
Descript.ion
deleted
100644 → 0
View file @
674baad4
cps zexit()
cps/static/js/archive.js
View file @
b4bd7507
...
...
@@ -8,6 +8,8 @@
* Copyright(c) 2011 Google Inc.
*/
/* global bitjs */
var
bitjs
=
bitjs
||
{};
bitjs
.
archive
=
bitjs
.
archive
||
{};
...
...
@@ -15,7 +17,7 @@ bitjs.archive = bitjs.archive || {};
// ===========================================================================
// Stolen from Closure because it's the best way to do Java-like inheritance.
bitjs
.
base
=
function
(
me
,
optMethodName
,
var
_a
rgs
)
{
bitjs
.
base
=
function
(
me
,
optMethodName
,
var
A
rgs
)
{
var
caller
=
arguments
.
callee
.
caller
;
if
(
caller
.
superClass_
)
{
// This is a constructor. Call the superclass constructor.
...
...
@@ -48,10 +50,10 @@ bitjs.archive = bitjs.archive || {};
};
bitjs
.
inherits
=
function
(
childCtor
,
parentCtor
)
{
/** @constructor */
function
tempCtor
()
{};
t
empCtor
.
prototype
=
parentCtor
.
prototype
;
function
TempCtor
()
{}
T
empCtor
.
prototype
=
parentCtor
.
prototype
;
childCtor
.
superClass_
=
parentCtor
.
prototype
;
childCtor
.
prototype
=
new
t
empCtor
();
childCtor
.
prototype
=
new
T
empCtor
();
childCtor
.
prototype
.
constructor
=
childCtor
;
};
// ===========================================================================
...
...
@@ -296,7 +298,7 @@ bitjs.archive = bitjs.archive || {};
};
this
.
worker_
.
onmessage
=
function
(
e
)
{
if
(
typeof
e
.
data
==
"string"
)
{
if
(
typeof
e
.
data
==
=
"string"
)
{
// Just log any strings the workers pump our way.
console
.
log
(
e
.
data
);
}
else
{
...
...
cps/static/js/io.js
View file @
b4bd7507
...
...
@@ -9,6 +9,8 @@
* Copyright(c) 2011 antimatter15
*/
/* global bitjs, Uint8Array */
var
bitjs
=
bitjs
||
{};
bitjs
.
io
=
bitjs
.
io
||
{};
...
...
@@ -58,16 +60,16 @@ bitjs.io = bitjs.io || {};
* @return {number} The peeked bits, as an unsigned number.
*/
bitjs
.
io
.
BitStream
.
prototype
.
peekBitsLtr
=
function
(
n
,
movePointers
)
{
if
(
n
<=
0
||
typeof
n
!=
typeof
1
)
{
if
(
n
<=
0
||
typeof
n
!=
=
typeof
1
)
{
return
0
;
}
movePointers
=
movePointers
||
false
,
bytePtr
=
this
.
bytePtr
,
bitPtr
=
this
.
bitPtr
,
result
=
0
,
bitsIn
=
0
,
bytes
=
this
.
bytes
;
var
movePointers
=
movePointers
||
false
;
var
bytePtr
=
this
.
bytePtr
;
var
bitPtr
=
this
.
bitPtr
;
var
result
=
0
;
var
bitsIn
=
0
;
var
bytes
=
this
.
bytes
;
// keep going until we have no more bits left to peek at
// TODO: Consider putting all bits from bytes we will need into a variable and then
...
...
@@ -123,11 +125,11 @@ bitjs.io = bitjs.io || {};
return
0
;
}
var
movePointers
=
movePointers
||
false
,
bytePtr
=
this
.
bytePtr
,
bitPtr
=
this
.
bitPtr
,
result
=
0
,
bytes
=
this
.
bytes
;
var
movePointers
=
movePointers
||
false
;
var
bytePtr
=
this
.
bytePtr
;
var
bitPtr
=
this
.
bitPtr
;
var
result
=
0
;
var
bytes
=
this
.
bytes
;
// keep going until we have no more bits left to peek at
// TODO: Consider putting all bits from bytes we will need into a variable and then
...
...
@@ -138,7 +140,7 @@ bitjs.io = bitjs.io || {};
if
(
bytePtr
>=
bytes
.
length
)
{
throw
"Error! Overflowed the bit stream! n="
+
n
+
", bytePtr="
+
bytePtr
+
", bytes.length="
+
bytes
.
length
+
", bitPtr="
+
bitPtr
;
return
-
1
;
//
return -1;
}
var
numBitsLeftInThisByte
=
(
8
-
bitPtr
);
...
...
@@ -207,8 +209,8 @@ bitjs.io = bitjs.io || {};
}
movePointers
=
movePointers
||
false
;
var
bytePtr
=
this
.
bytePtr
,
bitPtr
=
this
.
bitPtr
;
var
bytePtr
=
this
.
bytePtr
;
// var
bitPtr = this.bitPtr;
var
result
=
this
.
bytes
.
subarray
(
bytePtr
,
bytePtr
+
n
);
...
...
@@ -255,7 +257,7 @@ bitjs.io = bitjs.io || {};
*/
bitjs
.
io
.
ByteStream
.
prototype
.
peekNumber
=
function
(
n
)
{
// TODO: return error if n would go past the end of the stream?
if
(
n
<=
0
||
typeof
n
!==
typeof
1
){
if
(
n
<=
0
||
typeof
n
!==
typeof
1
)
{
return
-
1
;
}
...
...
cps/static/js/reading/epub.js
View file @
b4bd7507
...
...
@@ -10,8 +10,13 @@
restore
:
true
,
bookmarks
:
calibre
.
bookmark
?
[
calibre
.
bookmark
]
:
[]
});
if
(
calibre
.
useBookmarks
)
{
reader
.
on
(
"reader:bookmarked"
,
updateBookmark
.
bind
(
reader
,
"add"
));
reader
.
on
(
"reader:unbookmarked"
,
updateBookmark
.
bind
(
reader
,
"remove"
));
}
else
{
$
(
"#bookmark, #show-Bookmarks"
).
remove
();
}
/**
* @param {string} action - Add or remove bookmark
...
...
cps/static/js/unrar.js
View file @
b4bd7507
...
...
@@ -8,7 +8,7 @@
*
* http://kthoom.googlecode.com/hg/docs/unrar.html
*/
/* global bitjs */
/* global bitjs
, importScripts
*/
// This file expects to be invoked as a Worker (see onmessage below).
importScripts
(
"io.js"
);
...
...
@@ -42,23 +42,23 @@ var postProgress = function() {
// shows a byte value as its hex representation
var
nibble
=
"0123456789ABCDEF"
;
var
byteValueToHexString
=
function
(
num
)
{
return
nibble
[
num
>>
4
]
+
nibble
[
num
&
0xF
];
return
nibble
[
num
>>
4
]
+
nibble
[
num
&
0xF
];
};
var
twoByteValueToHexString
=
function
(
num
)
{
return
nibble
[(
num
>>
12
)
&
0xF
]
+
nibble
[(
num
>>
8
)
&
0xF
]
+
nibble
[(
num
>>
4
)
&
0xF
]
+
nibble
[
num
&
0xF
];
return
nibble
[(
num
>>
12
)
&
0xF
]
+
nibble
[(
num
>>
8
)
&
0xF
]
+
nibble
[(
num
>>
4
)
&
0xF
]
+
nibble
[
num
&
0xF
];
};
// Volume Types
var
MARK_HEAD
=
0x72
,
MAIN_HEAD
=
0x73
,
// MARK_HEAD = 0x72;
var
MAIN_HEAD
=
0x73
,
FILE_HEAD
=
0x74
,
COMM_HEAD
=
0x75
,
AV_HEAD
=
0x76
,
SUB_HEAD
=
0x77
,
PROTECT_HEAD
=
0x78
,
SIGN_HEAD
=
0x79
,
NEWSUB_HEAD
=
0x7a
,
//
COMM_HEAD = 0x75,
//
AV_HEAD = 0x76,
//
SUB_HEAD = 0x77,
//
PROTECT_HEAD = 0x78,
//
SIGN_HEAD = 0x79,
//
NEWSUB_HEAD = 0x7a,
ENDARC_HEAD
=
0x7b
;
// bstream is a bit stream
...
...
@@ -66,7 +66,7 @@ var RarVolumeHeader = function(bstream) {
var
headPos
=
bstream
.
bytePtr
;
// byte 1,2
info
(
"Rar Volume Header @"
+
bstream
.
bytePtr
);
info
(
"Rar Volume Header @"
+
bstream
.
bytePtr
);
this
.
crc
=
bstream
.
readBits
(
16
);
info
(
" crc="
+
this
.
crc
);
...
...
@@ -147,7 +147,7 @@ var RarVolumeHeader = function(bstream) {
this
.
HighPackSize
=
0
;
this
.
HighUnpSize
=
0
;
if
(
this
.
unpackedSize
==
0xffffffff
)
{
this
.
HighUnpSize
=
0x7fffffff
this
.
HighUnpSize
=
0x7fffffff
;
this
.
unpackedSize
=
0xffffffff
;
}
}
...
...
@@ -160,7 +160,7 @@ var RarVolumeHeader = function(bstream) {
// read in filename
this
.
filename
=
bstream
.
readBytes
(
this
.
nameSize
);
for
(
var
_i
=
0
,
_s
=
''
;
_i
<
this
.
filename
.
length
;
_i
++
)
{
for
(
var
_i
=
0
,
_s
=
""
;
_i
<
this
.
filename
.
length
;
_i
++
)
{
_s
+=
String
.
fromCharCode
(
this
.
filename
[
_i
]);
}
...
...
@@ -177,23 +177,25 @@ var RarVolumeHeader = function(bstream) {
// this is adapted straight out of arcread.cpp, Archive::ReadHeader()
for
(
var
I
=
0
;
I
<
4
;
++
I
)
{
var
rmode
=
extTimeFlags
>>
((
3
-
I
)
*
4
);
var
rmode
=
extTimeFlags
>>
((
3
-
I
)
*
4
);
if
((
rmode
&
8
)
==
0
)
continue
;
if
(
I
!=
0
)
if
(
I
!=
0
)
{
bstream
.
readBits
(
16
);
var
count
=
(
rmode
&
3
);
for
(
var
J
=
0
;
J
<
count
;
++
J
)
}
var
count
=
(
rmode
&
3
);
for
(
var
J
=
0
;
J
<
count
;
++
J
)
{
bstream
.
readBits
(
8
);
}
}
}
if
(
this
.
flags
.
LHD_COMMENT
)
{
info
(
"Found a LHD_COMMENT"
);
}
while
(
headPos
+
this
.
headSize
>
bstream
.
bytePtr
)
bstream
.
readBits
(
1
);
while
(
headPos
+
this
.
headSize
>
bstream
.
bytePtr
)
bstream
.
readBits
(
1
);
info
(
"Found FILE_HEAD with packSize="
+
this
.
packSize
+
", unpackedSize= "
+
this
.
unpackedSize
+
", hostOS="
+
this
.
hostOS
+
", unpVer="
+
this
.
unpVer
+
", method="
+
this
.
method
+
", filename="
+
this
.
filename
);
...
...
@@ -206,13 +208,13 @@ var RarVolumeHeader = function(bstream) {
}
};
var
BLOCK_LZ
=
0
,
BLOCK_PPM
=
1
;
var
BLOCK_LZ
=
0
;
//
BLOCK_PPM = 1;
var
rLDecode
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
10
,
12
,
14
,
16
,
20
,
24
,
28
,
32
,
40
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
160
,
192
,
224
],
rLBits
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
],
rDBitLengthCounts
=
[
4
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
14
,
0
,
12
],
rSDDecode
=
[
0
,
4
,
8
,
16
,
32
,
64
,
128
,
192
],
var
rLDecode
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
10
,
12
,
14
,
16
,
20
,
24
,
28
,
32
,
40
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
160
,
192
,
224
],
rLBits
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
],
rDBitLengthCounts
=
[
4
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
14
,
0
,
12
],
rSDDecode
=
[
0
,
4
,
8
,
16
,
32
,
64
,
128
,
192
],
rSDBits
=
[
2
,
2
,
3
,
4
,
5
,
6
,
6
,
6
];
var
rDDecode
=
[
0
,
1
,
2
,
3
,
4
,
6
,
8
,
12
,
16
,
24
,
32
,
...
...
@@ -232,7 +234,7 @@ var rNC = 299,
rLDC
=
17
,
rRC
=
28
,
rBC
=
20
,
rHUFF_TABLE_SIZE
=
(
rNC
+
rDC
+
rRC
+
rLDC
);
rHUFF_TABLE_SIZE
=
(
rNC
+
rDC
+
rRC
+
rLDC
);
var
UnpBlockType
=
BLOCK_LZ
;
var
UnpOldTable
=
new
Array
(
rHUFF_TABLE_SIZE
);
...
...
@@ -742,7 +744,7 @@ function unpack(v) {
rBuffer
=
new
bitjs
.
io
.
ByteBuffer
(
v
.
header
.
unpackedSize
);
info
(
"Unpacking "
+
v
.
filename
+
" RAR v"
+
Ver
);
info
(
"Unpacking "
+
v
.
filename
+
" RAR v"
+
Ver
);
switch
(
Ver
)
{
case
15
:
// rar 1.5 compression
...
...
cps/static/js/untar.js
View file @
b4bd7507
...
...
@@ -7,11 +7,10 @@
*
* TAR format: http://www.gnu.org/software/automake/manual/tar/Standard.html
*/
/* global bitjs */
// This file expects to be invoked as a Worker (see onmessage below).
importScripts
(
"io.js"
);
importScripts
(
"archive.js"
);
importScripts
(
'io.js'
);
importScripts
(
'archive.js'
);
// Progress variables.
var
currentFilename
=
""
;
...
...
@@ -42,7 +41,7 @@ var postProgress = function() {
var
readCleanString
=
function
(
bstr
,
numBytes
)
{
var
str
=
bstr
.
readString
(
numBytes
);
var
zIndex
=
str
.
indexOf
(
String
.
fromCharCode
(
0
));
return
zIndex
!=
=
-
1
?
str
.
substr
(
0
,
zIndex
)
:
str
;
return
zIndex
!
=
-
1
?
str
.
substr
(
0
,
zIndex
)
:
str
;
};
// takes a ByteStream and parses out the local file information
...
...
@@ -61,7 +60,7 @@ var TarLocalFile = function(bstream) {
this
.
linkname
=
readCleanString
(
bstream
,
100
);
this
.
maybeMagic
=
readCleanString
(
bstream
,
6
);
if
(
this
.
maybeMagic
=
==
"ustar"
)
{
if
(
this
.
maybeMagic
==
"ustar"
)
{
this
.
version
=
readCleanString
(
bstream
,
2
);
this
.
uname
=
readCleanString
(
bstream
,
32
);
this
.
gname
=
readCleanString
(
bstream
,
32
);
...
...
@@ -86,7 +85,7 @@ var TarLocalFile = function(bstream) {
info
(
" typeflag = "
+
this
.
typeflag
);
// A regular file.
if
(
this
.
typeflag
=
==
0
)
{
if
(
this
.
typeflag
==
0
)
{
info
(
" This is a regular file."
);
var
sizeInBytes
=
parseInt
(
this
.
size
);
this
.
fileData
=
new
Uint8Array
(
bstream
.
bytes
.
buffer
,
bstream
.
ptr
,
this
.
size
);
...
...
@@ -101,8 +100,8 @@ var TarLocalFile = function(bstream) {
if
(
remaining
>
0
&&
remaining
<
512
)
{
bstream
.
readBytes
(
remaining
);
}
}
else
if
(
this
.
typeflag
=
==
5
)
{
info
(
" This is a directory."
);
}
else
if
(
this
.
typeflag
==
5
)
{
info
(
" This is a directory."
)
}
};
...
...
@@ -122,7 +121,7 @@ var untar = function(arrayBuffer) {
var
localFiles
=
[];
// While we don't encounter an empty block, keep making TarLocalFiles.
while
(
bstream
.
peekNumber
(
4
)
!=
=
0
)
{
while
(
bstream
.
peekNumber
(
4
)
!
=
0
)
{
var
oneLocalFile
=
new
TarLocalFile
(
bstream
);
if
(
oneLocalFile
&&
oneLocalFile
.
isValid
)
{
localFiles
.
push
(
oneLocalFile
);
...
...
@@ -132,7 +131,7 @@ var untar = function(arrayBuffer) {
totalFilesInArchive
=
localFiles
.
length
;
// got all local files, now sort them
localFiles
.
sort
(
function
(
a
,
b
)
{
localFiles
.
sort
(
function
(
a
,
b
)
{
var
aname
=
a
.
filename
.
toLowerCase
();
var
bname
=
b
.
filename
.
toLowerCase
();
return
aname
>
bname
?
1
:
-
1
;
...
...
cps/static/js/unzip.js
View file @
b4bd7507
This diff is collapsed.
Click to expand it.
cps/templates/detail.html
View file @
b4bd7507
...
...
@@ -42,7 +42,7 @@
{% if g.user.kindle_mail and g.user.is_authenticated %}
<a
href=
"{{url_for('send_to_kindle', book_id=entry.id)}}"
id=
"sendbtn"
class=
"btn btn-primary"
role=
"button"
><span
class=
"glyphicon glyphicon-send"
></span>
{{_('Send to Kindle')}}
</a>
{% endif %}
{% if (g.user.role_download() and g.user.is_anonymous
()
) or g.user.is_authenticated %}
{% if (g.user.role_download() and g.user.is_anonymous) or g.user.is_authenticated %}
<div
class=
"btn-group"
role=
"group"
>
<button
id=
"read-in-browser"
type=
"button"
class=
"btn btn-primary dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
class=
"glyphicon glyphicon-eye-open"
></span>
{{_('Read in browser')}}
...
...
@@ -157,7 +157,7 @@
</p>
</div>
{% endif %}
{% if not g.user.is_anonymous
()
%}
{% if not g.user.is_anonymous %}
<div
class=
"custom_columns"
>
<p>
...
...
cps/templates/email_edit.html
View file @
b4bd7507
...
...
@@ -33,7 +33,7 @@
</div>
<button
type=
"submit"
name=
"submit"
value=
"submit"
class=
"btn btn-default"
>
{{_('Save settings')}}
</button>
<button
type=
"submit"
name=
"test"
value=
"test"
class=
"btn btn-default"
>
{{_('Save settings and send Test E-Mail')}}
</button>
<a
href=
"{{ url_for('admin') }}"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
<a
href=
"{{ url_for('admin') }}"
id=
"back"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
</form>
</div>
...
...
cps/templates/index.html
View file @
b4bd7507
...
...
@@ -6,7 +6,7 @@
<div
class=
"row"
>
{% for entry in random %}
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
id=
"books_rand"
>
<div
class=
"cover"
>
<a
href=
"{{ url_for('show_book', book_id=entry.id) }}"
data-toggle=
"modal"
data-target=
"#bookDetailsModal"
data-remote=
"false"
>
{% if entry.has_cover %}
...
...
@@ -42,7 +42,7 @@
<div
class=
"row"
>
{% if entries[0] %}
{% for entry in entries %}
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
>
<div
class=
"col-sm-3 col-lg-2 col-xs-6 book"
id=
"books"
>
<div
class=
"cover"
>
<a
href=
"{{ url_for('show_book', book_id=entry.id) }}"
data-toggle=
"modal"
data-target=
"#bookDetailsModal"
data-remote=
"false"
>
{% if entry.has_cover %}
...
...
cps/templates/index.xml
View file @
b4bd7507
...
...
@@ -34,7 +34,7 @@
<id>
{{url_for('feed_discover')}}
</id>
<content
type=
"text"
>
{{_('Show Random Books')}}
</content>
</entry>
{% if not current_user.is_anonymous
()
%}
{% if not current_user.is_anonymous %}
<entry>
<title>
{{_('Read Books')}}
</title>
<link
rel=
"subsection"
href=
"{{url_for('feed_read_books')}}"
type=
"application/atom+xml;profile=opds-catalog"
/>
...
...
cps/templates/layout.html
View file @
b4bd7507
...
...
@@ -34,7 +34,7 @@
</button>
<a
class=
"navbar-brand"
href=
"{{url_for('index')}}"
>
{{instance}}
</a>
</div>
{% if g.user.is_authenticated or g.user.is_anonymous
()
%}
{% if g.user.is_authenticated or g.user.is_anonymous %}
<form
class=
"navbar-form navbar-left"
role=
"search"
action=
"{{url_for('search')}}"
method=
"GET"
>
<div
class=
"form-group input-group input-group-sm"
>
<label
for=
"query"
class=
"sr-only"
>
{{_('Search')}}
</label>
...
...
@@ -46,13 +46,13 @@
</form>
{% endif %}
<div
class=
"navbar-collapse collapse"
>
{% if g.user.is_authenticated or g.user.is_anonymous
()
%}
{% if g.user.is_authenticated or g.user.is_anonymous %}
<ul
class=
"nav navbar-nav "
>
<li><a
href=
"{{url_for('advanced_search')}}"
><span
class=
"glyphicon glyphicon-search"
></span><span
class=
"hidden-sm"
>
{{_('Advanced Search')}}
</span></a></li>
</ul>
{% endif %}
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
{% if g.user.is_authenticated or g.user.is_anonymous
()
%}
{% if g.user.is_authenticated or g.user.is_anonymous %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
<li>
...
...
@@ -68,7 +68,7 @@
<li><a
id=
"top_admin"
href=
"{{url_for('admin')}}"
><span
class=
"glyphicon glyphicon-dashboard"
></span><span
class=
"hidden-sm"
>
{{_('Admin')}}
</span></a></li>
{% endif %}
<li><a
id=
"top_user"
href=
"{{url_for('profile')}}"
><span
class=
"glyphicon glyphicon-user"
></span><span
class=
"hidden-sm"
>
{{g.user.nickname}}
</span></a></li>
{% if not g.user.is_anonymous
()
%}
{% if not g.user.is_anonymous %}
<li><a
id=
"logout"
href=
"{{url_for('logout')}}"
><span
class=
"glyphicon glyphicon-log-out"
></span><span
class=
"hidden-sm"
>
{{_('Logout')}}
</span></a></li>
{% endif %}
{% endif %}
...
...
@@ -99,7 +99,7 @@
{% endfor %}
<div
class=
"container-fluid"
>
<div
class=
"row-fluid"
>
{% if g.user.is_authenticated or g.user.is_anonymous
()
%}
{% if g.user.is_authenticated or g.user.is_anonymous %}
<div
class=
"col-sm-2"
>
<nav
class=
"navigation"
>
<ul
class=
"list-unstyled"
id=
"scnd-nav"
intent
in-standard-append=
"nav.navigation"
in-mobile-after=
"#main-nav"
in-mobile-class=
"nav navbar-nav"
>
...
...
@@ -136,11 +136,13 @@
{% if g.user.show_series() %}
<li
id=
"nav_serie"
><a
href=
"{{url_for('series_list')}}"
><span
class=
"glyphicon glyphicon-bookmark"
></span>
{{_('Series')}}
</a></li>
{%endif%}
{% if g.user.show_author() %}
<li
id=
"nav_author"
><a
href=
"{{url_for('author_list')}}"
><span
class=
"glyphicon glyphicon-user"
></span>
{{_('Authors')}}
</a></li>
{%endif%}
{% if g.user.filter_language() == 'all' and g.user.show_language() %}
<li
id=
"nav_lang"
><a
href=
"{{url_for('language_overview')}}"
><span
class=
"glyphicon glyphicon-flag"
></span>
{{_('Languages')}}
</a></li>
{%endif%}
{% if g.user.is_authenticated or g.user.is_anonymous
()
%}
{% if g.user.is_authenticated or g.user.is_anonymous %}
<li
class=
"nav-head hidden-xs"
>
{{_('Public Shelves')}}
</li>
{% for shelf in g.public_shelfes %}
<li><a
href=
"{{url_for('show_shelf', shelf_id=shelf.id)}}"
><span
class=
"glyphicon glyphicon-list"
></span>
{{shelf.name}}
</a></li>
...
...
@@ -149,7 +151,7 @@
{% for shelf in g.user.shelf %}
<li><a
href=
"{{url_for('show_shelf', shelf_id=shelf.id)}}"
><span
class=
"glyphicon glyphicon-list"
></span>
{{shelf.name}}
</a></li>
{% endfor %}
{% if not g.user.is_anonymous
()
%}
{% if not g.user.is_anonymous %}
<li
id=
"nav_createshelf"
class=
"create-shelf"
><a
href=
"{{url_for('create_shelf')}}"
>
{{_('Create a Shelf')}}
</a></li>
<li
id=
"nav_about"
><a
href=
"{{url_for('stats')}}"
><span
class=
"glyphicon glyphicon-info-sign"
></span>
{{_('About')}}
</a></li>
{% endif %}
...
...
cps/templates/read.html
View file @
b4bd7507
...
...
@@ -83,7 +83,8 @@
cssPath
:
"{{ url_for('static', filename='css/') }}"
,
bookUrl
:
"{{ url_for('static', filename=bookid) }}/"
,
bookmarkUrl
:
"{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}"
,
bookmark
:
"{{ bookmark.bookmark_key if bookmark != None }}"
bookmark
:
"{{ bookmark.bookmark_key if bookmark != None }}"
,
useBookmarks
:
{{
g
.
user
.
is_authenticated
|
tojson
}}
};
</script>
<script
src=
"{{ url_for('static', filename='js/libs/jquery.min.js') }}"
></script>
...
...
cps/ub.py
View file @
b4bd7507
...
...
@@ -51,7 +51,7 @@ DEVELOPMENT = False
class
UserBase
:
@
staticmethod
@
property
def
is_authenticated
(
self
):
return
True
...
...
@@ -97,11 +97,11 @@ class UserBase:
def
role_delete_books
(
self
):
return
bool
((
self
.
role
is
not
None
)
and
(
self
.
role
&
ROLE_DELETE_BOOKS
==
ROLE_DELETE_BOOKS
))
@
classmethod
@
property
def
is_active
(
self
):
return
True
@
classmethod
@
property
def
is_anonymous
(
self
):
return
False
...
...
@@ -172,6 +172,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
settings
=
session
.
query
(
Settings
)
.
first
()
self
.
nickname
=
data
.
nickname
self
.
role
=
data
.
role
self
.
id
=
data
.
id
self
.
sidebar_view
=
data
.
sidebar_view
self
.
default_language
=
data
.
default_language
self
.
locale
=
data
.
locale
...
...
@@ -181,12 +182,17 @@ class Anonymous(AnonymousUserMixin, UserBase):
def
role_admin
(
self
):
return
False
@
property
def
is_active
(
self
):
return
False
@
property
def
is_anonymous
(
self
):
return
self
.
anon_browse
@
property
def
is_authenticated
(
self
):
return
False
# Baseclass representing Shelfs in calibre-web inapp.db
class
Shelf
(
Base
):
...
...
cps/web.py
View file @
b4bd7507
...
...
@@ -384,9 +384,12 @@ app.jinja_env.globals['url_for_other_page'] = url_for_other_page
def
login_required_if_no_ano
(
func
):
@
wraps
(
func
)
def
decorated_view
(
*
args
,
**
kwargs
):
if
config
.
config_anonbrowse
==
1
:
return
func
return
login_required
(
func
)
return
func
(
*
args
,
**
kwargs
)
return
login_required
(
func
)(
*
args
,
**
kwargs
)
return
decorated_view
def
remote_login_required
(
f
):
...
...
@@ -1311,7 +1314,7 @@ def show_book(book_id):
for
entry
in
shelfs
:
book_in_shelfs
.
append
(
entry
.
shelf
)
if
not
current_user
.
is_anonymous
()
:
if
not
current_user
.
is_anonymous
:
matching_have_read_book
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
and_
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
),
ub
.
ReadBook
.
book_id
==
book_id
))
.
all
()
have_read
=
len
(
matching_have_read_book
)
>
0
and
matching_have_read_book
[
0
]
.
is_read
...
...
@@ -1726,7 +1729,7 @@ def feed_get_cover(book_id):
def
render_read_books
(
page
,
are_read
,
as_xml
=
False
):
if
not
current_user
.
is_anonymous
()
:
if
not
current_user
.
is_anonymous
:
readBooks
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
))
.
filter
(
ub
.
ReadBook
.
is_read
==
True
)
.
all
()
readBookIds
=
[
x
.
book_id
for
x
in
readBooks
]
if
are_read
:
...
...
@@ -1799,6 +1802,8 @@ def read_book(book_id, book_format):
book_dir
=
os
.
path
.
join
(
config
.
get_main_dir
,
"cps"
,
"static"
,
str
(
book_id
))
if
not
os
.
path
.
exists
(
book_dir
):
os
.
mkdir
(
book_dir
)
bookmark
=
None
if
current_user
.
is_authenticated
:
bookmark
=
ub
.
session
.
query
(
ub
.
Bookmark
)
.
filter
(
ub
.
and_
(
ub
.
Bookmark
.
user_id
==
int
(
current_user
.
id
),
ub
.
Bookmark
.
book_id
==
book_id
,
ub
.
Bookmark
.
format
==
book_format
.
upper
()))
.
first
()
...
...
@@ -2213,7 +2218,7 @@ def delete_shelf(shelf_id):
@
app
.
route
(
"/shelf/<int:shelf_id>"
)
@
login_required_if_no_ano
def
show_shelf
(
shelf_id
):
if
current_user
.
is_anonymous
()
:
if
current_user
.
is_anonymous
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
else
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
or_
(
ub
.
and_
(
ub
.
Shelf
.
user_id
==
int
(
current_user
.
id
),
...
...
@@ -2248,7 +2253,7 @@ def order_shelf(shelf_id):
setattr
(
book
,
'order'
,
to_save
[
str
(
book
.
book_id
)])
counter
+=
1
ub
.
session
.
commit
()
if
current_user
.
is_anonymous
()
:
if
current_user
.
is_anonymous
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
else
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
or_
(
ub
.
and_
(
ub
.
Shelf
.
user_id
==
int
(
current_user
.
id
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment