Download only shelf
Show only titles and download button for specific shelf. Currently only direct link works, e.g: calibre-web/shelfdown/6
This commit is contained in:
parent
7253f583cf
commit
e0229c917c
82
cps/templates/shelfdown.html
Normal file
82
cps/templates/shelfdown.html
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="{{ g.user.locale }}">
|
||||||
|
<head>
|
||||||
|
<title>{{instance}} | {{title}}</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
|
||||||
|
<!-- Bootstrap -->
|
||||||
|
<link rel="apple-touch-icon" sizes="140x140" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
|
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
|
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
|
||||||
|
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
|
||||||
|
{% if g.user.get_theme == 1 %}
|
||||||
|
<link href="{{ url_for('static', filename='css/caliBlur-style.css') }}" rel="stylesheet" media="screen">
|
||||||
|
{% endif %}
|
||||||
|
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||||
|
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
{% block header %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body class="{{ page }}">
|
||||||
|
{% block body %}
|
||||||
|
<div class="discover">
|
||||||
|
<h2>{{title}}</h2>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
{% for entry in entries %}
|
||||||
|
<div class="col-sm-3 col-lg-2 col-xs-6 book">
|
||||||
|
|
||||||
|
<div class="meta">
|
||||||
|
<p class="title">{{entry.title|shortentitle}}</p>
|
||||||
|
<p class="author">
|
||||||
|
{% for author in entry.authors %}
|
||||||
|
<a href="{{url_for('author', book_id=author.id) }}">{{author.name.replace('|',',')}}</a>
|
||||||
|
{% if not loop.last %}
|
||||||
|
&
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group" role="group" aria-label="Download, send to Kindle, reading">
|
||||||
|
{% if g.user.role_download() %}
|
||||||
|
{% if entry.data|length %}
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
{% if entry.data|length < 2 %}
|
||||||
|
|
||||||
|
{% for format in entry.data %}
|
||||||
|
<a href="{{ url_for('get_download_link_ext', 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">
|
||||||
|
<span class="glyphicon glyphicon-download"></span>{{format.format}} ({{ format.uncompressed_size|filesizeformat }})
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<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" aria-labelledby="btnGroupDrop1">
|
||||||
|
{% for format in entry.data %}
|
||||||
|
<li><a href="{{ url_for('get_download_link_ext', 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 %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
29
cps/web.py
29
cps/web.py
|
@ -2676,6 +2676,35 @@ def show_shelf(shelf_id):
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/shelfdown/<int:shelf_id>")
|
||||||
|
@login_required_if_no_ano
|
||||||
|
def show_shelf_down(shelf_id):
|
||||||
|
if current_user.is_anonymous:
|
||||||
|
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1, ub.Shelf.id == shelf_id).first()
|
||||||
|
else:
|
||||||
|
shelf = ub.session.query(ub.Shelf).filter(ub.or_(ub.and_(ub.Shelf.user_id == int(current_user.id),
|
||||||
|
ub.Shelf.id == shelf_id),
|
||||||
|
ub.and_(ub.Shelf.is_public == 1,
|
||||||
|
ub.Shelf.id == shelf_id))).first()
|
||||||
|
result = list()
|
||||||
|
# user is allowed to access shelf
|
||||||
|
if shelf:
|
||||||
|
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).order_by(
|
||||||
|
ub.BookShelf.order.asc()).all()
|
||||||
|
for book in books_in_shelf:
|
||||||
|
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
||||||
|
if cur_book:
|
||||||
|
result.append(cur_book)
|
||||||
|
else:
|
||||||
|
app.logger.info('Not existing book %s in shelf %s deleted' % (book.book_id, shelf.id))
|
||||||
|
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book.book_id).delete()
|
||||||
|
ub.session.commit()
|
||||||
|
return render_title_template('shelfdown.html', entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name),
|
||||||
|
shelf=shelf, page="shelf")
|
||||||
|
else:
|
||||||
|
flash(_(u"Error opening shelf. Shelf does not exist or is not accessible"), category="error")
|
||||||
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
@app.route("/shelf/order/<int:shelf_id>", methods=["GET", "POST"])
|
@app.route("/shelf/order/<int:shelf_id>", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def order_shelf(shelf_id):
|
def order_shelf(shelf_id):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user