From c6b99974dad14b90caa19eb93056b5350ed02db9 Mon Sep 17 00:00:00 2001 From: nberting Date: Thu, 7 Jun 2018 19:10:56 +0200 Subject: [PATCH] new default covers and grid view in search --- app/forms.py | 3 + app/static/css/style.css | 36 +++++++++++ app/static/img/default_cover.gif | Bin 0 -> 14473 bytes app/templates/add_to_stacks.html | 2 +- app/templates/edit_book_detail.html | 2 +- app/templates/results.html | 34 ++++++----- app/templates/results_grid.html | 89 ++++++++++++++++++++++++++++ app/templates/show_book_detail.html | 2 +- app/templates/show_books.html | 20 ++++--- app/templates/show_books_grid.html | 41 ++++++++----- app/views.py | 24 ++++++-- 11 files changed, 204 insertions(+), 49 deletions(-) create mode 100644 app/static/img/default_cover.gif create mode 100644 app/templates/results_grid.html diff --git a/app/forms.py b/app/forms.py index 0e5e25f..81508e1 100755 --- a/app/forms.py +++ b/app/forms.py @@ -51,4 +51,7 @@ class SearchForm(FlaskForm): ('Stack', 'Stack')] select = SelectField('', choices=choices) search = StringField('', validators=[InputRequired()]) + grid = SubmitField('Grid') + listview = SubmitField('List') + diff --git a/app/static/css/style.css b/app/static/css/style.css index a39c5b2..b72808f 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -313,3 +313,39 @@ box-sizing: border-box; height: 100%; border: none; } + +.grid { + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr; + grid-gap: 2px; + align-items: top; + justify-items: center; +} + +@media screen and (max-width: 900px) { +.grid{ + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-gap: 2px; + align-items: center; + justify-items: center; +} +} +@media screen and (max-width: 400px) { +.grid{ + display: grid; + grid-template-columns: 1fr; + align-items: center; + justify-items: center; +} +} + +.gridbox { + display: inline-block; + padding-left: 5px; + align-items: center; + justify-items: center; +} +.gridbox:hover{ + opacity: 0.5; +} \ No newline at end of file diff --git a/app/static/img/default_cover.gif b/app/static/img/default_cover.gif new file mode 100644 index 0000000000000000000000000000000000000000..500390cbbb1928bb76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Xd_DLddlBz%KBvRyZ$9U5KId;f=Wjme bZ$9U5KId;f=WjmeZ$9U5KIeZopCkNVFY5BI literal 0 HcmV?d00001 diff --git a/app/templates/add_to_stacks.html b/app/templates/add_to_stacks.html index c2ed248..2e7ab09 100644 --- a/app/templates/add_to_stacks.html +++ b/app/templates/add_to_stacks.html @@ -6,7 +6,7 @@
Chosen book:

{{ book.title }}

- +

These are all the stacks that have been built so far.

diff --git a/app/templates/edit_book_detail.html b/app/templates/edit_book_detail.html index 094aee6..4299e95 100755 --- a/app/templates/edit_book_detail.html +++ b/app/templates/edit_book_detail.html @@ -12,7 +12,7 @@

{{ form.title.label }} {{ form.title(size=20, class="form-control") }}

- +

diff --git a/app/templates/results.html b/app/templates/results.html index 1ee29ef..54f4546 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -1,19 +1,20 @@ {% extends 'base.html' %} {% block main %} -
-
{% from "_formhelpers.html" import render_field %}
{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}
-
+


+ {{ form.grid(style="font-size:20px")}}{{ form.listview(style="font-size:20px")}}

+
+
-

Results: "{{ query }}" included in {{ count }} out of {{ whole }} items

+

Results: "{{ query }}" included in {{ count }} out of {{ whole }} items

