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
e160efbd
Commit
e160efbd
authored
Aug 28, 2018
by
bodybybuddha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GUI functions for ebookconvert any format feature
parent
f6ab7240
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
4 deletions
+39
-4
book_edit.html
cps/templates/book_edit.html
+18
-2
web.py
cps/web.py
+21
-2
No files found.
cps/templates/book_edit.html
View file @
e160efbd
...
@@ -124,13 +124,29 @@
...
@@ -124,13 +124,29 @@
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
{% if g.allow_upload %}
<div
role=
"group"
aria-label=
"Upload new book format"
>
<label
class=
"btn btn-default btn-file"
for=
"btn-upload-format"
>
{{ _('Upload format') }}
</label>
<div
class=
"btn-group"
role=
"group"
aria-label=
"New Book Formats"
>
<label
class=
"btn btn-primary btn-file"
for=
"btn-upload-format"
><span
class=
"glyphicon glyphicon-upload"
></span>
{{ _('Upload format') }}
</label>
<div
class=
"upload-format-input-text"
id=
"upload-format"
></div>
<div
class=
"upload-format-input-text"
id=
"upload-format"
></div>
<input
id=
"btn-upload-format"
name=
"btn-upload-format"
type=
"file"
>
<input
id=
"btn-upload-format"
name=
"btn-upload-format"
type=
"file"
>
{% if display_convertbtn and conversion_formats|length > 0 %}
<button
id=
"btnGroupConv"
type=
"button"
class=
"btn btn-primary dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
<span
class=
"glyphicon glyphicon-duplicate"
></span>
{{_('Convert to book format:')}}
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"btnGroupConv"
>
{% for format in conversion_formats %}
<li><a
href=
"{{ format }}"
>
{{format}} ({{ format }})
</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
...
...
cps/web.py
View file @
e160efbd
...
@@ -96,7 +96,6 @@ gdrive_watch_callback_token = 'target=calibreweb-watch_files'
...
@@ -96,7 +96,6 @@ gdrive_watch_callback_token = 'target=calibreweb-watch_files'
ALLOWED_EXTENSIONS
=
set
([
'txt'
,
'pdf'
,
'epub'
,
'mobi'
,
'azw'
,
'azw3'
,
'cbr'
,
'cbz'
,
'cbt'
,
'djvu'
,
'prc'
,
'doc'
,
'docx'
,
'fb2'
])
ALLOWED_EXTENSIONS
=
set
([
'txt'
,
'pdf'
,
'epub'
,
'mobi'
,
'azw'
,
'azw3'
,
'cbr'
,
'cbz'
,
'cbt'
,
'djvu'
,
'prc'
,
'doc'
,
'docx'
,
'fb2'
])
def
md5
(
fname
):
def
md5
(
fname
):
hash_md5
=
hashlib
.
md5
()
hash_md5
=
hashlib
.
md5
()
with
open
(
fname
,
"rb"
)
as
f
:
with
open
(
fname
,
"rb"
)
as
f
:
...
@@ -3072,10 +3071,30 @@ def edit_book(book_id):
...
@@ -3072,10 +3071,30 @@ def edit_book(book_id):
for
author
in
book
.
authors
:
for
author
in
book
.
authors
:
author_names
.
append
(
author
.
name
.
replace
(
'|'
,
','
))
author_names
.
append
(
author
.
name
.
replace
(
'|'
,
','
))
#Option for showing convertbook button
if
config
.
config_ebookconverter
==
2
:
display_convertbtn
=
True
else
:
display_convertbtn
=
False
app
.
logger
.
debug
(
book
)
app
.
logger
.
debug
(
book
.
data
)
#Determine what formats don't already exist
allowed_conversion_formats
=
ALLOWED_EXTENSIONS
for
file
in
book
.
data
:
try
:
allowed_conversion_formats
.
remove
(
file
.
format
.
lower
())
except
Exception
:
app
.
logger
.
debug
(
"Exception thrown:"
)
app
.
logger
.
debug
(
file
.
format
.
lower
())
app
.
logger
.
debug
(
allowed_conversion_formats
)
# Show form
# Show form
if
request
.
method
!=
'POST'
:
if
request
.
method
!=
'POST'
:
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
title
=
_
(
u"edit metadata"
),
page
=
"editbook"
)
title
=
_
(
u"edit metadata"
),
page
=
"editbook"
,
display_convertbtn
=
display_convertbtn
,
conversion_formats
=
allowed_conversion_formats
)
# Update book
# Update book
edited_books_id
=
set
()
edited_books_id
=
set
()
...
...
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