From 1ac9b3d837dffa0dbc4b67a4e2b772e83441b6be Mon Sep 17 00:00:00 2001 From: Virgil Grigoras Date: Sun, 30 Sep 2018 18:48:36 +0200 Subject: [PATCH] Update OPDS-part to display publishers --- cps/templates/feed.xml | 3 +++ cps/templates/index.xml | 9 ++++++++- cps/web.py | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cps/templates/feed.xml b/cps/templates/feed.xml index 9454187b..82e92416 100644 --- a/cps/templates/feed.xml +++ b/cps/templates/feed.xml @@ -43,6 +43,9 @@ {{entry.authors[0].name}} + + {{entry.publishers[0].name}} + {{entry.language}} {% for tag in entry.tags %} {{url_for('feed_authorindex')}} {{ current_time }} {{_('Books ordered by Author')}} - + + + {{_('Publishers')}} + + {{url_for('feed_publisherindex')}} + {{ current_time }} + {{_('Books ordered by publisher')}} + {{_('Category list')}} diff --git a/cps/web.py b/cps/web.py index 0f359fd6..4a397083 100644 --- a/cps/web.py +++ b/cps/web.py @@ -752,6 +752,26 @@ def feed_author(book_id): return render_xml_template('feed.xml', entries=entries, pagination=pagination) +@app.route("/opds/publisher") +@requires_basic_auth_if_no_ano +def feed_publisherindex(): + off = request.args.get("offset") or 0 + entries = db.session.query(db.Publishers).join(db.books_publishers_link).join(db.Books).filter(common_filters())\ + .group_by('books_publishers_link.publisher').order_by(db.Publishers.sort).limit(config.config_books_per_page).offset(off) + pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, + len(db.session.query(db.Publishers).all())) + return render_xml_template('feed.xml', listelements=entries, folder='feed_publisher', pagination=pagination) + + +@app.route("/opds/publisher/") +@requires_basic_auth_if_no_ano +def feed_publisher(book_id): + off = request.args.get("offset") or 0 + entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), + db.Books, db.Books.publishers.any(db.Publishers.id == book_id), [db.Books.timestamp.desc()]) + return render_xml_template('feed.xml', entries=entries, pagination=pagination) + + @app.route("/opds/category") @requires_basic_auth_if_no_ano def feed_categoryindex():