1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 01:50:31 +00:00

Fix opds login on python3

This commit is contained in:
Ozzieisaacs 2019-03-03 07:37:15 +01:00
parent de58d0a4d8
commit 68a36597ab
6 changed files with 104 additions and 16 deletions

View File

@ -35,6 +35,7 @@ from sqlalchemy.sql.expression import func
import helper
from werkzeug.security import check_password_hash
from werkzeug.datastructures import Headers
from web import download_required
try:
from urllib.parse import quote
except ImportError:
@ -66,7 +67,7 @@ def feed_index():
def feed_osd():
return render_xml_template('osd.xml', lang='en-EN')
@opds.route("/opds/search", defaults={'query': ""})
@opds.route("/opds/search/<query>")
@requires_basic_auth_if_no_ano
def feed_cc_search(query):
@ -254,7 +255,7 @@ def feed_shelf(book_id):
@opds.route("/opds/download/<book_id>/<book_format>/")
@requires_basic_auth_if_no_ano
# @download_required
@download_required
def get_opds_download_link(book_id, book_format):
book_format = book_format.split(".")[0]
book = db.session.query(db.Books).filter(db.Books.id == book_id).first()

File diff suppressed because one or more lines are too long

View File

@ -94,6 +94,13 @@ $(function() {
layoutMode : "fitRows"
});
$(".grid").isotope({
// options
itemSelector : ".grid-item",
layoutMode : "fitColumns"
});
var $loadMore = $(".load-more .row").infiniteScroll({
debug: false,
// selector for the paged navigation (it will be hidden)

View File

@ -2,17 +2,20 @@
{% block body %}
<h1 class="{{page}}">{{_(title)}}</h1>
<div class="container">
<div class="col-xs-12 col-sm-6">
{% for entry in entries %}
{% if loop.index0 == (loop.length/2)|int and loop.length > 20 %}
</div>
<div class="col-xs-12 col-sm-6">
{% endif %}
<div class="row">
<div class="col-xs-2 col-sm-2 col-md-1" align="left"><span class="badge">{{entry.count}}</span></div>
<div class="col-xs-10 col-sm-10 col-md-11"><a id="list_{{loop.index0}}" href="{{url_for(folder, book_id=entry[0].id )}}">{{entry[0].name}}</a></div>
<span class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet"></span></span></button>
<button class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet-alt"></span></button>
<div class="btn-group" role="group">
{% for char in charlist%}
<button class="btn btn-success">{{char.char}}</button>
{% endfor %}
</div>
<div class="grid">
{% for entry in entries %}
<div class="grid-item">
<span class="badge">{{entry.count}}</span>
<a id="list_{{loop.index0}}" href="{{url_for(folder, book_id=entry[0].id )}}">{{entry[0].name}}</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

View File

@ -6,7 +6,7 @@
<Developer>Janeczku</Developer>
<Contact>https://github.com/janeczku/calibre-web</Contact>
<Url type="text/html"
template="{{url_for('opds.search')}}?query={searchTerms}"/>
template="{{url_for('opds.feed_cc_search')}}?query={searchTerms}"/>
<Url type="application/atom+xml"
template="{{url_for('opds.feed_normal_search')}}?query={searchTerms}"/>
<SyndicationRight>open</SyndicationRight>

View File

@ -141,7 +141,7 @@ def load_user_from_header(header_val):
header_val = header_val.replace('Basic ', '', 1)
basic_username = basic_password = ''
try:
header_val = base64.b64decode(header_val)
header_val = base64.b64decode(header_val).decode('utf-8')
basic_username = header_val.split(':')[0]
basic_password = header_val.split(':')[1]
except TypeError:
@ -598,9 +598,13 @@ def author_list():
entries = db.session.query(db.Authors, func.count('books_authors_link.book').label('count'))\
.join(db.books_authors_link).join(db.Books).filter(common_filters())\
.group_by('books_authors_link.author').order_by(db.Authors.sort).all()
charlist = db.session.query(func.upper(func.substr(db.Authors.sort,1,1)).label('char')) \
.join(db.books_authors_link).join(db.Books).filter(common_filters()) \
.group_by(func.upper(func.substr(db.Authors.sort,1,1))).all()
# charlist = db.session.query(func.substr(db.Authors.sort,1,1).label('char'),func.count(db.Authors.sort).label('count')).group_by(func.substr(db.Authors.sort,1,1)).all()
for entry in entries:
entry.Authors.name = entry.Authors.name.replace('|', ',')
return render_title_template('list.html', entries=entries, folder='web.author',
return render_title_template('list.html', entries=entries, folder='web.author', charlist=charlist,
title=u"Author list", page="authorlist")
else:
abort(404)