OPDS Marvin (and Marvin 3) now really work (#79)

OPDS should now also work with reverse proxy configuration
Changed readme (reverse proxy configuration)
No progress for calibre companion
pull/92/head
OzzieIsaacs 8 years ago
parent a16321179d
commit c13a2a4557

@ -30,7 +30,6 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<!-- <p><a href="{{ url_for('edit_book', book_id=entry.id) }}">{{entry.authors[0].name}}: {{entry.title}}</a></p> -->
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

@ -475,7 +475,7 @@ def feed_new():
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
len(db.session.query(db.Books).filter(filter).all())) len(db.session.query(db.Books).filter(filter).all()))
xml = render_template('feed.xml', entries=entries, pagination=pagination, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/new?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_new")+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -494,7 +494,7 @@ def feed_discover():
entries = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.NEWEST_BOOKS) 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)) pagination = Pagination(1, config.NEWEST_BOOKS,int(config.NEWEST_BOOKS))
xml = render_template('feed.xml', entries=entries, pagination=pagination, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/discover") next_url=url_for("feed_discover"))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -515,7 +515,7 @@ def feed_hot():
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, 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())) 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, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/hot?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_hot")+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -536,7 +536,7 @@ def feed_authorindex():
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
len(db.session.query(db.Authors).all())) len(db.session.query(db.Authors).all()))
xml = render_template('feed.xml', authors=authors, pagination=pagination, xml = render_template('feed.xml', authors=authors, pagination=pagination,
next_url="/opds/author?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_authorindex")+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -557,7 +557,7 @@ def feed_author(name):
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, 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())) 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, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/author?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_author",name=name)+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -573,7 +573,7 @@ def feed_categoryindex():
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
len(db.session.query(db.Tags).all())) len(db.session.query(db.Tags).all()))
xml = render_template('feed.xml', categorys=entries, pagination=pagination, xml = render_template('feed.xml', categorys=entries, pagination=pagination,
next_url="/opds/category?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_categoryindex")+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -594,7 +594,7 @@ def feed_category(name):
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, 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())) 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, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/category?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_category",name=name)+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -614,7 +614,7 @@ def feed_seriesindex():
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS,
len(db.session.query(db.Series).all())) len(db.session.query(db.Series).all()))
xml = render_template('feed.xml', series=entries, pagination=pagination, xml = render_template('feed.xml', series=entries, pagination=pagination,
next_url="/opds/series?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_seriesindex")+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -635,7 +635,7 @@ def feed_series(name):
pagination = Pagination((int(off)/(int(config.NEWEST_BOOKS))+1), config.NEWEST_BOOKS, 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())) 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, xml = render_template('feed.xml', entries=entries, pagination=pagination,
next_url="/opds/series?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off))) next_url=url_for("feed_series",name=name)+"?start_index=%d" % (int(config.NEWEST_BOOKS) + int(off)))
response = make_response(xml) response = make_response(xml)
response.headers["Content-Type"] = "application/xml" response.headers["Content-Type"] = "application/xml"
return response return response
@ -1265,7 +1265,7 @@ def remove_from_shelf(shelf_id, book_id):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
if not shelf.is_public and not shelf.user_id == int(current_user.id): if not shelf.is_public and not shelf.user_id == int(current_user.id):
flash("Sorry you are not allowed to remove a book from this shelf: %s" % shelf.name) flash("Sorry you are not allowed to remove a book from this shelf: %s" % shelf.name)
return redirect(url_for('index', _external=True)) return redirect(url_for('index'))
book_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id, book_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id,
ub.BookShelf.book_id == book_id).first() ub.BookShelf.book_id == book_id).first()
@ -1528,7 +1528,7 @@ def new_user():
ub.session.add(content) ub.session.add(content)
ub.session.commit() ub.session.commit()
flash(_("User '%(user)s' created", user=content.nickname), category="success") flash(_("User '%(user)s' created", user=content.nickname), category="success")
return redirect(url_for('admin', _external=True)) return redirect(url_for('admin'))
except IntegrityError: except IntegrityError:
ub.session.rollback() ub.session.rollback()
flash(_(u"Found an existing account for this email address or nickname."), category="error") flash(_(u"Found an existing account for this email address or nickname."), category="error")
@ -1588,7 +1588,7 @@ def edit_user(user_id):
if "delete" in to_save: if "delete" in to_save:
ub.session.delete(content) ub.session.delete(content)
flash(_(u"User '%(nick)s' deleted", nick=content.nickname), category="success") flash(_(u"User '%(nick)s' deleted", nick=content.nickname), category="success")
return redirect(url_for('admin', _external=True)) return redirect(url_for('admin'))
else: else:
if to_save["password"]: if to_save["password"]:
content.password = generate_password_hash(to_save["password"]) content.password = generate_password_hash(to_save["password"])
@ -1849,14 +1849,14 @@ def edit_book(book_id):
for b in edited_books_id: for b in edited_books_id:
helper.update_dir_stucture(b) helper.update_dir_stucture(b)
if "detail_view" in to_save: if "detail_view" in to_save:
return redirect(url_for('show_book', id=book.id, _external=True)) return redirect(url_for('show_book', id=book.id))
else: else:
return render_template('edit_book.html', book=book, authors=author_names, cc=cc) return render_template('edit_book.html', book=book, authors=author_names, cc=cc)
else: else:
return render_template('edit_book.html', book=book, authors=author_names, cc=cc) return render_template('edit_book.html', book=book, authors=author_names, cc=cc)
else: else:
flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error")
return redirect(url_for("index", _external=True)) return redirect(url_for("index"))
@app.route("/upload", methods=["GET", "POST"]) @app.route("/upload", methods=["GET", "POST"])
@ -1886,12 +1886,12 @@ def upload():
os.makedirs(filepath) os.makedirs(filepath)
except OSError: except OSError:
flash(_(u"Failed to create path %s (Permission denied)." % filepath), category="error") flash(_(u"Failed to create path %s (Permission denied)." % filepath), category="error")
return redirect(url_for('index', _external=True)) return redirect(url_for('index'))
try: try:
copyfile(meta.file_path, saved_filename) copyfile(meta.file_path, saved_filename)
except OSError, e: except OSError, e:
flash(_(u"Failed to store file %s (Permission denied)." % saved_filename), category="error") flash(_(u"Failed to store file %s (Permission denied)." % saved_filename), category="error")
return redirect(url_for('index', _external=True)) return redirect(url_for('index'))
try: try:
os.unlink(meta.file_path) os.unlink(meta.file_path)
except OSError, e: except OSError, e:

