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
cdaad2fb
Commit
cdaad2fb
authored
Aug 23, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into Develop
parents
f066926f
843279ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
345 additions
and
268 deletions
+345
-268
admin.py
cps/admin.py
+2
-0
config_sql.py
cps/config_sql.py
+1
-0
kobo.py
cps/kobo.py
+9
-10
admin.html
cps/templates/admin.html
+6
-0
config_edit.html
cps/templates/config_edit.html
+5
-1
Calibre-Web TestSummary.html
test/Calibre-Web TestSummary.html
+322
-257
No files found.
cps/admin.py
View file @
cdaad2fb
...
...
@@ -132,6 +132,7 @@ def admin():
allUser
=
ub
.
session
.
query
(
ub
.
User
)
.
all
()
email_settings
=
config
.
get_mail_settings
()
return
render_title_template
(
"admin.html"
,
allUser
=
allUser
,
email
=
email_settings
,
config
=
config
,
commit
=
commit
,
feature_support
=
feature_support
,
title
=
_
(
u"Admin page"
),
page
=
"admin"
)
...
...
@@ -637,6 +638,7 @@ def _configuration_update_helper():
_config_checkbox_int
(
to_save
,
"config_public_reg"
)
_config_checkbox_int
(
to_save
,
"config_register_email"
)
reboot_required
|=
_config_checkbox_int
(
to_save
,
"config_kobo_sync"
)
_config_int
(
to_save
,
"config_external_port"
)
_config_checkbox_int
(
to_save
,
"config_kobo_proxy"
)
_config_string
(
to_save
,
"config_upload_formats"
)
...
...
cps/config_sql.py
View file @
cdaad2fb
...
...
@@ -57,6 +57,7 @@ class _Settings(_Base):
config_calibre_dir
=
Column
(
String
)
config_port
=
Column
(
Integer
,
default
=
constants
.
DEFAULT_PORT
)
config_external_port
=
Column
(
Integer
,
default
=
constants
.
DEFAULT_PORT
)
config_certfile
=
Column
(
String
)
config_keyfile
=
Column
(
String
)
...
...
cps/kobo.py
View file @
cdaad2fb
...
...
@@ -129,7 +129,7 @@ def HandleSyncRequest():
sync_token
=
SyncToken
.
SyncToken
.
from_headers
(
request
.
headers
)
log
.
info
(
"Kobo library sync request received."
)
if
not
current_app
.
wsgi_app
.
is_proxied
:
log
.
debug
(
'Kobo: Received unproxied request, changed request port to server port'
)
log
.
debug
(
'Kobo: Received unproxied request, changed request port to
external
server port'
)
# TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header
# instead so that the device triggers another sync.
...
...
@@ -252,7 +252,7 @@ def generate_sync_response(sync_token, sync_results):
@
download_required
def
HandleMetadataRequest
(
book_uuid
):
if
not
current_app
.
wsgi_app
.
is_proxied
:
log
.
debug
(
'Kobo: Received unproxied request, changed request port to server port'
)
log
.
debug
(
'Kobo: Received unproxied request, changed request port to
external
server port'
)
log
.
info
(
"Kobo library metadata request received for book
%
s"
%
book_uuid
)
book
=
calibre_db
.
get_book_by_uuid
(
book_uuid
)
if
not
book
or
not
book
.
data
:
...
...
@@ -269,10 +269,11 @@ def get_download_url_for_book(book, book_format):
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
else
:
host
=
request
.
host
return
"{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}"
.
format
(
url_scheme
=
request
.
scheme
,
url_base
=
host
,
url_port
=
config
.
config_port
,
url_port
=
config
.
config_
external_
port
,
book_id
=
book
.
id
,
book_format
=
book_format
.
lower
()
)
...
...
@@ -924,7 +925,7 @@ def HandleInitRequest():
kobo_resources
=
NATIVE_KOBO_RESOURCES
()
if
not
current_app
.
wsgi_app
.
is_proxied
:
log
.
debug
(
'Kobo: Received unproxied request, changed request port to server port'
)
log
.
debug
(
'Kobo: Received unproxied request, changed request port to
external
server port'
)
if
':'
in
request
.
host
and
not
request
.
host
.
endswith
(
']'
):
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
else
:
...
...
@@ -932,8 +933,9 @@ def HandleInitRequest():
calibre_web_url
=
"{url_scheme}://{url_base}:{url_port}"
.
format
(
url_scheme
=
request
.
scheme
,
url_base
=
host
,
url_port
=
config
.
config_port
url_port
=
config
.
config_
external_
port
)
log
.
debug
(
'Kobo: Received unproxied request, changed request url to
%
s'
,
calibre_web_url
)
kobo_resources
[
"image_host"
]
=
calibre_web_url
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
calibre_web_url
+
url_for
(
"kobo.HandleCoverImageRequest"
,
...
...
@@ -942,16 +944,14 @@ def HandleInitRequest():
width
=
"{width}"
,
height
=
"{height}"
,
Quality
=
'{Quality}'
,
isGreyscale
=
'isGreyscale'
))
isGreyscale
=
'isGreyscale'
))
kobo_resources
[
"image_url_template"
]
=
unquote
(
calibre_web_url
+
url_for
(
"kobo.HandleCoverImageRequest"
,
auth_token
=
kobo_auth
.
get_auth_token
(),
book_uuid
=
"{ImageId}"
,
width
=
"{width}"
,
height
=
"{height}"
,
isGreyscale
=
'false'
))
isGreyscale
=
'false'
))
else
:
kobo_resources
[
"image_host"
]
=
url_for
(
"web.index"
,
_external
=
True
)
.
strip
(
"/"
)
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
url_for
(
"kobo.HandleCoverImageRequest"
,
...
...
@@ -970,7 +970,6 @@ def HandleInitRequest():
isGreyscale
=
'false'
,
_external
=
True
))
response
=
make_response
(
jsonify
({
"Resources"
:
kobo_resources
}))
response
.
headers
[
"x-kobo-apitoken"
]
=
"e30="
...
...
cps/templates/admin.html
View file @
cdaad2fb
...
...
@@ -88,6 +88,12 @@
<div
class=
"col-xs-6 col-sm-6"
>
{{_('Port')}}
</div>
<div
class=
"col-xs-6 col-sm-6"
>
{{config.config_port}}
</div>
</div>
{% if feature_support['kobo'] and config.config_port != config.config_external_port %}
<div
class=
"row"
>
<div
class=
"col-xs-6 col-sm-6"
>
{{_('External Port')}}
</div>
<div
class=
"col-xs-6 col-sm-6"
>
{{config.config_external_port}}
</div>
</div>
{% endif %}
</div>
<div
class=
"col-xs-12 col-sm-6"
>
<div
class=
"row"
>
...
...
cps/templates/config_edit.html
View file @
cdaad2fb
...
...
@@ -194,10 +194,14 @@
<label
for=
"config_kobo_sync"
>
{{_('Enable Kobo sync')}}
</label>
</div>
<div
data-related=
"kobo-settings"
>
<div
class=
"form-group"
style=
"
text-inden
t:10px;"
>
<div
class=
"form-group"
style=
"
margin-lef
t:10px;"
>
<input
type=
"checkbox"
id=
"config_kobo_proxy"
name=
"config_kobo_proxy"
{%
if
config
.
config_kobo_proxy
%}
checked
{%
endif
%}
>
<label
for=
"config_kobo_proxy"
>
{{_('Proxy unknown requests to Kobo Store')}}
</label>
</div>
<div
class=
"form-group"
style=
"margin-left:10px;"
>
<label
for=
"config_external_port"
>
{{_('Server External Port (for port forwarded API calls)')}}
</label>
<input
type=
"number"
min=
"1"
max=
"65535"
class=
"form-control"
name=
"config_external_port"
id=
"config_external_port"
value=
"{% if config.config_external_port != None %}{{ config.config_external_port }}{% endif %}"
autocomplete=
"off"
required
>
</div>
</div>
{% endif %}
{% if feature_support['goodreads'] %}
...
...
test/Calibre-Web TestSummary.html
View file @
cdaad2fb
This diff is collapsed.
Click to expand it.
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