Refactored send email by make use of ajax calls instead of posting the page
Always use getPath instead of pathname
This commit is contained in:
parent
2b9f920454
commit
321db4d712
|
@ -172,10 +172,6 @@ def check_send_to_ereader(entry):
|
||||||
book_formats.append({'format': 'Epub',
|
book_formats.append({'format': 'Epub',
|
||||||
'convert': 0,
|
'convert': 0,
|
||||||
'text': _('Send %(format)s to eReader', format='Epub')})
|
'text': _('Send %(format)s to eReader', format='Epub')})
|
||||||
if 'MOBI' in formats:
|
|
||||||
book_formats.append({'format': 'Mobi',
|
|
||||||
'convert': 0,
|
|
||||||
'text': _('Send %(format)s to eReader', format='Mobi')})
|
|
||||||
if 'PDF' in formats:
|
if 'PDF' in formats:
|
||||||
book_formats.append({'format': 'Pdf',
|
book_formats.append({'format': 'Pdf',
|
||||||
'convert': 0,
|
'convert': 0,
|
||||||
|
@ -205,8 +201,8 @@ def check_read_formats(entry):
|
||||||
|
|
||||||
|
|
||||||
# Files are processed in the following order/priority:
|
# Files are processed in the following order/priority:
|
||||||
# 1: If Mobi file is existing, it's directly send to eReader email,
|
# 1: If epub file is existing, it's directly send to eReader email,
|
||||||
# 2: If Epub file is existing, it's converted and send to eReader email,
|
# 2: If mobi file is existing, it's converted and send to eReader email,
|
||||||
# 3: If Pdf file is existing, it's directly send to eReader email
|
# 3: If Pdf file is existing, it's directly send to eReader email
|
||||||
def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id):
|
def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id):
|
||||||
"""Send email with attachments"""
|
"""Send email with attachments"""
|
||||||
|
@ -214,7 +210,7 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
|
||||||
|
|
||||||
if convert == 1:
|
if convert == 1:
|
||||||
# returns None if success, otherwise errormessage
|
# returns None if success, otherwise errormessage
|
||||||
return convert_book_format(book_id, calibrepath, 'epub', book_format.lower(), user_id, ereader_mail)
|
return convert_book_format(book_id, calibrepath, 'mobi', book_format.lower(), user_id, ereader_mail)
|
||||||
if convert == 2:
|
if convert == 2:
|
||||||
# returns None if success, otherwise errormessage
|
# returns None if success, otherwise errormessage
|
||||||
return convert_book_format(book_id, calibrepath, 'azw3', book_format.lower(), user_id, ereader_mail)
|
return convert_book_format(book_id, calibrepath, 'azw3', book_format.lower(), user_id, ereader_mail)
|
||||||
|
|
|
@ -314,9 +314,6 @@ $(document).mouseup(function (e) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Split path name to array and remove blanks
|
|
||||||
url = window.location.pathname
|
|
||||||
|
|
||||||
// Move create shelf
|
// Move create shelf
|
||||||
$("#nav_createshelf").prependTo(".your-shelves");
|
$("#nav_createshelf").prependTo(".your-shelves");
|
||||||
|
|
||||||
|
@ -360,31 +357,6 @@ $(document).on("click", ".dropdown-toggle", function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fade out content on page unload
|
|
||||||
// delegate all clicks on "a" tag (links)
|
|
||||||
/*$(document).on("click", "a:not(.btn-toolbar a, a[href*='shelf/remove'], .identifiers a, .bookinfo , .btn-group > a, #add-to-shelves a, #book-list a, .stat.blur a )", function () {
|
|
||||||
|
|
||||||
// get the href attribute
|
|
||||||
var newUrl = $(this).attr("href");
|
|
||||||
|
|
||||||
// veryfy if the new url exists or is a hash
|
|
||||||
if (!newUrl || newUrl[0] === "#") {
|
|
||||||
// set that hash
|
|
||||||
location.hash = newUrl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
now, fadeout the html (whole page)
|
|
||||||
$( '.blur-wrapper' ).fadeOut(250);
|
|
||||||
$(".row-fluid .col-sm-10").fadeOut(500,function () {
|
|
||||||
// when the animation is complete, set the new location
|
|
||||||
location = newUrl;
|
|
||||||
});
|
|
||||||
|
|
||||||
// prevent the default browser behavior.
|
|
||||||
return false;
|
|
||||||
});*/
|
|
||||||
|
|
||||||
// Collapse long text into read-more
|
// Collapse long text into read-more
|
||||||
$("div.comments").readmore({
|
$("div.comments").readmore({
|
||||||
collapsedHeight: 134,
|
collapsedHeight: 134,
|
||||||
|
@ -447,6 +419,8 @@ if ($("body.author").length > 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Split path name to array and remove blanks
|
||||||
|
url = window.location.pathname
|
||||||
// Ereader Page - add class to iframe body on ereader page after it loads.
|
// Ereader Page - add class to iframe body on ereader page after it loads.
|
||||||
backurl = "../../book/" + url[2]
|
backurl = "../../book/" + url[2]
|
||||||
$("body.epub #title-controls")
|
$("body.epub #title-controls")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
||||||
* Copyright (C) 2018 jkrehm
|
* Copyright (C) 2018-2023 jkrehm, OzzieIsaacs
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,6 +17,35 @@
|
||||||
|
|
||||||
/* global _ */
|
/* global _ */
|
||||||
|
|
||||||
|
function handleResponse (data) {
|
||||||
|
$(".row-fluid.text-center").remove();
|
||||||
|
$("#flash_danger").remove();
|
||||||
|
$("#flash_success").remove();
|
||||||
|
if (!jQuery.isEmptyObject(data)) {
|
||||||
|
if($("#bookDetailsModal").is(":visible")) {
|
||||||
|
data.forEach(function (item) {
|
||||||
|
$(".modal-header").after('<div id="flash_' + item.type +
|
||||||
|
'" class="text-center alert alert-' + item.type + '">' + item.message + '</div>');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
data.forEach(function (item) {
|
||||||
|
$(".navbar").after('<div class="row-fluid text-center">' +
|
||||||
|
'<div id="flash_' + item.type + '" class="alert alert-' + item.type + '">' + item.message + '</div>' +
|
||||||
|
'</div>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(".sendbtn-form").click(function() {
|
||||||
|
$.ajax({
|
||||||
|
method: 'post',
|
||||||
|
url: $(this).data('href'),
|
||||||
|
success: function (data) {
|
||||||
|
handleResponse(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#have_read_form").ajaxForm();
|
$("#have_read_form").ajaxForm();
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ function init(logType) {
|
||||||
d.innerHTML = "loading ...";
|
d.innerHTML = "loading ...";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: window.location.pathname + "/../../ajax/log/" + logType,
|
url: getPath() + "/../../ajax/log/" + logType,
|
||||||
datatype: "text",
|
datatype: "text",
|
||||||
cache: false
|
cache: false
|
||||||
})
|
})
|
||||||
|
|
|
@ -85,14 +85,6 @@ $(document).on("change", "select[data-controlall]", function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*$(document).on("click", "#sendbtn", function (event) {
|
|
||||||
postButton(event, $(this).data('action'));
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on("click", ".sendbutton", function (event) {
|
|
||||||
// $(".sendbutton").on("click", "body", function(event) {
|
|
||||||
postButton(event, $(this).data('action'));
|
|
||||||
});*/
|
|
||||||
|
|
||||||
$(document).on("click", ".postAction", function (event) {
|
$(document).on("click", ".postAction", function (event) {
|
||||||
// $(".sendbutton").on("click", "body", function(event) {
|
// $(".sendbutton").on("click", "body", function(event) {
|
||||||
|
@ -100,7 +92,6 @@ $(document).on("click", ".postAction", function (event) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Syntax has to be bind not on, otherwise problems with firefox
|
// Syntax has to be bind not on, otherwise problems with firefox
|
||||||
$(".container-fluid").bind("dragenter dragover", function () {
|
$(".container-fluid").bind("dragenter dragover", function () {
|
||||||
if($("#btn-upload").length && !$('body').hasClass('shelforder')) {
|
if($("#btn-upload").length && !$('body').hasClass('shelforder')) {
|
||||||
|
@ -321,7 +312,7 @@ $(function() {
|
||||||
folder: folder,
|
folder: folder,
|
||||||
filter: filt
|
filter: filt
|
||||||
},
|
},
|
||||||
url: window.location.pathname + request_path,
|
url: getPath() + request_path,
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
if ($("#element_selected").text() ==="") {
|
if ($("#element_selected").text() ==="") {
|
||||||
$("#element_selected").text(data.cwd);
|
$("#element_selected").text(data.cwd);
|
||||||
|
@ -434,7 +425,7 @@ $(function() {
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname + "/../../get_update_status",
|
url: getPath() + "/../../get_update_status",
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
$this.html(buttonText);
|
$this.html(buttonText);
|
||||||
|
|
||||||
|
@ -538,6 +529,7 @@ $(function() {
|
||||||
$("#bookDetailsModal")
|
$("#bookDetailsModal")
|
||||||
.on("show.bs.modal", function(e) {
|
.on("show.bs.modal", function(e) {
|
||||||
$("#flash_danger").remove();
|
$("#flash_danger").remove();
|
||||||
|
$("#flash_success").remove();
|
||||||
var $modalBody = $(this).find(".modal-body");
|
var $modalBody = $(this).find(".modal-body");
|
||||||
|
|
||||||
// Prevent static assets from loading multiple times
|
// Prevent static assets from loading multiple times
|
||||||
|
@ -650,7 +642,6 @@ $(function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("#user_submit").click(function() {
|
$("#user_submit").click(function() {
|
||||||
this.closest("form").submit();
|
this.closest("form").submit();
|
||||||
});
|
});
|
||||||
|
@ -682,7 +673,7 @@ $(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"post",
|
method:"post",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname + "/../../ajax/simulatedbchange",
|
url: getPath() + "/../../ajax/simulatedbchange",
|
||||||
data: {config_calibre_dir: $("#config_calibre_dir").val(), csrf_token: $("input[name='csrf_token']").val()},
|
data: {config_calibre_dir: $("#config_calibre_dir").val(), csrf_token: $("input[name='csrf_token']").val()},
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
if ( data.change ) {
|
if ( data.change ) {
|
||||||
|
@ -713,13 +704,13 @@ $(function() {
|
||||||
var loader = "/../..";
|
var loader = "/../..";
|
||||||
$("#flash_success").remove();
|
$("#flash_success").remove();
|
||||||
$("#flash_danger").remove();
|
$("#flash_danger").remove();
|
||||||
$.post(window.location.pathname + request_path, $(this).closest("form").serialize(), function(data) {
|
$.post(getPath() + request_path, $(this).closest("form").serialize(), function(data) {
|
||||||
$('#config_upload_formats').val(data.config_upload);
|
$('#config_upload_formats').val(data.config_upload);
|
||||||
if(data.reboot) {
|
if(data.reboot) {
|
||||||
$("#spinning_success").show();
|
$("#spinning_success").show();
|
||||||
var rebootInterval = setInterval(function(){
|
var rebootInterval = setInterval(function(){
|
||||||
$.get({
|
$.get({
|
||||||
url:window.location.pathname + "/../../admin/alive",
|
url:getPath() + "/../../admin/alive",
|
||||||
success: function (d, statusText, xhr) {
|
success: function (d, statusText, xhr) {
|
||||||
if (xhr.status < 400) {
|
if (xhr.status < 400) {
|
||||||
$("#spinning_success").hide();
|
$("#spinning_success").hide();
|
||||||
|
@ -745,7 +736,6 @@ $(function() {
|
||||||
$(this).data('value'),
|
$(this).data('value'),
|
||||||
function(value){
|
function(value){
|
||||||
postButton(event, $("#delete_shelf").data("action"));
|
postButton(event, $("#delete_shelf").data("action"));
|
||||||
// $("#delete_shelf").closest("form").submit()
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ $(function() {
|
||||||
method: "post",
|
method: "post",
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname + "/../ajax/canceltask",
|
url: getPath() + "/../ajax/canceltask",
|
||||||
data: JSON.stringify({"task_id": taskId}),
|
data: JSON.stringify({"task_id": taskId}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
100
cps/templates/detail.html
Normal file → Executable file
100
cps/templates/detail.html
Normal file → Executable file
|
@ -5,12 +5,13 @@
|
||||||
<div class="col-sm-3 col-lg-3 col-xs-5">
|
<div class="col-sm-3 col-lg-3 col-xs-5">
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
<!-- Always use full-sized image for the detail page -->
|
<!-- Always use full-sized image for the detail page -->
|
||||||
<img id="detailcover" title="{{entry.title}}" src="{{url_for('web.get_cover', book_id=entry.id, resolution='og', c=entry|last_modified)}}" />
|
<img id="detailcover" title="{{ entry.title }}"
|
||||||
|
src="{{ url_for('web.get_cover', book_id=entry.id, resolution='og', c=entry|last_modified) }}"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-9 col-lg-9 book-meta">
|
<div class="col-sm-9 col-lg-9 book-meta">
|
||||||
<div class="btn-toolbar" role="toolbar">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
<div class="btn-group" role="group" aria-label="Download, send to eReader, reading">
|
<div class="btn-group" role="group" aria-label="Download, send to E-Reader, reading">
|
||||||
{% if current_user.role_download() %}
|
{% if current_user.role_download() %}
|
||||||
{% if entry.data|length %}
|
{% if entry.data|length %}
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
|
@ -19,18 +20,24 @@
|
||||||
{{ _('Download') }} :
|
{{ _('Download') }} :
|
||||||
</button>
|
</button>
|
||||||
{% for format in entry.data %}
|
{% for format in entry.data %}
|
||||||
<a href="{{ url_for('web.download_link', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}" id="btnGroupDrop1{{format.format|lower}}" class="btn btn-primary" role="button">
|
<a href="{{ url_for('web.download_link', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}"
|
||||||
<span class="glyphicon glyphicon-download"></span>{{format.format}} ({{ format.uncompressed_size|filesizeformat }})
|
id="btnGroupDrop1{{ format.format|lower }}" class="btn btn-primary"
|
||||||
|
role="button">
|
||||||
|
<span class="glyphicon glyphicon-download"></span>{{ format.format }}
|
||||||
|
({{ format.uncompressed_size|filesizeformat }})
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<button id="btnGroupDrop1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<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="glyphicon glyphicon-download"></span> {{ _('Download') }}
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
|
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
|
||||||
{% for format in entry.data %}
|
{% for format in entry.data %}
|
||||||
<li><a href="{{ url_for('web.download_link', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}">{{format.format}} ({{ format.uncompressed_size|filesizeformat }})</a></li>
|
<li>
|
||||||
|
<a href="{{ url_for('web.download_link', book_id=entry.id, book_format=format.format|lower, anyname=entry.id|string+'.'+format.format|lower) }}">{{ format.format }}
|
||||||
|
({{ format.uncompressed_size|filesizeformat }})</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -40,16 +47,23 @@
|
||||||
{% if current_user.kindle_mail and entry.email_share_list %}
|
{% if current_user.kindle_mail and entry.email_share_list %}
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
{% if entry.email_share_list.__len__() == 1 %}
|
{% if entry.email_share_list.__len__() == 1 %}
|
||||||
<div id="sendbtn" data-action="{{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'])}}" data-text="{{_('Send to eReader')}}" class="btn btn-primary postAction" role="button"><span class="glyphicon glyphicon-send"></span> {{entry.email_share_list[0]['text']}}</div>
|
<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>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button id="sendbtn2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button id="sendbtn2" type="button" class="btn btn-primary dropdown-toggle"
|
||||||
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<span class="glyphicon glyphicon-send"></span>{{ _('Send to eReader') }}
|
<span class="glyphicon glyphicon-send"></span>{{ _('Send to eReader') }}
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="send-to-ereader">
|
<ul class="dropdown-menu" aria-labelledby="send-to-ereader">
|
||||||
{% for format in entry.email_share_list %}
|
{% for format in entry.email_share_list %}
|
||||||
<li><a class="postAction" data-action="{{url_for('web.send_to_ereader', book_id=entry.id, book_format=format['format'], convert=format['convert'])}}">{{format['text']}}</a></li>
|
<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>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,17 +72,24 @@
|
||||||
{% if entry.reader_list and current_user.role_viewer() %}
|
{% if entry.reader_list and current_user.role_viewer() %}
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
{% if entry.reader_list|length > 1 %}
|
{% if entry.reader_list|length > 1 %}
|
||||||
<button id="read-in-browser" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button id="read-in-browser" type="button" class="btn btn-primary dropdown-toggle"
|
||||||
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<span class="glyphicon glyphicon-book"></span> {{ _('Read in Browser') }}
|
<span class="glyphicon glyphicon-book"></span> {{ _('Read in Browser') }}
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="read-in-browser">
|
<ul class="dropdown-menu" aria-labelledby="read-in-browser">
|
||||||
{% for format in entry.reader_list %}
|
{% for format in entry.reader_list %}
|
||||||
<li><a target="_blank" href="{{ url_for('web.read_book', book_id=entry.id, book_format=format) }}">{{format}}</a></li>
|
<li><a target="_blank"
|
||||||
|
href="{{ url_for('web.read_book', book_id=entry.id, book_format=format) }}">{{ format }}</a>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a target="_blank" href="{{url_for('web.read_book', book_id=entry.id, book_format=entry.reader_list[0])}}" id="readbtn" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-book"></span> {{_('Read in Browser')}} - {{entry.reader_list[0]}}</a>
|
<a target="_blank"
|
||||||
|
href="{{ url_for('web.read_book', book_id=entry.id, book_format=entry.reader_list[0]) }}"
|
||||||
|
id="readbtn" class="btn btn-primary" role="button"><span
|
||||||
|
class="glyphicon glyphicon-book"></span> {{ _('Read in Browser') }}
|
||||||
|
- {{ entry.reader_list[0] }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -81,14 +102,17 @@
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="listen-in-browser">
|
<ul class="dropdown-menu" aria-labelledby="listen-in-browser">
|
||||||
{% for format in entry.reader_list %}
|
{% for format in entry.reader_list %}
|
||||||
<li><a target="_blank" href="{{ url_for('web.read_book', book_id=entry.id, book_format=format) }}">{{format}}</a></li>
|
<li><a target="_blank" href="{{ url_for('web.read_book', book_id=entry.id, book_format=format) }}">{{ format }}</a>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="dropdown-menu" aria-labelledby="listen-in-browser">
|
<ul class="dropdown-menu" aria-labelledby="listen-in-browser">
|
||||||
|
|
||||||
{% for format in entry.data %}
|
{% for format in entry.data %}
|
||||||
{% if format.format|lower in entry.audio_entries %}
|
{% if format.format|lower in entry.audio_entries %}
|
||||||
<li><a target="_blank" href="{{ url_for('web.read_book', book_id=entry.id, book_format=format.format|lower) }}">{{format.format|lower }}</a></li>
|
<li><a target="_blank"
|
||||||
|
href="{{ url_for('web.read_book', book_id=entry.id, book_format=format.format|lower) }}">{{ format.format|lower }}</a>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -130,7 +154,8 @@
|
||||||
{% if entry.languages.__len__() > 0 %}
|
{% if entry.languages.__len__() > 0 %}
|
||||||
<div class="languages">
|
<div class="languages">
|
||||||
<p>
|
<p>
|
||||||
<span class="label label-default">{{_('Language')}}: {% for language in entry.languages %}{{language.language_name}}{% if not loop.last %}, {% endif %}{% endfor %}</span>
|
<span class="label label-default">{{ _('Language') }}: {% for language in entry.languages %}
|
||||||
|
{{ language.language_name }}{% if not loop.last %}, {% endif %}{% endfor %}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -140,7 +165,8 @@
|
||||||
<p>
|
<p>
|
||||||
<span class="glyphicon glyphicon-link"></span>
|
<span class="glyphicon glyphicon-link"></span>
|
||||||
{% for identifier in entry.identifiers %}
|
{% for identifier in entry.identifiers %}
|
||||||
<a href="{{identifier}}" target="_blank" class="btn btn-xs btn-success" role="button">{{identifier.format_type()}}</a>
|
<a href="{{ identifier }}" target="_blank" class="btn btn-xs btn-success"
|
||||||
|
role="button">{{ identifier.format_type() }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -153,7 +179,8 @@
|
||||||
<span class="glyphicon glyphicon-tags"></span>
|
<span class="glyphicon glyphicon-tags"></span>
|
||||||
|
|
||||||
{% for tag in entry.tags %}
|
{% for tag in entry.tags %}
|
||||||
<a href="{{ url_for('web.books_list', data='category', sort_param='stored', book_id=tag.id) }}" class="btn btn-xs btn-info" role="button">{{tag.name}}</a>
|
<a href="{{ url_for('web.books_list', data='category', sort_param='stored', book_id=tag.id) }}"
|
||||||
|
class="btn btn-xs btn-info" role="button">{{ tag.name }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -217,20 +244,26 @@
|
||||||
|
|
||||||
<div class="custom_columns">
|
<div class="custom_columns">
|
||||||
<p>
|
<p>
|
||||||
<form id="have_read_form" action="{{ url_for('web.toggle_read', book_id=entry.id)}}" method="POST">
|
<form id="have_read_form" action="{{ url_for('web.toggle_read', book_id=entry.id) }}"
|
||||||
|
method="POST">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
<label class="block-label">
|
<label class="block-label">
|
||||||
<input id="have_read_cb" data-checked="{{_('Mark As Unread')}}" data-unchecked="{{_('Mark As Read')}}" type="checkbox" {% if entry.read_status %}checked{% endif %} >
|
<input id="have_read_cb" data-checked="{{ _('Mark As Unread') }}"
|
||||||
|
data-unchecked="{{ _('Mark As Read') }}" type="checkbox"
|
||||||
|
{% if entry.read_status %}checked{% endif %}>
|
||||||
<span>{{ _('Read') }}</span>
|
<span>{{ _('Read') }}</span>
|
||||||
</label>
|
</label>
|
||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
{% if current_user.check_visibility(32768) %}
|
{% if current_user.check_visibility(32768) %}
|
||||||
<p>
|
<p>
|
||||||
<form id="archived_form" action="{{ url_for('web.toggle_archived', book_id=entry.id)}}" method="POST">
|
<form id="archived_form" action="{{ url_for('web.toggle_archived', book_id=entry.id) }}"
|
||||||
|
method="POST">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
<label class="block-label">
|
<label class="block-label">
|
||||||
<input id="archived_cb" data-checked="{{_('Restore from archive')}}" data-unchecked="{{_('Add to archive')}}" type="checkbox" {% if entry.is_archived %}checked{% endif %} >
|
<input id="archived_cb" data-checked="{{ _('Restore from archive') }}"
|
||||||
|
data-unchecked="{{ _('Add to archive') }}" type="checkbox"
|
||||||
|
{% if entry.is_archived %}checked{% endif %}>
|
||||||
<span>{{ _('Archived') }}</span>
|
<span>{{ _('Archived') }}</span>
|
||||||
</label>
|
</label>
|
||||||
</form>
|
</form>
|
||||||
|
@ -254,7 +287,9 @@
|
||||||
{% if current_user.shelf.all() or g.shelves_access %}
|
{% if current_user.shelf.all() or g.shelves_access %}
|
||||||
<div id="shelf-actions" class="btn-toolbar" role="toolbar">
|
<div id="shelf-actions" class="btn-toolbar" role="toolbar">
|
||||||
<div class="btn-group" role="group" aria-label="Add to shelves">
|
<div class="btn-group" role="group" aria-label="Add to shelves">
|
||||||
<button id="add-to-shelf" type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button id="add-to-shelf" type="button"
|
||||||
|
class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown"
|
||||||
|
aria-haspopup="true" aria-expanded="false">
|
||||||
<span class="glyphicon glyphicon-list"></span> {{ _('Add to shelf') }}
|
<span class="glyphicon glyphicon-list"></span> {{ _('Add to shelf') }}
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -266,20 +301,23 @@
|
||||||
data-remove-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
data-remove-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
||||||
data-shelf-action="add"
|
data-shelf-action="add"
|
||||||
>
|
>
|
||||||
{{shelf.name}}{% if shelf.is_public == 1 %} {{_('(Public)')}}{% endif %}
|
{{ shelf.name }}{% if shelf.is_public == 1 %}
|
||||||
|
{{ _('(Public)') }}{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="remove-from-shelves" class="btn-group" role="group" aria-label="Remove from shelves">
|
<div id="remove-from-shelves" class="btn-group" role="group"
|
||||||
|
aria-label="Remove from shelves">
|
||||||
{% if books_shelfs %}
|
{% if books_shelfs %}
|
||||||
{% for shelf in g.shelves_access %}
|
{% for shelf in g.shelves_access %}
|
||||||
{% if shelf.id in books_shelfs %}
|
{% if shelf.id in books_shelfs %}
|
||||||
<a data-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
<a data-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
||||||
data-add-href="{{ url_for('shelf.add_to_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
data-add-href="{{ url_for('shelf.add_to_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
|
||||||
class="btn btn-sm btn-default" role="button" data-shelf-action="remove"
|
class="btn btn-sm btn-default" role="button"
|
||||||
|
data-shelf-action="remove"
|
||||||
>
|
>
|
||||||
<span {% if not shelf.is_public or current_user.role_edit_shelfs() %}
|
<span {% if not shelf.is_public or current_user.role_edit_shelfs() %}
|
||||||
class="glyphicon glyphicon-remove"
|
class="glyphicon glyphicon-remove"
|
||||||
|
@ -297,12 +335,13 @@
|
||||||
{% if current_user.role_edit() %}
|
{% if current_user.role_edit() %}
|
||||||
<div class="btn-toolbar" role="toolbar">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
<div class="btn-group" role="group" aria-label="Edit/Delete book">
|
<div class="btn-group" role="group" aria-label="Edit/Delete book">
|
||||||
<a href="{{ url_for('edit-book.show_edit_book', book_id=entry.id) }}" class="btn btn-sm btn-primary" id="edit_book" role="button"><span class="glyphicon glyphicon-edit"></span> {{_('Edit Metadata')}}</a>
|
<a href="{{ url_for('edit-book.show_edit_book', book_id=entry.id) }}"
|
||||||
|
class="btn btn-sm btn-primary" id="edit_book" role="button"><span
|
||||||
|
class="glyphicon glyphicon-edit"></span> {{ _('Edit Metadata') }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -317,10 +356,15 @@
|
||||||
</li>
|
</li>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/template" id="template-shelf-remove">
|
<script type="text/template" id="template-shelf-remove">
|
||||||
<a data-href="<%= remove %>" data-add-href="<%= add %>" class="btn btn-sm btn-default" data-shelf-action="remove">
|
<a data-href="<%= remove %>" data-add-href="<%= add %>" class="btn btn-sm btn-default"
|
||||||
|
data-shelf-action="remove">
|
||||||
<span class="glyphicon glyphicon-remove"></span> <%= content %>
|
<span class="glyphicon glyphicon-remove"></span> <%= content %>
|
||||||
</a>
|
</a>
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ url_for('static', filename='js/details.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/details.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/fullscreen.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/fullscreen.js') }}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
18
cps/web.py
Normal file → Executable file
18
cps/web.py
Normal file → Executable file
|
@ -25,7 +25,7 @@ import chardet # dependency of requests
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
from flask import request, redirect, send_from_directory, make_response, flash, abort, url_for
|
from flask import request, redirect, send_from_directory, make_response, flash, abort, url_for, Response
|
||||||
from flask import session as flask_session
|
from flask import session as flask_session
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
from flask_babel import get_locale
|
from flask_babel import get_locale
|
||||||
|
@ -1214,22 +1214,20 @@ def download_link(book_id, book_format, anyname):
|
||||||
@download_required
|
@download_required
|
||||||
def send_to_ereader(book_id, book_format, convert):
|
def send_to_ereader(book_id, book_format, convert):
|
||||||
if not config.get_mail_server_configured():
|
if not config.get_mail_server_configured():
|
||||||
flash(_("Please configure the SMTP mail settings first."), category="error")
|
response = [{'type': "danger", 'message': _("Please configure the SMTP mail settings first...")}]
|
||||||
|
return Response(json.dumps(response), mimetype='application/json')
|
||||||
elif current_user.kindle_mail:
|
elif current_user.kindle_mail:
|
||||||
result = send_mail(book_id, book_format, convert, current_user.kindle_mail, config.config_calibre_dir,
|
result = send_mail(book_id, book_format, convert, current_user.kindle_mail, config.config_calibre_dir,
|
||||||
current_user.name)
|
current_user.name)
|
||||||
if result is None:
|
if result is None:
|
||||||
flash(_("Success! Book queued for sending to %(eReadermail)s", eReadermail=current_user.kindle_mail),
|
|
||||||
category="success")
|
|
||||||
ub.update_download(book_id, int(current_user.id))
|
ub.update_download(book_id, int(current_user.id))
|
||||||
|
response = [{'type': "success", 'message': _("Success! Book queued for sending to %(eReadermail)s",
|
||||||
|
eReadermail=current_user.kindle_mail)}]
|
||||||
else:
|
else:
|
||||||
flash(_("Oops! There was an error sending book: %(res)s", res=result), category="error")
|
response = [{'type': "danger", 'message': _("Oops! There was an error sending book: %(res)s", res=result)}]
|
||||||
else:
|
else:
|
||||||
flash(_("Oops! Please update your profile with a valid eReader Email."), category="error")
|
response = [{'type': "danger", 'message': _("Oops! Please update your profile with a valid eReader Email.")}]
|
||||||
if "HTTP_REFERER" in request.environ:
|
return Response(json.dumps(response), mimetype='application/json')
|
||||||
return redirect(request.environ["HTTP_REFERER"])
|
|
||||||
else:
|
|
||||||
return redirect(url_for('web.index'))
|
|
||||||
|
|
||||||
|
|
||||||
# ################################### Login Logout ##################################################################
|
# ################################### Login Logout ##################################################################
|
||||||
|
|
Loading…
Reference in New Issue
Block a user