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
e0483882
Unverified
Commit
e0483882
authored
Jul 03, 2020
by
Jef LeCompte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(api): include external port option
Signed-off-by:
Jef LeCompte
<
jeffreylec@gmail.com
>
parent
8608ff11
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
8 deletions
+16
-8
admin.py
cps/admin.py
+1
-0
config_sql.py
cps/config_sql.py
+1
-0
kobo.py
cps/kobo.py
+6
-8
admin.html
cps/templates/admin.html
+4
-0
config_edit.html
cps/templates/config_edit.html
+4
-0
No files found.
cps/admin.py
View file @
e0483882
...
@@ -623,6 +623,7 @@ def _configuration_update_helper():
...
@@ -623,6 +623,7 @@ def _configuration_update_helper():
gdriveError
=
_configuration_gdrive_helper
(
to_save
)
gdriveError
=
_configuration_gdrive_helper
(
to_save
)
reboot_required
|=
_config_int
(
to_save
,
"config_port"
)
reboot_required
|=
_config_int
(
to_save
,
"config_port"
)
reboot_required
|=
_config_int
(
to_save
,
"config_external_port"
)
reboot_required
|=
_config_string
(
to_save
,
"config_keyfile"
)
reboot_required
|=
_config_string
(
to_save
,
"config_keyfile"
)
if
config
.
config_keyfile
and
not
os
.
path
.
isfile
(
config
.
config_keyfile
):
if
config
.
config_keyfile
and
not
os
.
path
.
isfile
(
config
.
config_keyfile
):
...
...
cps/config_sql.py
View file @
e0483882
...
@@ -57,6 +57,7 @@ class _Settings(_Base):
...
@@ -57,6 +57,7 @@ class _Settings(_Base):
config_calibre_dir
=
Column
(
String
)
config_calibre_dir
=
Column
(
String
)
config_port
=
Column
(
Integer
,
default
=
constants
.
DEFAULT_PORT
)
config_port
=
Column
(
Integer
,
default
=
constants
.
DEFAULT_PORT
)
config_external_port
=
Column
(
Integer
,
default
=
constants
.
DEFAULT_PORT
)
config_certfile
=
Column
(
String
)
config_certfile
=
Column
(
String
)
config_keyfile
=
Column
(
String
)
config_keyfile
=
Column
(
String
)
...
...
cps/kobo.py
View file @
e0483882
...
@@ -267,14 +267,15 @@ def HandleMetadataRequest(book_uuid):
...
@@ -267,14 +267,15 @@ def HandleMetadataRequest(book_uuid):
def
get_download_url_for_book
(
book
,
book_format
):
def
get_download_url_for_book
(
book
,
book_format
):
if
not
current_app
.
wsgi_app
.
is_proxied
:
if
not
current_app
.
wsgi_app
.
is_proxied
:
if
':'
in
request
.
host
and
not
request
.
host
.
endswith
(
']'
)
:
if
':'
in
request
.
host
and
not
request
.
host
.
endswith
(
']'
):
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
else
:
else
:
host
=
request
.
host
host
=
request
.
host
return
"{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}"
.
format
(
return
"{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}"
.
format
(
url_scheme
=
request
.
scheme
,
url_scheme
=
request
.
scheme
,
url_base
=
host
,
url_base
=
host
,
url_port
=
config
.
config_port
,
url_port
=
config
.
config_
external_
port
,
book_id
=
book
.
id
,
book_id
=
book
.
id
,
book_format
=
book_format
.
lower
()
book_format
=
book_format
.
lower
()
)
)
...
@@ -925,7 +926,7 @@ def HandleInitRequest():
...
@@ -925,7 +926,7 @@ def HandleInitRequest():
calibre_web_url
=
"{url_scheme}://{url_base}:{url_port}"
.
format
(
calibre_web_url
=
"{url_scheme}://{url_base}:{url_port}"
.
format
(
url_scheme
=
request
.
scheme
,
url_scheme
=
request
.
scheme
,
url_base
=
host
,
url_base
=
host
,
url_port
=
config
.
config_port
url_port
=
config
.
config_
external_
port
)
)
kobo_resources
[
"image_host"
]
=
calibre_web_url
kobo_resources
[
"image_host"
]
=
calibre_web_url
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
calibre_web_url
+
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
calibre_web_url
+
...
@@ -935,16 +936,14 @@ def HandleInitRequest():
...
@@ -935,16 +936,14 @@ def HandleInitRequest():
width
=
"{width}"
,
width
=
"{width}"
,
height
=
"{height}"
,
height
=
"{height}"
,
Quality
=
'{Quality}'
,
Quality
=
'{Quality}'
,
isGreyscale
=
'isGreyscale'
isGreyscale
=
'isGreyscale'
))
))
kobo_resources
[
"image_url_template"
]
=
unquote
(
calibre_web_url
+
kobo_resources
[
"image_url_template"
]
=
unquote
(
calibre_web_url
+
url_for
(
"kobo.HandleCoverImageRequest"
,
url_for
(
"kobo.HandleCoverImageRequest"
,
auth_token
=
kobo_auth
.
get_auth_token
(),
auth_token
=
kobo_auth
.
get_auth_token
(),
book_uuid
=
"{ImageId}"
,
book_uuid
=
"{ImageId}"
,
width
=
"{width}"
,
width
=
"{width}"
,
height
=
"{height}"
,
height
=
"{height}"
,
isGreyscale
=
'false'
isGreyscale
=
'false'
))
))
else
:
else
:
kobo_resources
[
"image_host"
]
=
url_for
(
"web.index"
,
_external
=
True
)
.
strip
(
"/"
)
kobo_resources
[
"image_host"
]
=
url_for
(
"web.index"
,
_external
=
True
)
.
strip
(
"/"
)
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
url_for
(
"kobo.HandleCoverImageRequest"
,
kobo_resources
[
"image_url_quality_template"
]
=
unquote
(
url_for
(
"kobo.HandleCoverImageRequest"
,
...
@@ -963,7 +962,6 @@ def HandleInitRequest():
...
@@ -963,7 +962,6 @@ def HandleInitRequest():
isGreyscale
=
'false'
,
isGreyscale
=
'false'
,
_external
=
True
))
_external
=
True
))
response
=
make_response
(
jsonify
({
"Resources"
:
kobo_resources
}))
response
=
make_response
(
jsonify
({
"Resources"
:
kobo_resources
}))
response
.
headers
[
"x-kobo-apitoken"
]
=
"e30="
response
.
headers
[
"x-kobo-apitoken"
]
=
"e30="
...
...
cps/templates/admin.html
View file @
e0483882
...
@@ -88,6 +88,10 @@
...
@@ -88,6 +88,10 @@
<div
class=
"col-xs-6 col-sm-6"
>
{{_('Port')}}
</div>
<div
class=
"col-xs-6 col-sm-6"
>
{{_('Port')}}
</div>
<div
class=
"col-xs-6 col-sm-6"
>
{{config.config_port}}
</div>
<div
class=
"col-xs-6 col-sm-6"
>
{{config.config_port}}
</div>
</div>
</div>
<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>
</div>
</div>
<div
class=
"col-xs-12 col-sm-6"
>
<div
class=
"col-xs-12 col-sm-6"
>
<div
class=
"row"
>
<div
class=
"row"
>
...
...
cps/templates/config_edit.html
View file @
e0483882
...
@@ -90,6 +90,10 @@
...
@@ -90,6 +90,10 @@
<label
for=
"config_port"
>
{{_('Server Port')}}
</label>
<label
for=
"config_port"
>
{{_('Server Port')}}
</label>
<input
type=
"number"
min=
"1"
max=
"65535"
class=
"form-control"
name=
"config_port"
id=
"config_port"
value=
"{% if config.config_port != None %}{{ config.config_port }}{% endif %}"
autocomplete=
"off"
required
>
<input
type=
"number"
min=
"1"
max=
"65535"
class=
"form-control"
name=
"config_port"
id=
"config_port"
value=
"{% if config.config_port != None %}{{ config.config_port }}{% endif %}"
autocomplete=
"off"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"config_external_port"
>
{{_('Server External Port (for reverse proxy 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>
<label
for=
"config_certfile"
>
{{_('SSL certfile location (leave it empty for non-SSL Servers)')}}
</label>
<label
for=
"config_certfile"
>
{{_('SSL certfile location (leave it empty for non-SSL Servers)')}}
</label>
<div
class=
"form-group input-group"
>
<div
class=
"form-group input-group"
>
<input
type=
"text"
class=
"form-control"
id=
"config_certfile"
name=
"config_certfile"
value=
"{% if config.config_certfile != None %}{{ config.config_certfile }}{% endif %}"
autocomplete=
"off"
>
<input
type=
"text"
class=
"form-control"
id=
"config_certfile"
name=
"config_certfile"
value=
"{% if config.config_certfile != None %}{{ config.config_certfile }}{% endif %}"
autocomplete=
"off"
>
...
...
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