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 0000000..500390c Binary files /dev/null and b/app/static/img/default_cover.gif differ 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):

{% 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)