Disable bookmarking when anonymous users are reading
This commit is contained in:
parent
0512e5a940
commit
56c71dd4bf
3 changed files with 12 additions and 4 deletions
|
@ -10,8 +10,13 @@
|
||||||
restore: true,
|
restore: true,
|
||||||
bookmarks: calibre.bookmark ? [calibre.bookmark] : []
|
bookmarks: calibre.bookmark ? [calibre.bookmark] : []
|
||||||
});
|
});
|
||||||
reader.on("reader:bookmarked", updateBookmark.bind(reader, "add"));
|
|
||||||
reader.on("reader:unbookmarked", updateBookmark.bind(reader, "remove"));
|
if (calibre.useBookmarks) {
|
||||||
|
reader.on("reader:bookmarked", updateBookmark.bind(reader, "add"));
|
||||||
|
reader.on("reader:unbookmarked", updateBookmark.bind(reader, "remove"));
|
||||||
|
} else {
|
||||||
|
$("#bookmark, #show-Bookmarks").remove();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} action - Add or remove bookmark
|
* @param {string} action - Add or remove bookmark
|
||||||
|
|
|
@ -83,7 +83,8 @@
|
||||||
cssPath: "{{ url_for('static', filename='css/') }}",
|
cssPath: "{{ url_for('static', filename='css/') }}",
|
||||||
bookUrl: "{{ url_for('static', filename=bookid) }}/",
|
bookUrl: "{{ url_for('static', filename=bookid) }}/",
|
||||||
bookmarkUrl: "{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}",
|
bookmarkUrl: "{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}",
|
||||||
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}"
|
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
|
||||||
|
useBookmarks: {{ g.user.is_authenticated | tojson }}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script>
|
||||||
|
|
|
@ -1779,7 +1779,9 @@ def read_book(book_id, book_format):
|
||||||
book_dir = os.path.join(config.get_main_dir, "cps", "static", str(book_id))
|
book_dir = os.path.join(config.get_main_dir, "cps", "static", str(book_id))
|
||||||
if not os.path.exists(book_dir):
|
if not os.path.exists(book_dir):
|
||||||
os.mkdir(book_dir)
|
os.mkdir(book_dir)
|
||||||
bookmark = ub.session.query(ub.Bookmark).filter(ub.and_(ub.Bookmark.user_id == int(current_user.id),
|
bookmark = None
|
||||||
|
if current_user.is_authenticated:
|
||||||
|
bookmark = ub.session.query(ub.Bookmark).filter(ub.and_(ub.Bookmark.user_id == int(current_user.id),
|
||||||
ub.Bookmark.book_id == book_id,
|
ub.Bookmark.book_id == book_id,
|
||||||
ub.Bookmark.format == book_format.upper())).first()
|
ub.Bookmark.format == book_format.upper())).first()
|
||||||
if book_format.lower() == "epub":
|
if book_format.lower() == "epub":
|
||||||
|
|
Loading…
Reference in a new issue