mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 04:19:59 +00:00
Updated GUI buttons for ebook-convert feature
This commit is contained in:
parent
3ec000ad85
commit
4f386c8a00
@ -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?")
|
||||
|
||||
|
||||
# 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):
|
||||
"""
|
||||
Returns the given string converted to a string that can be used for a clean
|
||||
|
@ -254,3 +254,7 @@ $("#btn-upload-cover").on("change", function () {
|
||||
} // Remove c:\fake at beginning from localhost chrome
|
||||
$("#upload-cover").html(filename);
|
||||
});
|
||||
|
||||
$("#btn-book-convert").on("change", function () {
|
||||
alert("woot");
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
{% 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="cover">
|
||||
@ -25,7 +25,37 @@
|
||||
</div>
|
||||
{% 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>
|
||||
<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="form-group">
|
||||
<label for="book_title">{{_('Book Title')}}</label>
|
||||
@ -136,19 +166,6 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
{% endif %}
|
||||
|
21
cps/web.py
21
cps/web.py
@ -3183,16 +3183,10 @@ def edit_book(book_id):
|
||||
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())
|
||||
allowed_conversion_formats.remove(file.format.lower())
|
||||
|
||||
app.logger.debug(allowed_conversion_formats)
|
||||
|
||||
@ -3627,3 +3621,16 @@ def upload():
|
||||
title=book.title, books_shelfs=book_in_shelfs, page="upload")
|
||||
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"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user