1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-11-27 04:05:13 +00:00

Save ePub bookmarks to database

Save ePub bookmark to database. Also use library's built-in restore feature to restore all information from localStorage.
This commit is contained in:
Jonathan Rehm
2017-08-23 08:52:52 -07:00
parent 193605df4a
commit 374b5f4c6e
4 changed files with 133 additions and 96 deletions

View File

@@ -212,15 +212,26 @@ class BookShelf(Base):
def __repr__(self):
return '<Book %r>' % self.id
class ReadBook(Base):
__tablename__ = 'book_read_link'
id=Column(Integer, primary_key=True)
id = Column(Integer, primary_key=True)
book_id = Column(Integer, unique=False)
user_id =Column(Integer, ForeignKey('user.id'), unique=False)
user_id = Column(Integer, ForeignKey('user.id'), unique=False)
is_read = Column(Boolean, unique=False)
class Bookmark(Base):
__tablename__ = 'bookmark'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('user.id'))
book_id = Column(Integer)
format = Column(String(collation='NOCASE'))
bookmark_key = Column(String)
# Baseclass representing Downloads from calibre-web in app.db
class Downloads(Base):
__tablename__ = 'downloads'
@@ -396,7 +407,9 @@ class Config:
# rows with SQL commands
def migrate_Database():
if not engine.dialect.has_table(engine.connect(), "book_read_link"):
ReadBook.__table__.create(bind = engine)
ReadBook.__table__.create(bind=engine)
if not engine.dialect.has_table(engine.connect(), "bookmark"):
Bookmark.__table__.create(bind=engine)
try:
session.query(exists().where(User.locale)).scalar()