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
4f386c8a
Commit
4f386c8a
authored
Aug 28, 2018
by
bodybybuddha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated GUI buttons for ebook-convert feature
parent
3ec000ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
21 deletions
+54
-21
helper.py
cps/helper.py
+5
-0
edit_books.js
cps/static/js/edit_books.js
+4
-0
book_edit.html
cps/templates/book_edit.html
+31
-14
web.py
cps/web.py
+14
-7
No files found.
cps/helper.py
View file @
4f386c8a
...
@@ -135,6 +135,11 @@ def send_mail(book_id, kindle_mail, calibrepath, user_id):
...
@@ -135,6 +135,11 @@ def send_mail(book_id, kindle_mail, calibrepath, user_id):
return
_
(
u"The requested file could not be read. Maybe wrong permissions?"
)
return
_
(
u"The requested file could not be read. Maybe wrong permissions?"
)
# Convert existing book entry to new format
#def convert_book_format(book_id, calibrepath, new_book_format, user_id):
# return
def
get_valid_filename
(
value
,
replace_whitespace
=
True
):
def
get_valid_filename
(
value
,
replace_whitespace
=
True
):
"""
"""
Returns the given string converted to a string that can be used for a clean
Returns the given string converted to a string that can be used for a clean
...
...
cps/static/js/edit_books.js
View file @
4f386c8a
...
@@ -254,3 +254,7 @@ $("#btn-upload-cover").on("change", function () {
...
@@ -254,3 +254,7 @@ $("#btn-upload-cover").on("change", function () {
}
// Remove c:\fake at beginning from localhost chrome
}
// Remove c:\fake at beginning from localhost chrome
$
(
"#upload-cover"
).
html
(
filename
);
$
(
"#upload-cover"
).
html
(
filename
);
});
});
$
(
"#btn-book-convert"
).
on
(
"change"
,
function
()
{
alert
(
"woot"
);
});
cps/templates/book_edit.html
View file @
4f386c8a
{% extends "layout.html" %}
{% extends "layout.html" %}
{% block body %}
{% block body %}
{% if book %}
{% if book %}
<form
role=
"form"
action=
"{{ url_for('edit_book', book_id=book.id) }}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
class=
"col-sm-3 col-lg-3 col-xs-12"
>
<div
class=
"col-sm-3 col-lg-3 col-xs-12"
>
<div
class=
"cover"
>
<div
class=
"cover"
>
...
@@ -25,7 +25,37 @@
...
@@ -25,7 +25,37 @@
</div>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if display_convertbtn and conversion_formats|length > 0 %}
<div
class=
"text-center more-stuff"
><h4>
{{_('Convert book format:')}}
</h4>
<form
class=
"padded-bottom"
action=
"{{ url_for('convert_bookformat', book_id=book.id) }}"
method=
"post"
enctype=
"multipart/form-data"
id=
"book_convert_frm"
>
<div
class=
"form-group"
>
<div
class=
"text-left"
>
<label
class=
"control-label"
for=
"book_format_from"
>
{{_('Convert from:')}}
</label>
<select
class=
"form-control"
name=
"book_format_from"
id=
"book_format_from"
>
<option
disabled
selected
value
>
-- select an option --
</option>
{% for file in book.data %}
<option>
{{file.format}}
</option>
{% endfor %}
</select>
<label
class=
"control-label"
for=
"book_format_to"
>
{{_('Convert to:')}}
</label>
<select
class=
"form-control"
name=
"book_format_to"
id=
"book_format_to"
>
<option
disabled
selected
value
>
-- select an option --
</option>
{% for format in conversion_formats %}
<option>
{{format|upper}}
</option>
{% endfor %}
</select>
</div>
</div>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-primary"
id=
"btn-book-covert"
name=
"btn-book-covert"
>
{{_('Convert book')}}
</button>
</span>
</form>
</div>
{% endif %}
</div>
</div>
<form
role=
"form"
action=
"{{ url_for('edit_book', book_id=book.id) }}"
method=
"post"
enctype=
"multipart/form-data"
id=
"book_edit_frm"
>
<div
class=
"col-sm-9 col-xs-12"
>
<div
class=
"col-sm-9 col-xs-12"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"book_title"
>
{{_('Book Title')}}
</label>
<label
for=
"book_title"
>
{{_('Book Title')}}
</label>
...
@@ -136,19 +166,6 @@
...
@@ -136,19 +166,6 @@
<label
class=
"btn btn-primary btn-file"
for=
"btn-upload-format"
><span
class=
"glyphicon glyphicon-upload"
></span>
{{ _('Upload format') }}
</label>
<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 %}
...
...
cps/web.py
View file @
4f386c8a
...
@@ -3183,16 +3183,10 @@ def edit_book(book_id):
...
@@ -3183,16 +3183,10 @@ def edit_book(book_id):
else
:
else
:
display_convertbtn
=
False
display_convertbtn
=
False
app
.
logger
.
debug
(
book
)
app
.
logger
.
debug
(
book
.
data
)
#Determine what formats don't already exist
#Determine what formats don't already exist
allowed_conversion_formats
=
ALLOWED_EXTENSIONS
allowed_conversion_formats
=
ALLOWED_EXTENSIONS
for
file
in
book
.
data
:
for
file
in
book
.
data
:
try
:
allowed_conversion_formats
.
remove
(
file
.
format
.
lower
())
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
)
app
.
logger
.
debug
(
allowed_conversion_formats
)
...
@@ -3627,3 +3621,16 @@ def upload():
...
@@ -3627,3 +3621,16 @@ def upload():
title
=
book
.
title
,
books_shelfs
=
book_in_shelfs
,
page
=
"upload"
)
title
=
book
.
title
,
books_shelfs
=
book_in_shelfs
,
page
=
"upload"
)
return
redirect
(
url_for
(
"index"
))
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/admin/book/convert/<int:book_id>"
,
methods
=
[
'POST'
])
@
login_required_if_no_ano
@
edit_required
def
convert_bookformat
(
book_id
):
# rtn = convert_book_format(book_id, calibrepath, new_book_format, user_id)
app
.
logger
.
debug
(
'got here'
)
app
.
logger
.
debug
(
'book id:'
+
str
(
book_id
))
app
.
logger
.
debug
(
'from format:'
+
request
.
form
[
'book_format_from'
])
app
.
logger
.
debug
(
'to format:'
+
request
.
form
[
'book_format_to'
])
return
redirect
(
url_for
(
"index"
))
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