1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 09:30:31 +00:00

Bugfix for visibility opds feed

This commit is contained in:
Ozzie Isaacs 2024-05-07 08:27:55 +02:00
parent 737d758362
commit cb62d36e44
2 changed files with 29 additions and 5 deletions

View File

@ -24,7 +24,7 @@ import datetime
import json
from urllib.parse import unquote_plus
from flask import Blueprint, request, render_template, make_response, abort, Response
from flask import Blueprint, request, render_template, make_response, abort, Response, g
from flask_login import current_user
from flask_babel import get_locale
from flask_babel import gettext as _
@ -117,7 +117,7 @@ def feed_discover():
@opds.route("/opds/rated")
@requires_basic_auth_if_no_ano
def feed_best_rated():
if not current_user.check_visibility(constants.SIDEBAR_RATED):
if not current_user.check_visibility(constants.SIDEBAR_BEST_RATED):
abort(404)
off = request.args.get("offset") or 0
entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
@ -384,6 +384,7 @@ def feed_shelfindex():
def feed_shelf(book_id):
if not (current_user.is_authenticated or g.allow_anonymous):
abort(404)
off = request.args.get("offset") or 0
if current_user.is_anonymous:
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1,
ub.Shelf.id == book_id).first()

View File

@ -22,6 +22,7 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books sorted alphabetically')}}</content>
</entry>
{% if current_user.check_visibility(g.constants.SIDEBAR_DOWNLOAD) and (not current_user.is_anonymous) %}
<entry>
<title>{{_('Hot Books')}}</title>
<link href="{{url_for('opds.feed_hot')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -29,6 +30,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Popular publications from this catalog based on Downloads.')}}</content>
</entry>
{%endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_BEST_RATED) %}
<entry>
<title>{{_('Top Rated Books')}}</title>
<link href="{{url_for('opds.feed_best_rated')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -36,6 +39,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Popular publications from this catalog based on Rating.')}}</content>
</entry>
{%endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_RECENT) %}
<entry>
<title>{{_('Recently added Books')}}</title>
<link href="{{url_for('opds.feed_new')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -43,6 +48,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('The latest Books')}}</content>
</entry>
{%endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_RANDOM) %}
<entry>
<title>{{_('Random Books')}}</title>
<link href="{{url_for('opds.feed_discover')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -50,7 +57,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Show Random Books')}}</content>
</entry>
{% if not current_user.is_anonymous %}
{%endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_READ_AND_UNREAD) and not current_user.is_anonymous %}
<entry>
<title>{{_('Read Books')}}</title>
<link href="{{url_for('opds.feed_read_books')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -66,6 +74,7 @@
<content type="text">{{_('Unread Books')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_AUTHOR) %}
<entry>
<title>{{_('Authors')}}</title>
<link href="{{url_for('opds.feed_authorindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -73,6 +82,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by Author')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_PUBLISHER) %}
<entry>
<title>{{_('Publishers')}}</title>
<link href="{{url_for('opds.feed_publisherindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -80,6 +91,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by publisher')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_CATEGORY) %}
<entry>
<title>{{_('Categories')}}</title>
<link href="{{url_for('opds.feed_categoryindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -87,6 +100,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by category')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_SERIES) %}
<entry>
<title>{{_('Series')}}</title>
<link href="{{url_for('opds.feed_seriesindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -94,6 +109,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by series')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_LANGUAGE) %}
<entry>
<title>{{_('Languages')}}</title>
<link href="{{url_for('opds.feed_languagesindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -101,6 +118,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by Languages')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_RATING) %}
<entry>
<title>{{_('Ratings')}}</title>
<link href="{{url_for('opds.feed_ratingindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -108,7 +127,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by Rating')}}</content>
</entry>
{% endif %}
{% if current_user.check_visibility(g.constants.SIDEBAR_FORMAT) %}
<entry>
<title>{{_('File formats')}}</title>
<link href="{{url_for('opds.feed_formatindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -116,6 +136,8 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books ordered by file formats')}}</content>
</entry>
{% endif %}
{% if current_user.is_authenticated or g.allow_anonymous %}
<entry>
<title>{{_('Shelves')}}</title>
<link href="{{url_for('opds.feed_shelfindex')}}" type="application/atom+xml;profile=opds-catalog"/>
@ -123,4 +145,5 @@
<updated>{{ current_time }}</updated>
<content type="text">{{_('Books organized in shelves')}}</content>
</entry>
{% endif %}
</feed>