mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 04:19:59 +00:00
Improvements for OPDS on iOS with Bookari- and Chunky-Reader
This commit is contained in:
parent
8494cb698c
commit
a16321179d
@ -3,17 +3,19 @@
|
||||
<id>urn:uuid:2853dacf-ed79-42f5-8e8a-a7bb3d1ae6a2</id>
|
||||
<link rel="self"
|
||||
href="{{url_for('feed_index')}}"
|
||||
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
||||
type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
<link rel="start"
|
||||
href="{{url_for('feed_index')}}"
|
||||
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
||||
type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
<link rel="up"
|
||||
href="{{url_for('feed_index')}}"
|
||||
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
||||
type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
{% if pagination.has_next %}
|
||||
<link rel="next"
|
||||
title="{{_('Next')}}"
|
||||
href="{{ next_url }}"
|
||||
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
|
||||
type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
{% endif %}
|
||||
<link rel="search"
|
||||
href="{{url_for('feed_osd')}}"
|
||||
type="application/opensearchdescription+xml"/>
|
||||
@ -30,7 +32,6 @@
|
||||
<updated>{{entry.timestamp}}</updated>
|
||||
<author>
|
||||
<name>{{entry.authors[0].name}}</name>
|
||||
<uri>{{entry.authors[0].name}}</uri>
|
||||
</author>
|
||||
<language>{{entry.language}}</language>
|
||||
{% for tag in entry.tags %}
|
||||
@ -38,17 +39,18 @@
|
||||
term="{{tag.name}}"
|
||||
label="{{tag.name}}"/>
|
||||
{% endfor %}
|
||||
<summary>{% if entry.comments[0] %}{{entry.comments[0].text|striptags}}{% endif %}</summary>
|
||||
{% if entry.comments[0] %}<summary>{{entry.comments[0].text|striptags}}</summary>{% endif %}
|
||||
{% if entry.has_cover %}
|
||||
<link rel="http://opds-spec.org/image" href="{{ url_for('feed_get_cover', cover_path=entry.path) }}" type="image/jpg"/>
|
||||
<link rel="http://opds-spec.org/cover" href="{{ url_for('feed_get_cover', cover_path=entry.path) }}" type="image/jpg"/>
|
||||
<link rel="http://opds-spec.org/image/thumbnail" href="{{ url_for('feed_get_cover', cover_path=entry.path) }}" type="image/jpg"/>
|
||||
<link type="image/jpeg" href="{{url_for('feed_get_cover', book_id=entry.id)}}" rel="http://opds-spec.org/image"/>
|
||||
<link type="image/jpeg" href="{{url_for('feed_get_cover', book_id=entry.id)}}" rel="http://opds-spec.org/image/thumbnail"/>
|
||||
{% endif %}
|
||||
{% for format in entry.data %}
|
||||
<link rel="http://opds-spec.org/acquisition" href="{{ url_for('get_opds_download_link', book_id=entry.id, format=format.format|lower)}}"
|
||||
length="{{format.uncompressed_size}}" mtime="{{entry.timestamp}}"
|
||||
{% if format.format|lower == "epub" %}
|
||||
type="application/epub+zip"/>
|
||||
{% elif format.format|lower == "cbr" %}
|
||||
type="application/x-cbr"/>
|
||||
{% else %}
|
||||
type="application/x-mobipocket-ebook"/>
|
||||
{% endif %}
|
||||
@ -59,7 +61,7 @@
|
||||
<entry>
|
||||
<title>{{author.name}}</title>
|
||||
<id>{{ url_for('feed_author', name=author.name) }}</id>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_author', name=author.name)}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_author', name=author.name)}}"/>
|
||||
<link type="application/atom+xml" href="{{url_for('feed_author', name=author.name)}}" rel="subsection"/>
|
||||
</entry>
|
||||
{% endfor %}
|
||||
@ -67,7 +69,7 @@
|
||||
<entry>
|
||||
<title>{{entry.name}}</title>
|
||||
<id>{{ url_for('feed_category', name=entry.name) }}</id>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_category', name=entry.name)}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_category', name=entry.name)}}"/>
|
||||
<link type="application/atom+xml" href="{{url_for('feed_category', name=entry.name)}}" rel="subsection"/>
|
||||
</entry>
|
||||
{% endfor %}
|
||||
|
@ -27,28 +27,28 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<title>{{_('Random Books')}}</title>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_discover')}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_discover')}}"/>
|
||||
<link rel="http://opds-spec.org/featured" href="{{url_for('feed_discover')}}" type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition"/>
|
||||
<id>{{url_for('feed_discover')}}</id>
|
||||
<content type="text">{{_('Show Random Books')}}</content>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>{{_('Authors')}}</title>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_authorindex')}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_authorindex')}}"/>
|
||||
<link rel="subsection" href="{{url_for('feed_authorindex')}}" type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
<id>{{url_for('feed_authorindex')}}</id>
|
||||
<content type="text">{{_('Books ordered by Author')}}</content>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>{{_('Category list')}}</title>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_categoryindex')}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_categoryindex')}}"/>
|
||||
<link rel="subsection" href="{{url_for('feed_categoryindex')}}" type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
<id>{{url_for('feed_categoryindex')}}</id>
|
||||
<content type="text">{{_('Books ordered by category')}}</content>
|
||||
</entry>
|
||||
<entry>
|
||||
<title>{{_('Series list')}}</title>
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_seriesindex')}}" />
|
||||
<link type="application/atom+xml;profile=opds-catalog;type=feed;kind=acquisition" href="{{url_for('feed_seriesindex')}}"/>
|
||||
<link rel="subsection" href="{{url_for('feed_seriesindex')}}" type="application/atom+xml;profile=opds-catalog;type=feed;kind=navigation"/>
|
||||
<id>{{url_for('feed_seriesindex')}}</id>
|
||||
<content type="text">{{_('Books ordered by series')}}</content>
|
||||
|
58
cps/web.py
58
cps/web.py
@ -472,7 +472,9 @@ def feed_new():
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(filter).order_by(db.Books.timestamp.desc()).offset(off).limit(
|
||||
config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Books).filter(filter).all()))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/new?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -482,16 +484,17 @@ def feed_new():
|
||||
@app.route("/opds/discover")
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_discover():
|
||||
off = request.args.get("start_index")
|
||||
# off = request.args.get("start_index")
|
||||
if current_user.filter_language() != "all":
|
||||
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
||||
else:
|
||||
filter = True
|
||||
if not off:
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(filter).order_by(func.random()).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
next_url="/opds/discover?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
# if not off:
|
||||
# off = 0
|
||||
entries = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.NEWEST_BOOKS)
|
||||
pagination = Pagination(1, config.NEWEST_BOOKS,int(config.NEWEST_BOOKS))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/discover")
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
return response
|
||||
@ -509,8 +512,9 @@ def feed_hot():
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(filter).filter(db.Books.ratings.any(db.Ratings.rating > 9)).offset(
|
||||
off).limit(config.NEWEST_BOOKS)
|
||||
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Books).filter(filter).filter(db.Books.ratings.any(db.Ratings.rating > 9)).all()))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/hot?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -521,6 +525,7 @@ def feed_hot():
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_authorindex():
|
||||
off = request.args.get("start_index")
|
||||
# ToDo: Language filter not working
|
||||
if current_user.filter_language() != "all":
|
||||
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
||||
else:
|
||||
@ -528,7 +533,9 @@ def feed_authorindex():
|
||||
if not off:
|
||||
off = 0
|
||||
authors = db.session.query(db.Authors).order_by(db.Authors.sort).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', authors=authors,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Authors).all()))
|
||||
xml = render_template('feed.xml', authors=authors, pagination=pagination,
|
||||
next_url="/opds/author?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -547,7 +554,9 @@ def feed_author(name):
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(db.Books.authors.any(db.Authors.name.like("%" + name + "%"))).filter(
|
||||
filter).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Books).filter(db.Books.authors.any(db.Authors.name.like("%" + name + "%"))).filter(filter).all()))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/author?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -561,7 +570,9 @@ def feed_categoryindex():
|
||||
if not off:
|
||||
off = 0
|
||||
entries = db.session.query(db.Tags).order_by(db.Tags.name).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', categorys=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Tags).all()))
|
||||
xml = render_template('feed.xml', categorys=entries, pagination=pagination,
|
||||
next_url="/opds/category?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -580,7 +591,9 @@ def feed_category(name):
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(db.Books.tags.any(db.Tags.name.like("%" + name + "%"))).order_by(
|
||||
db.Books.timestamp.desc()).filter(filter).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Books).filter(db.Books.tags.any(db.Tags.name.like("%" + name + "%"))).filter(filter).all()))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/category?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -591,10 +604,16 @@ def feed_category(name):
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_seriesindex():
|
||||
off = request.args.get("start_index")
|
||||
if current_user.filter_language() != "all":
|
||||
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
||||
else:
|
||||
filter = True
|
||||
if not off:
|
||||
off = 0
|
||||
entries = db.session.query(db.Series).order_by(db.Series.name).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', series=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Series).all()))
|
||||
xml = render_template('feed.xml', series=entries, pagination=pagination,
|
||||
next_url="/opds/series?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -613,7 +632,9 @@ def feed_series(name):
|
||||
off = 0
|
||||
entries = db.session.query(db.Books).filter(db.Books.series.any(db.Series.name.like("%" + name + "%"))).order_by(
|
||||
db.Books.timestamp.desc()).filter(filter).offset(off).limit(config.NEWEST_BOOKS)
|
||||
xml = render_template('feed.xml', entries=entries,
|
||||
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
|
||||
len(db.session.query(db.Books).filter(db.Books.series.any(db.Series.name.like("%" + name + "%"))).filter(filter).all()))
|
||||
xml = render_template('feed.xml', entries=entries, pagination=pagination,
|
||||
next_url="/opds/series?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
|
||||
response = make_response(xml)
|
||||
response.headers["Content-Type"] = "application/xml"
|
||||
@ -1037,10 +1058,11 @@ def get_cover(cover_path):
|
||||
return send_from_directory(os.path.join(config.DB_ROOT, cover_path), "cover.jpg")
|
||||
|
||||
|
||||
@app.route("/opds/cover/<path:cover_path>")
|
||||
@app.route("/opds/cover/<path:book_id>")
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_get_cover(cover_path):
|
||||
return send_from_directory(os.path.join(config.DB_ROOT, cover_path), "cover.jpg")
|
||||
def feed_get_cover(book_id):
|
||||
book = db.session.query(db.Books).filter(db.Books.id == book_id).first()
|
||||
return send_from_directory(os.path.join(config.DB_ROOT, book.path), "cover.jpg")
|
||||
|
||||
|
||||
@app.route("/read/<int:book_id>/<format>")
|
||||
|
Loading…
Reference in New Issue
Block a user