Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for selecting which Kindle/eReader to send books to #3303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions cps/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,45 +149,48 @@ def send_registration_mail(e_mail, user_name, default_password, resend=False):
return


def check_send_to_ereader_with_converter(formats):
def check_send_to_ereader_with_converter(formats, ereader_emails):
book_formats = list()
if 'MOBI' in formats and 'EPUB' not in formats:
book_formats.append({'format': 'Epub',
'convert': 1,
'text': _('Convert %(orig)s to %(format)s and send to eReader',
orig='Mobi',
format='Epub')})
if 'AZW3' in formats and 'EPUB' not in formats:
book_formats.append({'format': 'Epub',
'convert': 2,
'text': _('Convert %(orig)s to %(format)s and send to eReader',
orig='Azw3',
format='Epub')})
if 'EPUB' not in formats:
for convert_format in [('MOBI', 1), ('AZW3', 2)]:
for email in ereader_emails:
if len(ereader_emails) > 1:
msg_text = _('Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)',
orig=convert_format[0], format='Epub', eReadermail=email)
else:
msg_text = _('Convert %(orig)s to %(format)s and send to eReader',
orig=convert_format[0], format='Epub')
if convert_format[0] in formats:
book_formats.append({'format': 'Epub',
'convert': convert_format[1],
'ereader_email': email,
'text': msg_text})
return book_formats


