Fix opds login on python3

pull/932/head
Ozzieisaacs 6 years ago
parent de58d0a4d8
commit 68a36597ab

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

File diff suppressed because one or more lines are too long

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

@ -2,17 +2,20 @@
{% block body %} {% block body %}
<h1 class="{{page}}">{{_(title)}}</h1> <h1 class="{{page}}">{{_(title)}}</h1>
<div class="container"> <div class="container">
<div class="col-xs-12 col-sm-6"> <span class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet"></span></span></button>
{% for entry in entries %} <button class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet-alt"></span></button>
{% if loop.index0 == (loop.length/2)|int and loop.length > 20 %} <div class="btn-group" role="group">
</div> {% for char in charlist%}
<div class="col-xs-12 col-sm-6"> <button class="btn btn-success">{{char.char}}</button>
{% endif %} {% endfor %}
<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>
</div> </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 %} {% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

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

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

Loading…
Cancel
Save