From 22494aadd27c097c1ef207848b05e68ad0a18ecb Mon Sep 17 00:00:00 2001 From: nberting Date: Sun, 10 Jun 2018 11:16:47 +0200 Subject: [PATCH 1/3] styling buttons --- app/static/css/style.css | 10 +++++----- app/templates/show_book_detail.html | 18 ++++++++++-------- app/views.py | 2 ++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index 2ea3389..a7f6bbf 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -385,21 +385,21 @@ box-sizing: border-box; height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ - background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + background-color: rgba(0,0,0,0.5); /* Black w/ opacity */ } /* Modal Content/Box */ .modal-content { - background-color: #fefefe; + background-color: yellow; margin: 15% auto; /* 15% from the top and centered */ - padding: 20px; + padding: 15px; border: 1px solid #888; width: 40%; /* Could be more or less, depending on screen size */ } /* The Close Button */ .close { - color: red; + color: grey; float: right; font-size: 28px; font-weight: bold; @@ -407,7 +407,7 @@ box-sizing: border-box; .close:hover, .close:focus { - color: black; + color: red; text-decoration: none; cursor: pointer; } diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 79252d3..ea6b6b9 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -21,18 +21,20 @@ {% endfor %}

- - - - +{% if book.file %} + + "{{book.message or 'Happy reading.'}}"
+

>>>> Link to file <<<<

+ +{% else %} +{% endif %} + + + diff --git a/app/views.py b/app/views.py index 199b264..27cb5fa 100755 --- a/app/views.py +++ b/app/views.py @@ -141,12 +141,14 @@ def edit_book_by_id(id): input_authors = user_form.author.data category = user_form.category.data year_published = user_form.year_published.data + message = user_form.message.data if year_published=="": year_published = None book = Book.query.filter_by(id=id).first() book.title = title book.category = category book.year_published = year_published + book.message = message #authors update book.authors.clear() From b8a6c86a13502c961e60a217077a15cff3c408ce Mon Sep 17 00:00:00 2001 From: nberting Date: Sun, 10 Jun 2018 12:29:09 +0200 Subject: [PATCH 2/3] reverse query results and some new links on show_book_detail --- app/templates/results.html | 5 +++-- app/templates/results_grid.html | 5 ++--- app/templates/show_book_detail.html | 7 ++++++- app/views.py | 24 ++++++++++++++++++------ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/app/templates/results.html b/app/templates/results.html index 8e88967..296dc8e 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -31,7 +31,7 @@ {% endif %} {% endwith %} - +
@@ -68,9 +68,10 @@
+
-

Other books

+

More books

diff --git a/app/templates/results_grid.html b/app/templates/results_grid.html index d043c4a..228f7db 100644 --- a/app/templates/results_grid.html +++ b/app/templates/results_grid.html @@ -30,7 +30,7 @@ {% endif %} {% endwith %} -
+
{% for book in books|sort(attribute='title', reverse = False) %} @@ -52,9 +52,8 @@ {% endfor %}
-
-

Other books

+

More books

diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index ea6b6b9..e7a0e77 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -35,7 +35,12 @@ - +

+
+{% if previousbook %} + < see the previous book added to XPPL:  {{ previousbook.title |truncate(40,True,'...') }} {% endif %} +{% if nextbook %} + see the next book added to XPPL:  {{ nextbook.title|truncate(40,True,'...')}} > {% endif %}
{% endblock %} diff --git a/app/views.py b/app/views.py index 27cb5fa..2a97058 100755 --- a/app/views.py +++ b/app/views.py @@ -9,6 +9,7 @@ from app import app, db, socketio, DOMAIN from flask import Flask, Response, render_template, request, redirect, url_for, flash, send_from_directory, jsonify, abort import json from sqlalchemy.sql.expression import func, select +from sqlalchemy.sql import except_ from app.forms import UploadForm, EditForm, SearchForm, ChatForm, StackForm, AddtoStackForm, EditStackForm from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema, Potential from app.cover import get_cover @@ -105,6 +106,15 @@ def show_books_grid(): @app.route('/books/') def show_book_by_id(id): book = Book.query.get(id) + previousbook = Book.query.filter_by(id=id - 1).first() + nextbook = Book.query.filter_by(id=id + 1).first() + allbooks = db.session.query(Book).all() + edge = len(allbooks) + if id == 1: + previousbook = None + if id == edge: + nextbook = None + userin = UserIns.query.filter_by(title="lastViewed").first() if userin != None: userin.info = book.title @@ -116,7 +126,7 @@ def show_book_by_id(id): if not book: return render_template('red_link.html', id=id) else: - return render_template('show_book_detail.html', book=book) + return render_template('show_book_detail.html', book=book, previousbook = previousbook, nextbook = nextbook) @app.route('/books//delete', methods=['POST', 'GET']) @@ -399,8 +409,8 @@ def show_books(): @app.route('/search///', methods=['POST', 'GET']) def search_results(searchtype, query, viewby): search = SearchForm(request.form, search=query) - random_order=Book.query.all() results=Book.query.filter(Book.title.contains(query)).order_by(Book.title) + allbooks = set(Book.query.all()) viewby = view[-1] if searchtype == 'Title': @@ -432,14 +442,16 @@ def search_results(searchtype, query, viewby): count = results.count() whole = Book.query.count() percentage = float(count / whole * 100) + fbooks = set(results) + books_all = allbooks - fbooks if search.listview.data: view.append('1') - return render_template('results.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage) + return render_template('results.html', books=results, form=search, query=query, books_all=books_all, searchtype=search.select.data, count = count, whole = whole, percentage = percentage) if search.grid.data: view.append('2') - return render_template('results_grid.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage) + return render_template('results_grid.html', books=results, form=search, query=query, books_all=books_all, searchtype=search.select.data, count = count, whole = whole, percentage = percentage) if request.method == 'POST': newmsg = 'searched for: ' + search.search.data @@ -464,10 +476,10 @@ def search_results(searchtype, query, viewby): return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby))) if viewby == '2': - return render_template('results_grid.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage) + return render_template('results_grid.html', form=search, books=results, books_all=books_all, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage) else: - return render_template('results.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage) + return render_template('results.html', form=search, books=results, books_all=books_all, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage) # ## Search - autocomplete From 93bf8a6b938f9a054c4bf39ef717c7d20d7cfdca Mon Sep 17 00:00:00 2001 From: nberting Date: Sun, 10 Jun 2018 17:41:44 +0200 Subject: [PATCH 3/3] extended info on add-book page --- app/static/css/style.css | 3 ++ app/templates/add_book.html | 48 +++++++++++++++++++++++++---- app/templates/show_book_detail.html | 39 +++++++++++++++++------ app/views.py | 13 +++++++- 4 files changed, 86 insertions(+), 17 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index a7f6bbf..6db020c 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -83,6 +83,9 @@ border-spacing:0; /* Removes the cell spacing via CSS */ font-size: 20px; cursor: pointer; } +.library_table td{ +padding: 5px; +} th.headerSortUp{ background-color: #E8E8E8!important; diff --git a/app/templates/add_book.html b/app/templates/add_book.html index 35c5c6b..cf5dac6 100755 --- a/app/templates/add_book.html +++ b/app/templates/add_book.html @@ -1,7 +1,9 @@ {% extends 'base.html' %} {% block main %} -
+
+
+

Add Book

{% with messages = get_flashed_messages() %} {% if messages %} @@ -33,25 +35,59 @@ {% endfor %}
-
-
Category: {{ form.category(size=27, class="form-control") }}

Year published: {{ form.year_published(size=8, class="form-control") }}

-
- Add a message for future readers: {{ form.message(size=150, class="form-control") }} +
+ Add a message for future readers: {{ form.message(size=90, class="form-control") }}

{{ form.file }} {{ form.upload }} {{ form.wish }}
- +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Titles: {{ books_all }}
Authors: {{ authors_all }}
Categories: {{ categories|replace('[', '')|replace(']', '') }}
Stacks: {{ stacks_all|replace('[', '')|replace(']', '') }}
From the years: {{earliest}} –– {{latest}}
Gaps in the collection: At least {{ books_potential }} potential books missing
+
{% endblock %} diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index e7a0e77..19e8c64 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -5,21 +5,40 @@

{{ book.title }}

-

Year published: {{ book.year_published }}

-

Author(s):