def check_send_to_ereader(entry):
def check_send_to_ereader(entry, ereader_email_str):
"""
returns all available book formats for sending to eReader
"""
formats = list()
book_formats = list()
ereader_emails = [strip_whitespaces(x) for x in ereader_email_str.split(',')]
if len(entry.data):
for ele in iter(entry.data):
if ele.uncompressed_size < config.mail_size:
formats.append(ele.format)
if 'EPUB' in formats:
book_formats.append({'format': 'Epub',
'convert': 0,
'text': _('Send %(format)s to eReader', format='Epub')})
if 'PDF' in formats:
book_formats.append({'format': 'Pdf',
'convert': 0,
'text': _('Send %(format)s to eReader', format='Pdf')})
if 'AZW' in formats:
book_formats.append({'format': 'Azw',
'convert': 0,
'text': _('Send %(format)s to eReader', format='Azw')})
for book_format in ['EPUB', 'PDF', 'AZW']:
for ereader_email in ereader_emails:
if book_format in formats:
if len(ereader_emails) > 1:
msg_text = _('Send %(format)s to eReader (%(eReadermail)s)',
format=book_format, eReadermail=ereader_email)
else:
msg_text = _('Send %(format)s to eReader', format=book_format)
book_formats.append({'format': book_format,
'convert': 0,
'ereader_email': ereader_email,
'text': msg_text})
if config.config_converterpath:
book_formats.extend(check_send_to_ereader_with_converter(formats))
return book_formats
Expand Down
7 changes: 3 additions & 4 deletions cps/static/js/caliBlur.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if ($("body.book").length > 0) {
// If only one download type exists still put the items into a drop-drown list.
downloads = $("a[id^=btnGroupDrop]").get();
if ($(downloads).length === 1) {
$('<button id="btnGroupDrop1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-download"></span>Download :<span class="caret"></span></button><ul class="dropdown-menu leramslist aria-labelledby="btnGroupDrop1"></ul>').insertBefore(downloads[downloads.length - 1]);
$('<button id="btnGroupDrop1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-download"></span>Download<span class="caret"></span></button><ul class="dropdown-menu leramslist aria-labelledby="btnGroupDrop1"></ul>').insertBefore(downloads[downloads.length - 1]);
$(downloads).detach();
$.each(downloads, function (i, val) {
$("<li>" + downloads[i].outerHTML + "</li>").appendTo(".leramslist");
Expand Down Expand Up @@ -154,7 +154,7 @@ if ($("body.book").length > 0) {
// Move dropdown lists higher in dom, replace bootstrap toggle with own toggle.
$('ul[aria-labelledby="read-in-browser"]').insertBefore(".blur-wrapper").addClass("readinbrowser-drop");
$('ul[aria-labelledby="listen-in-browser"]').insertBefore(".blur-wrapper").addClass("readinbrowser-drop");
$('ul[aria-labelledby="send-to-kereader"]').insertBefore(".blur-wrapper").addClass("sendtoereader-drop");
$('ul[aria-labelledby="send-to-ereader"]').insertBefore(".blur-wrapper").addClass("sendtoereader-drop");
$(".leramslist").insertBefore(".blur-wrapper");
$('ul[aria-labelledby="btnGroupDrop1"]').insertBefore(".blur-wrapper").addClass("leramslist");
$("#add-to-shelves").insertBefore(".blur-wrapper");
Expand Down Expand Up @@ -592,7 +592,7 @@ $('.btn-group[aria-label="Edit/Delete book"] a').attr({

$("#sendbtn").attr({
"data-toggle": "tooltip",
"title": $("#sendbtn").attr("data-text"),
"title": $("#sendbtn").text(), // "Send to eReader"
"data-placement": "bottom",
"data-viewport": ".btn-toolbar"
})
Expand Down Expand Up @@ -712,4 +712,3 @@ $(window).on("resize", function () {
// id = setTimeout(mobileSupport, 500);
mobileSupport();
});

7 changes: 4 additions & 3 deletions cps/templates/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% if entry.email_share_list.__len__() == 1 %}
<div class="btn-group" role="group">
<button id="sendbtn" class="btn btn-primary sendbtn-form" data-href="{{url_for('web.send_to_ereader', book_id=entry.id, book_format=entry.email_share_list[0]['format'], convert=entry.email_share_list[0]['convert'])}}">
<span class="glyphicon glyphicon-send"></span> {{entry.email_share_list[0]['text']}}
<button id="sendbtn" class="btn btn-primary sendbtn-form" href="{{url_for('web.send_to_ereader', book_id=entry.id, book_format=entry.email_share_list[0]['format'], convert=entry.email_share_list[0]['convert'], ereader_email=entry.email_share_list[0]['ereader_email'])}}">
<span class="glyphicon glyphicon-send"></span>{{entry.email_share_list[0]['text']}}
<span class="caret"></span>
</button>
</div>
{% else %}
Expand All @@ -69,7 +70,7 @@
<ul class="dropdown-menu" aria-labelledby="send-to-ereader">
{% for format in entry.email_share_list %}
<li>
<a class="sendbtn-form" data-href="{{url_for('web.send_to_ereader', book_id=entry.id, book_format=format['format'], convert=format['convert'])}}">{{ format['text'] }}</a>
<a class="sendbtn-form" href="{{url_for('web.send_to_ereader', book_id=entry.id, book_format=format['format'], convert=format['convert'], ereader_email=format['ereader_email'])}}">{{ format['text'] }}</a>
</li>
{% endfor %}
</ul>
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/cs/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,22 @@ msgstr "Začínáme s Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Registrační e-mail pro uživatele: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Převést %(orig)s do %(format)s a poslat do Kindle (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Převést %(orig)s do %(format)s a poslat do Kindle"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Poslat %(format)s do Kindle (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "Poslat %(format)s do Kindle"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,22 @@ msgstr "Loslegen mit Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Registrierungs-E-Mail für Benutzer: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Konvertiere %(orig)s nach %(format)s und sende an E-Reader (%(eReadermail)s)"

#: cps/helper.py:161
#, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Konvertiere %(orig)s nach %(format)s und sende an E-Reader"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Sende %(format)s an E-Reader (%(eReadermail)s)"

#: cps/helper.py:189
#, python-format
msgid "Send %(format)s to eReader"
msgstr "Sende %(format)s an E-Reader"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/el/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,22 @@ msgstr "Ξεκινήστε με το Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "e-mail εγγραφής για χρήστη: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Μετατροπή %(orig)s σε %(format)s και αποστολή στο Kindle (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Μετατροπή %(orig)s σε %(format)s και αποστολή στο Kindle"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Αποστολή %(format)s στο Kindle (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "Αποστολή %(format)s στο Kindle"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,22 @@ msgstr "Primeros pasos con Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Correo electrónico de registro para el usuario: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Convertir %(orig)s a %(format)s y enviar al eReader"

#: cps/helper.py:161
#, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Convertir %(orig)s a %(format)s y enviar al eReader"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Enviar %(format)s al eReader (%(eReadermail)s)"

#: cps/helper.py:189
#, python-format
msgid "Send %(format)s to eReader"
msgstr "Enviar %(format)s al eReader"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/fi/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -718,12 +718,22 @@ msgstr "Aloita Calibre-Web:in käyttö"
msgid "Registration Email for user: %(name)s"
msgstr "Rekiströintisähköposti käyttäjälle: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Muunna %(orig)s muotoon %(format)s ja lähetä Kindleen (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Muunna %(orig)s muotoon %(format)s ja lähetä Kindleen"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Lähetä %(format)s Kindleen (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "Lähetä %(format)s Kindleen"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,22 @@ msgstr "Bien démarrer avec Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Courriel d’inscription pour l’utilisateur : %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Convertir de %(orig)s vers %(format)s et envoyer au Kindle (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Convertir de %(orig)s vers %(format)s et envoyer au Kindle"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Envoyer %(format)s vers le Kindle (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "Envoyer %(format)s vers le Kindle"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/gl/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -699,12 +699,22 @@ msgstr "Comeza con Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Correo electrónico de rexistro para o usuario: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Converte %(orig)s en %(format)s e envía a eReader (%(eReadermail)s)"

#: cps/helper.py:161
#, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Converte %(orig)s en %(format)s e envía a eReader"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Enviar %(format)s a eReader (%(eReadermail)s)"

#: cps/helper.py:189
#, python-format
msgid "Send %(format)s to eReader"
msgstr "Enviar %(format)s a eReader"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/hu/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,22 @@ msgstr "Kezdő lépések a Calibre-Web-bel"
msgid "Registration Email for user: %(name)s"
msgstr "Regisztrációs e-mail a következő felhasználóhoz: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "%(orig)s konvertálása %(format)s-ra és küldés Kindle-re (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "%(orig)s konvertálása %(format)s-ra és küldés Kindle-re"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "%(format)s küldése Kindle-re (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "%(format)s küldése Kindle-re"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/id/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,22 @@ msgstr "Memulai dengan Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "Email pendaftaran untuk pengguna: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Ubah %(orig)s menjadi %(format)s dan kirim ke E-Reader (%(eReadermail)s)"

#: cps/helper.py:161
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Ubah %(orig)s menjadi %(format)s dan kirim ke E-Reader"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Kirim %(format)s ke E-Reader (%(eReadermail)s)"

#: cps/helper.py:189
#, fuzzy, python-format
msgid "Send %(format)s to eReader"
msgstr "Kirim %(format)s ke E-Reader"
Expand Down
14 changes: 12 additions & 2 deletions cps/translations/it/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,22 @@ msgstr "Inizia con Calibre-Web"
msgid "Registration Email for user: %(name)s"
msgstr "E-mail di registrazione per l'utente: %(name)s"

#: cps/helper.py:157 cps/helper.py:163
#: cps/helper.py:158
#, fuzzy, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader (%(eReadermail)s)"
msgstr "Converti %(orig)s in %(format)s e invia all'eReader (%(eReadermail)s)"

#: cps/helper.py:161
#, python-format
msgid "Convert %(orig)s to %(format)s and send to eReader"
msgstr "Converti %(orig)s in %(format)s e invia all'eReader"

#: cps/helper.py:182 cps/helper.py:186 cps/helper.py:190
#: cps/helper.py:186
#, fuzzy, python-format
msgid "Send %(format)s to eReader (%(eReadermail)s)"
msgstr "Invia %(format)s all'eReader (%(eReadermail)s)"

#: cps/helper.py:189
#, python-format
msgid "Send %(format)s to eReader"
msgstr "Invia %(format)s all'eReader"
Expand Down
Loading