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
cbb236ba
Commit
cbb236ba
authored
Dec 01, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added visiblilty of shelfs to opds catalog (#267)
parent
aee5ca0e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
4 deletions
+67
-4
screenfull.min.js
cps/static/js/libs/screenfull.min.js
+3
-3
index.xml
cps/templates/index.xml
+14
-0
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+1
-1
web.py
cps/web.py
+49
-0
No files found.
cps/static/js/libs/screenfull.min.js
View file @
cbb236ba
/*!
* screenfull
* v1.1.0 - 2013-09-06
* https://github.com/sindresorhus/screenfull.js
* v3.3.0 - 2017-07-06
* (c) Sindre Sorhus; MIT License
*/
!
function
(
a
,
b
){
"use strict"
;
var
c
=
"undefined"
!=
typeof
Element
&&
"ALLOW_KEYBOARD_INPUT"
in
Element
,
d
=
function
(){
for
(
var
a
,
c
,
d
=
[[
"requestFullscreen"
,
"exitFullscreen"
,
"fullscreenElement"
,
"fullscreenEnabled"
,
"fullscreenchange"
,
"fullscreenerror"
],[
"webkitRequestFullscreen"
,
"webkitExitFullscreen"
,
"webkitFullscreenElement"
,
"webkitFullscreenEnabled"
,
"webkitfullscreenchange"
,
"webkitfullscreenerror"
],[
"webkitRequestFullScreen"
,
"webkitCancelFullScreen"
,
"webkitCurrentFullScreenElement"
,
"webkitCancelFullScreen"
,
"webkitfullscreenchange"
,
"webkitfullscreenerror"
],[
"mozRequestFullScreen"
,
"mozCancelFullScreen"
,
"mozFullScreenElement"
,
"mozFullScreenEnabled"
,
"mozfullscreenchange"
,
"mozfullscreenerror"
],[
"msRequestFullscreen"
,
"msExitFullscreen"
,
"msFullscreenElement"
,
"msFullscreenEnabled"
,
"MSFullscreenchange"
,
"MSFullscreenerror"
]],
e
=
0
,
f
=
d
.
length
,
g
=
{};
f
>
e
;
e
++
)
if
(
a
=
d
[
e
],
a
&&
a
[
1
]
in
b
){
for
(
e
=
0
,
c
=
a
.
length
;
c
>
e
;
e
++
)
g
[
d
[
0
][
e
]]
=
a
[
e
];
return
g
}
return
!
1
}(),
e
=
{
request
:
function
(
a
){
var
e
=
d
.
requestFullscreen
;
a
=
a
||
b
.
documentElement
,
/5
\.
1
[\.\d]
* Safari/
.
test
(
navigator
.
userAgent
)?
a
[
e
]():
a
[
e
](
c
&&
Element
.
ALLOW_KEYBOARD_INPUT
)},
exit
:
function
(){
b
[
d
.
exitFullscreen
]()},
toggle
:
function
(
a
){
this
.
isFullscreen
?
this
.
exit
():
this
.
request
(
a
)},
onchange
:
function
(){},
onerror
:
function
(){},
raw
:
d
};
return
d
?(
Object
.
defineProperties
(
e
,{
isFullscreen
:{
get
:
function
(){
return
!!
b
[
d
.
fullscreenElement
]}},
element
:{
enumerable
:
!
0
,
get
:
function
(){
return
b
[
d
.
fullscreenElement
]}},
enabled
:{
enumerable
:
!
0
,
get
:
function
(){
return
!!
b
[
d
.
fullscreenEnabled
]}}}),
b
.
addEventListener
(
d
.
fullscreenchange
,
function
(
a
){
e
.
onchange
.
call
(
e
,
a
)}),
b
.
addEventListener
(
d
.
fullscreenerror
,
function
(
a
){
e
.
onerror
.
call
(
e
,
a
)}),
a
.
screenfull
=
e
,
void
0
):(
a
.
screenfull
=!
1
,
void
0
)}(
window
,
document
);
\ No newline at end of file
!
function
(){
"use strict"
;
var
a
=
"undefined"
!=
typeof
window
&&
void
0
!==
window
.
document
?
window
.
document
:{},
b
=
"undefined"
!=
typeof
module
&&
module
.
exports
,
c
=
"undefined"
!=
typeof
Element
&&
"ALLOW_KEYBOARD_INPUT"
in
Element
,
d
=
function
(){
for
(
var
b
,
c
=
[[
"requestFullscreen"
,
"exitFullscreen"
,
"fullscreenElement"
,
"fullscreenEnabled"
,
"fullscreenchange"
,
"fullscreenerror"
],[
"webkitRequestFullscreen"
,
"webkitExitFullscreen"
,
"webkitFullscreenElement"
,
"webkitFullscreenEnabled"
,
"webkitfullscreenchange"
,
"webkitfullscreenerror"
],[
"webkitRequestFullScreen"
,
"webkitCancelFullScreen"
,
"webkitCurrentFullScreenElement"
,
"webkitCancelFullScreen"
,
"webkitfullscreenchange"
,
"webkitfullscreenerror"
],[
"mozRequestFullScreen"
,
"mozCancelFullScreen"
,
"mozFullScreenElement"
,
"mozFullScreenEnabled"
,
"mozfullscreenchange"
,
"mozfullscreenerror"
],[
"msRequestFullscreen"
,
"msExitFullscreen"
,
"msFullscreenElement"
,
"msFullscreenEnabled"
,
"MSFullscreenChange"
,
"MSFullscreenError"
]],
d
=
0
,
e
=
c
.
length
,
f
=
{};
d
<
e
;
d
++
)
if
((
b
=
c
[
d
])
&&
b
[
1
]
in
a
){
for
(
d
=
0
;
d
<
b
.
length
;
d
++
)
f
[
c
[
0
][
d
]]
=
b
[
d
];
return
f
}
return
!
1
}(),
e
=
{
change
:
d
.
fullscreenchange
,
error
:
d
.
fullscreenerror
},
f
=
{
request
:
function
(
b
){
var
e
=
d
.
requestFullscreen
;
b
=
b
||
a
.
documentElement
,
/5
\.
1
[
.
\d]
* Safari/
.
test
(
navigator
.
userAgent
)?
b
[
e
]():
b
[
e
](
c
&&
Element
.
ALLOW_KEYBOARD_INPUT
)},
exit
:
function
(){
a
[
d
.
exitFullscreen
]()},
toggle
:
function
(
a
){
this
.
isFullscreen
?
this
.
exit
():
this
.
request
(
a
)},
onchange
:
function
(
a
){
this
.
on
(
"change"
,
a
)},
onerror
:
function
(
a
){
this
.
on
(
"error"
,
a
)},
on
:
function
(
b
,
c
){
var
d
=
e
[
b
];
d
&&
a
.
addEventListener
(
d
,
c
,
!
1
)},
off
:
function
(
b
,
c
){
var
d
=
e
[
b
];
d
&&
a
.
off
(
d
,
c
,
!
1
)},
raw
:
d
};
if
(
!
d
)
return
void
(
b
?
module
.
exports
=!
1
:
window
.
screenfull
=!
1
);
Object
.
defineProperties
(
f
,{
isFullscreen
:{
get
:
function
(){
return
Boolean
(
a
[
d
.
fullscreenElement
])}},
element
:{
enumerable
:
!
0
,
get
:
function
(){
return
a
[
d
.
fullscreenElement
]}},
enabled
:{
enumerable
:
!
0
,
get
:
function
(){
return
Boolean
(
a
[
d
.
fullscreenEnabled
])}}}),
b
?
module
.
exports
=
f
:
window
.
screenfull
=
f
}();
\ No newline at end of file
cps/templates/index.xml
View file @
cbb236ba
...
...
@@ -66,4 +66,18 @@
<id>
{{url_for('feed_seriesindex')}}
</id>
<content
type=
"text"
>
{{_('Books ordered by series')}}
</content>
</entry>
<entry>
<title>
{{_('Public Shelves')}}
</title>
<link
rel=
"subsection"
href=
"{{url_for('feed_shelfindex', public="
public")}}"
type=
"application/atom+xml;profile=opds-catalog"
/>
<id>
{{url_for('feed_shelfindex', public="public")}}
</id>
<content
type=
"text"
>
{{_('Books organized in public shelfs, visible to everyone')}}
</content>
</entry>
{% if not current_user.is_anonymous %}
<entry>
<title>
{{_('Your Shelves')}}
</title>
<link
rel=
"subsection"
href=
"{{url_for('feed_shelfindex')}}"
type=
"application/atom+xml;profile=opds-catalog"
/>
<id>
{{url_for('feed_shelfindex')}}
</id>
<content
type=
"text"
>
{{_("User's own shelfs, only visible to the current user himself")}}
</content>
</entry>
{% endif %}
</feed>
cps/translations/de/LC_MESSAGES/messages.po
View file @
cbb236ba
...
...
@@ -1090,7 +1090,7 @@ msgstr "Sprachen"
#: cps/templates/layout.html:152
msgid "Public Shelves"
msgstr "Öffentiche Bücherregale"
msgstr "Öffent
l
iche Bücherregale"
#: cps/templates/layout.html:156
msgid "Your Shelves"
...
...
cps/web.py
View file @
cbb236ba
...
...
@@ -840,6 +840,55 @@ def feed_series(book_id):
return
response
@
app
.
route
(
"/opds/shelfindex/"
,
defaults
=
{
'public'
:
0
})
@
app
.
route
(
"/opds/shelfindex/<string:public>"
)
@
requires_basic_auth_if_no_ano
def
feed_shelfindex
(
public
):
off
=
request
.
args
.
get
(
"offset"
)
if
not
off
:
off
=
0
if
public
is
not
0
:
shelf
=
g
.
public_shelfes
number
=
len
(
shelf
)
else
:
shelf
=
g
.
user
.
shelf
number
=
shelf
.
count
()
pagination
=
Pagination
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
config
.
config_books_per_page
,
number
)
xml
=
render_title_template
(
'feed.xml'
,
listelements
=
shelf
,
folder
=
'feed_shelf'
,
pagination
=
pagination
)
response
=
make_response
(
xml
)
response
.
headers
[
"Content-Type"
]
=
"application/atom+xml; charset=utf-8"
return
response
@
app
.
route
(
"/opds/shelf/<int:book_id>"
)
@
requires_basic_auth_if_no_ano
def
feed_shelf
(
book_id
):
off
=
request
.
args
.
get
(
"offset"
)
if
not
off
:
off
=
0
if
current_user
.
is_anonymous
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
book_id
)
.
first
()
else
:
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
or_
(
ub
.
and_
(
ub
.
Shelf
.
user_id
==
int
(
current_user
.
id
),
ub
.
Shelf
.
id
==
book_id
),
ub
.
and_
(
ub
.
Shelf
.
is_public
==
1
,
ub
.
Shelf
.
id
==
book_id
)))
.
first
()
result
=
list
()
# user is allowed to access shelf
if
shelf
:
books_in_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
book_id
)
.
order_by
(
ub
.
BookShelf
.
order
.
asc
())
.
all
()
for
book
in
books_in_shelf
:
cur_book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book
.
book_id
)
.
first
()
result
.
append
(
cur_book
)
pagination
=
Pagination
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
config
.
config_books_per_page
,
len
(
result
))
xml
=
render_title_template
(
'feed.xml'
,
entries
=
result
,
pagination
=
pagination
)
response
=
make_response
(
xml
)
response
.
headers
[
"Content-Type"
]
=
"application/atom+xml; charset=utf-8"
return
response
def
partial
(
total_byte_len
,
part_size_limit
):
s
=
[]
for
p
in
range
(
0
,
total_byte_len
,
part_size_limit
):
...
...
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