From e5bc1ae020148cc61ed0d94555b7cc950c895103 Mon Sep 17 00:00:00 2001 From: Virgil Grigoras Date: Mon, 25 Feb 2019 19:21:49 +0100 Subject: [PATCH 1/6] Add new database field for storing max_authors --- cps/ub.py | 8 ++++++++ cps/web.py | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cps/ub.py b/cps/ub.py index f1f8f02d..80ac641e 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -315,6 +315,7 @@ class Settings(Base): config_calibre_web_title = Column(String, default=u'Calibre-Web') config_books_per_page = Column(Integer, default=60) config_random_books = Column(Integer, default=4) + config_authors_max = Column(Integer, default=5) config_read_column = Column(Integer, default=0) config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+') config_log_level = Column(SmallInteger, default=logging.INFO) @@ -380,6 +381,7 @@ class Config: self.config_calibre_web_title = data.config_calibre_web_title self.config_books_per_page = data.config_books_per_page self.config_random_books = data.config_random_books + self.config_authors_max = data.config_authors_max self.config_title_regex = data.config_title_regex self.config_read_column = data.config_read_column self.config_log_level = data.config_log_level @@ -601,6 +603,12 @@ def migrate_Database(): conn = engine.connect() conn.execute("ALTER TABLE Settings ADD column `config_default_role` SmallInteger DEFAULT 0") session.commit() + try: + session.query(exists().where(Settings.config_authors_max)).scalar() + except exc.OperationalError: # Database is not compatible, some rows are missing + conn = engine.connect() + conn.execute("ALTER TABLE Settings ADD column `config_authors_max` INTEGER DEFAULT 5") + session.commit() try: session.query(exists().where(BookShelf.order)).scalar() except exc.OperationalError: # Database is not compatible, some rows are missing diff --git a/cps/web.py b/cps/web.py index 2aeb78ad..5db967ad 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1207,7 +1207,7 @@ def get_updater_status(): def index(page): entries, random, pagination = fill_indexpage(page, db.Books, True, [db.Books.timestamp.desc()]) return render_title_template('index.html', random=random, entries=entries, pagination=pagination, - title=_(u"Recently Added Books"), page="root") + title=_(u"Recently Added Books"), page="root", config_authors_max=config.config_authors_max) @app.route('/books/newest', defaults={'page': 1}) @@ -1351,7 +1351,8 @@ def author(book_id, page): app.logger.error('Goodreads website is down/inaccessible') return render_title_template('author.html', entries=entries, pagination=pagination, - title=name, author=author_info, other_books=other_books, page="author") + title=name, author=author_info, other_books=other_books, page="author", + config_authors_max=config.config_authors_max) @app.route("/publisher") @@ -2817,6 +2818,9 @@ def view_configuration(): content.config_random_books = int(to_save["config_random_books"]) if "config_books_per_page" in to_save: content.config_books_per_page = int(to_save["config_books_per_page"]) + # maximum authors to show before we display a 'show more' link + if "config_authors_max" in to_save: + content.config_authors_max = int(to_save["config_authors_max"]) # Mature Content configuration if "config_mature_content_tags" in to_save: content.config_mature_content_tags = to_save["config_mature_content_tags"].strip() From d3ed0317bbbe180bd9be5427c857577088e1a46a Mon Sep 17 00:00:00 2001 From: Virgil Grigoras Date: Mon, 25 Feb 2019 19:25:08 +0100 Subject: [PATCH 2/6] styling and javascript for hiding authors --- cps/static/css/style.css | 6 ++++++ cps/static/js/main.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 9e2e82b3..e75457e3 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -36,6 +36,11 @@ a{color: #45b29d}a:hover{color: #444;} .container-fluid .book .meta .title{font-weight:bold;font-size:15px;color:#444} .container-fluid .book .meta .author{font-size:12px;color:#999} .container-fluid .book .meta .rating{margin-top:5px}.rating .glyphicon-star{color:#999}.rating .glyphicon-star.good{color:#45b29d} + +.container-fluid .author .author-hidden, .container-fluid .author .author-hidden-divider { + display: none; +} + .navbar-brand{font-family: 'Grand Hotel', cursive; font-size: 35px; color: #45b29d !important;} .more-stuff{margin-top: 20px; padding-top: 20px; border-top: 1px solid #ccc} .more-stuff>li{margin-bottom: 10px;} @@ -52,6 +57,7 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te -moz-box-shadow: 0 5px 8px -6px #777; box-shadow: 0 5px 8px -6px #777; } + .navbar-default .navbar-toggle .icon-bar {background-color: #000;} .navbar-default .navbar-toggle {border-color: #000;} .cover { margin-bottom: 10px;} diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 7cd07e18..0893a905 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -204,4 +204,12 @@ $(function() { $(window).resize(function() { $(".discover .row").isotope("layout"); }); + + $(".author-expand").click(function() { + $(this).parent().find('a.author-name').slice($(this).data("authors-max")).toggle(); + $(this).parent().find('span.author-hidden-divider').toggle(); + $(this).html()==$(this).data("collapse-caption")? $(this).html('(...)'):$(this).html($(this).data("collapse-caption")); + $(".discover .row").isotope("layout"); + }); + }); From 3272b4ca1ed4083827365741d65e810e4ce0efbc Mon Sep 17 00:00:00 2001 From: Virgil Grigoras Date: Mon, 25 Feb 2019 19:26:43 +0100 Subject: [PATCH 3/6] configuration field for max_authors --- cps/templates/config_view_edit.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index 3b8ebf80..83c20834 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -27,6 +27,10 @@ +
+ + +