@ -81,7 +81,7 @@ http {
Apache 2.4 configuration for a local server listening on port 443, mapping calibre web to /calibre-web: Apache 2.4 configuration for a local server listening on port 443, mapping calibre web to /calibre-web:
The following modules have to be activated: headers, proxy, proxy_html, proxy_http, rewrite, xml2enc. The following modules have to be activated: headers, proxy, rewrite.
``` ```
Listen 443 Listen 443
@ -92,12 +92,11 @@ Listen 443
SSLCertificateFile "C:\Apache24\conf\ssl\test.crt" SSLCertificateFile "C:\Apache24\conf\ssl\test.crt"
SSLCertificateKeyFile "C:\Apache24\conf\ssl\test.key" SSLCertificateKeyFile "C:\Apache24\conf\ssl\test.key"
<Location /calibre-web> <Location "/calibre-web" >
ProxyHTMLEnable On RequestHeader set X-SCRIPT-NAME /calibre-web
ProxyPass http://127.0.0.1:8083/ RequestHeader set X-SCHEME https
ProxyPassReverse http://127.0.0.1:8083/ ProxyPass http://localhost:8083/
Header edit Location "^http://(.*?)/" "https://$1/calibre-web/" ProxyPassReverse http://localhost:8083/
ProxyHTMLURLMap / /calibre-web/
</Location> </Location>
</VirtualHost> </VirtualHost>
``` ```

Loading…
Cancel
Save