@@ -34,16 +35,17 @@ Cover Title - Author - Filetype - Category - Stack - Add to stack + Author + Filetype + Category + Stack + Add to stack {% for book in books %} - + + {{ book.title }} {% for author in book.authors %} @@ -75,16 +77,16 @@ Cover Title - Author - Filetype - Category - Stack - Add to stack + Author + Filetype + Category + Stack + Add to stack {% for book in books_all %} - + {{ book.title }} {% for author in book.authors %} diff --git a/app/templates/results_grid.html b/app/templates/results_grid.html new file mode 100644 index 0000000..cea341b --- /dev/null +++ b/app/templates/results_grid.html @@ -0,0 +1,89 @@ +{% extends 'base.html' %} + +{% block main %} +
+ {% from "_formhelpers.html" import render_field %} +
+
{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}
+ + +


+ {{ form.grid(style="font-size:20px")}}{{ form.listview(style="font-size:20px")}}

+
+
+ +
+

Results: "{{ query }}" included in {{ count }} out of {{ whole }} items

+
+
+
+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+
+ {% endif %} + {% endwith %} +
+ + {% for book in books|sort(attribute='title', reverse = False) %} + + +
+ + +

+ + +{{ book.title }} +
+ +{% for author in book.authors %} +{{ author.author_name }}
{% endfor %}
+ +

+
+ {% endfor %} +
+ + +
+
+

Other books

+ +
+ +{% for book in books_all|sort(attribute='title', reverse = False) %} + +
+ + +

+ + +{{ book.title }} +
+ +{% for author in book.authors %} +{{ author.author_name }}
{% endfor %}
+ +

+
+ {% endfor %} +
+
+ + +

+ See all books +

+ +
+ +{% endblock %} diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 42cd67d..a6ab30f 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -4,7 +4,7 @@

{{ book.title }}

- +

Author(s):

    {% for author in book.authors %}
  • {{ author.author_name }}
  • diff --git a/app/templates/show_books.html b/app/templates/show_books.html index 5f8e7b9..258c0e6 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -8,7 +8,9 @@ - +


    + {{ form.grid(style="font-size:20px")}}{{ form.listview(style="font-size:20px")}}

    +

    All Books

    {% with messages = get_flashed_messages() %} @@ -28,19 +30,19 @@ Cover Title - Author - Filetype - Category - Stack - Add to stack + Author + Filetype + Category + Stack + Add to stack {% for book in books|sort(attribute='title', reverse = False) %} - + - + +
    + + +

    + + +{{ book.title }} +
    + +{% for author in book.authors %} +{{ author.author_name }}
    {% endfor %}
    + +

    +
    {% endfor %} - +
{% endblock %} diff --git a/app/views.py b/app/views.py index 58edf45..e152071 100755 --- a/app/views.py +++ b/app/views.py @@ -342,6 +342,11 @@ def edit_stack_by_id(id): def show_books(): books = db.session.query(Book).all() search = SearchForm(request.form) + + if search.grid.data: + return render_template ('show_books_grid.html', books=books, form=search) + if search.listview.data: + return render_template ('show_books.html', books=books, form=search) if request.method == 'POST': return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data))) @@ -349,8 +354,8 @@ def show_books(): @app.route('/search///', methods=['POST', 'GET']) def search_results(searchtype, query): - search = SearchForm(request.form) - random_order=Book.query.order_by(func.random()).limit(10) + search = SearchForm(request.form, search=query) + random_order=Book.query.order_by(func.random()).limit(14) results=Book.query.filter(Book.title.contains(query)) if searchtype == 'Title': @@ -376,14 +381,21 @@ def search_results(searchtype, query): upload_form = UploadForm(title= query, author='') return render_template('red_link.html', form=upload_form, title=query) + count = results.count() + whole = Book.query.count() + percentage = float(count / whole * 100) + + if search.listview.data: + 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) + + if search.grid.data: + 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) + if request.method == 'POST': query = search.search.data results = [] return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data))) - - count = results.count() - whole = Book.query.count() - percentage = float(count / whole * 100) + 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)