Merge branch 'stack_stuff' of git.xpub.nl:/var/www/git.xpub.nl/repos/xpub-lib into stack_stuff
This commit is contained in:
commit
c3ea2d4868
@ -83,6 +83,9 @@ border-spacing:0; /* Removes the cell spacing via CSS */
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.library_table td{
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
th.headerSortUp{
|
th.headerSortUp{
|
||||||
background-color: #E8E8E8!important;
|
background-color: #E8E8E8!important;
|
||||||
@ -385,21 +388,21 @@ box-sizing: border-box;
|
|||||||
height: 100%; /* Full height */
|
height: 100%; /* Full height */
|
||||||
overflow: auto; /* Enable scroll if needed */
|
overflow: auto; /* Enable scroll if needed */
|
||||||
background-color: rgb(0,0,0); /* Fallback color */
|
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/Box */
|
||||||
.modal-content {
|
.modal-content {
|
||||||
background-color: #fefefe;
|
background-color: yellow;
|
||||||
margin: 15% auto; /* 15% from the top and centered */
|
margin: 15% auto; /* 15% from the top and centered */
|
||||||
padding: 20px;
|
padding: 15px;
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
width: 40%; /* Could be more or less, depending on screen size */
|
width: 40%; /* Could be more or less, depending on screen size */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Close Button */
|
/* The Close Button */
|
||||||
.close {
|
.close {
|
||||||
color: red;
|
color: grey;
|
||||||
float: right;
|
float: right;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -407,7 +410,7 @@ box-sizing: border-box;
|
|||||||
|
|
||||||
.close:hover,
|
.close:hover,
|
||||||
.close:focus {
|
.close:focus {
|
||||||
color: black;
|
color: red;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<div class="container">
|
<div class="container" style="float: left; width:50%;">
|
||||||
|
<div style="width: 98%; border-right: dashed; border-width: 1px;">
|
||||||
|
|
||||||
<h1 class="page-header">Add Book</h1>
|
<h1 class="page-header">Add Book</h1>
|
||||||
{% with messages = get_flashed_messages() %}
|
{% with messages = get_flashed_messages() %}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
@ -33,25 +35,59 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<br>
|
<br>
|
||||||
<div style="padding-left:10px;">
|
|
||||||
Category: {{ form.category(size=27, class="form-control") }}
|
Category: {{ form.category(size=27, class="form-control") }}
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
Year published: {{ form.year_published(size=8, class="form-control") }}
|
Year published: {{ form.year_published(size=8, class="form-control") }}
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<div style="width: 50%">
|
<div style="width: 40%;">
|
||||||
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") }}
|
||||||
<br></div>
|
<br></div>
|
||||||
<br>
|
<br>
|
||||||
{{ form.file }}
|
{{ form.file }}
|
||||||
{{ form.upload }}
|
{{ form.upload }}
|
||||||
{{ form.wish }}
|
{{ form.wish }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table class="library_table" id="table" style="width:30% padding:10px;" >
|
||||||
|
<thead>
|
||||||
|
<tr id="header" style="height:15px;">
|
||||||
|
<th style="width: 10%;"> <h5> Currently in the library </h5></th>
|
||||||
|
<th style="width: 20%;"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td> Titles: </td>
|
||||||
|
<td> {{ books_all }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Authors: </td>
|
||||||
|
<td> {{ authors_all }} </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Categories: </td>
|
||||||
|
<td> {{ categories|replace('[', '')|replace(']', '') }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Stacks: </td>
|
||||||
|
<td> {{ stacks_all|replace('[', '')|replace(']', '') }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> From the years: </td>
|
||||||
|
<td> {{earliest}} –– {{latest}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Gaps in the collection: </td>
|
||||||
|
<td> At least {{ books_potential }} potential books missing</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<table class="library_table" id="table" style="width:100%">
|
<table class="library_table" id="table" style="width:100%; padding-bottom:60px;">
|
||||||
<tr id="header">
|
<tr id="header">
|
||||||
<th width="70px;">Cover</th>
|
<th width="70px;">Cover</th>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
@ -68,9 +68,10 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
|
|
||||||
<div class="container" style= "border-top: dashed; border-width: 1px;" >
|
<div class="container" style= "border-top: dashed; border-width: 1px;" >
|
||||||
<h2> Other books </h2>
|
<h2> More books </h2>
|
||||||
|
|
||||||
<table class="library_table" id="table" style="width:100%">
|
<table class="library_table" id="table" style="width:100%">
|
||||||
<tr id="header">
|
<tr id="header">
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
<div class="grid" >
|
<div class="grid" style="padding-bottom:60px;">
|
||||||
|
|
||||||
{% for book in books|sort(attribute='title', reverse = False) %}
|
{% for book in books|sort(attribute='title', reverse = False) %}
|
||||||
|
|
||||||
@ -52,9 +52,8 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="container" style= "border-top: dashed; border-width: 1px;">
|
<div class="container" style= "border-top: dashed; border-width: 1px;">
|
||||||
<h2> Other books </h2>
|
<h2> More books </h2>
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|
||||||
|
@ -5,35 +5,61 @@
|
|||||||
<h1 class="header">{{ book.title }}</h1>
|
<h1 class="header">{{ book.title }}</h1>
|
||||||
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="180" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="180" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
||||||
|
|
||||||
<p>Year published: {{ book.year_published }}</p>
|
|
||||||
<p>Author(s): <ul>{% for author in book.authors %}
|
|
||||||
|
|
||||||
<li><a href="{{url_for('show_author_by_id', id=author.id)}}">{{ author.author_name }}</a> </li>
|
<table class="library_table" id="table" style="width:50%; padding-bottom: 20px;">
|
||||||
|
<thead>
|
||||||
|
<tr id="header">
|
||||||
|
<th style="width: 150px;"></th>
|
||||||
|
<th style="width: 500px;"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Year published: </td>
|
||||||
|
<td>{{ book.year_published or '––'}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Author(s): </td>
|
||||||
|
<td>{% for author in book.authors %}
|
||||||
|
|
||||||
{% endfor %}</ul></p>
|
<a href="{{url_for('show_author_by_id', id=author.id)}}">{{ author.author_name }}</a><br>
|
||||||
|
|
||||||
<p>Category: {{ book.category }}</p>
|
{% endfor %}</td>
|
||||||
|
</tr>
|
||||||
<p>Included in stack(s): <ul>{% for stack in book.stacks %}
|
<tr>
|
||||||
|
<td>Category: </td>
|
||||||
|
<td>{{ book.category }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Included in stack(s): </td>
|
||||||
|
<td>{% for stack in book.stacks %}
|
||||||
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a>
|
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a>
|
||||||
<p style="font-size: 10px;"><a href="{{url_for('remove_from_stack', stackid=stack.id, bookid=book.id)}}"> Remove from stack</a></p>
|
<p style="font-size: 10px;"><a href="{{url_for('remove_from_stack', stackid=stack.id, bookid=book.id)}}"> – Remove from stack</a>{% endfor %}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
{% endfor %}</ul></p>
|
{% if book.file %}
|
||||||
|
|
||||||
<button id="myBtn" style= "width: 180px; font-size: 10pt;"><a> Download this {{ book.fileformat }}</a></button>
|
<button id="myBtn" style= "width: 180px; font-size: 10pt;"><a> Download this {{ book.fileformat }}</a></button>
|
||||||
<button style= "font-size: 10pt;"> <a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a></button>
|
|
||||||
<button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>
|
|
||||||
|
|
||||||
<div id="myModal" class="modal">
|
<div id="myModal" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<span class="close">×</span>
|
<span class="close">×</span>
|
||||||
<h3>A message from the uploading librarian:</h3>
|
<h3>A message from the uploading librarian:</h3>
|
||||||
<p style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </p>
|
<span style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </span><br>
|
||||||
<br>
|
<h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4></a></div>
|
||||||
<h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4>
|
</div>
|
||||||
</div></div>
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<button style= "font-size: 10pt;"> <a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a></button>
|
||||||
|
<button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>
|
||||||
|
<br><br>
|
||||||
|
<hr>
|
||||||
|
{% if previousbook %}
|
||||||
|
<a href="{{ url_for('show_book_by_id', id=previousbook.id )}}" style="font-size: 9pt;"> < see the previous book added to XPPL: <i>{{ previousbook.title |truncate(40,True,'...') }} </i></a> {% endif %}
|
||||||
|
{% if nextbook %}
|
||||||
|
<a href="{{ url_for('show_book_by_id', id=nextbook.id )}}" style="float:right; font-size: 9pt;"> see the next book added to XPPL: <i>{{ nextbook.title|truncate(40,True,'...')}} </i>> </a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
39
app/views.py
39
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
|
from flask import Flask, Response, render_template, request, redirect, url_for, flash, send_from_directory, jsonify, abort
|
||||||
import json
|
import json
|
||||||
from sqlalchemy.sql.expression import func, select
|
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.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.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema, Potential
|
||||||
from app.cover import get_cover
|
from app.cover import get_cover
|
||||||
@ -105,6 +106,15 @@ def show_books_grid():
|
|||||||
@app.route('/books/<int:id>')
|
@app.route('/books/<int:id>')
|
||||||
def show_book_by_id(id):
|
def show_book_by_id(id):
|
||||||
book = Book.query.get(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()
|
userin = UserIns.query.filter_by(title="lastViewed").first()
|
||||||
if userin != None:
|
if userin != None:
|
||||||
userin.info = book.title
|
userin.info = book.title
|
||||||
@ -116,7 +126,7 @@ def show_book_by_id(id):
|
|||||||
if not book:
|
if not book:
|
||||||
return render_template('red_link.html', id=id)
|
return render_template('red_link.html', id=id)
|
||||||
else:
|
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/<int:id>/delete', methods=['POST', 'GET'])
|
@app.route('/books/<int:id>/delete', methods=['POST', 'GET'])
|
||||||
@ -141,12 +151,14 @@ def edit_book_by_id(id):
|
|||||||
input_authors = user_form.author.data
|
input_authors = user_form.author.data
|
||||||
category = user_form.category.data
|
category = user_form.category.data
|
||||||
year_published = user_form.year_published.data
|
year_published = user_form.year_published.data
|
||||||
|
message = user_form.message.data
|
||||||
if year_published=="":
|
if year_published=="":
|
||||||
year_published = None
|
year_published = None
|
||||||
book = Book.query.filter_by(id=id).first()
|
book = Book.query.filter_by(id=id).first()
|
||||||
book.title = title
|
book.title = title
|
||||||
book.category = category
|
book.category = category
|
||||||
book.year_published = year_published
|
book.year_published = year_published
|
||||||
|
book.message = message
|
||||||
|
|
||||||
#authors update
|
#authors update
|
||||||
book.authors.clear()
|
book.authors.clear()
|
||||||
@ -188,6 +200,17 @@ def edit_book_by_id(id):
|
|||||||
@app.route('/add-book', methods=['POST', 'GET'])
|
@app.route('/add-book', methods=['POST', 'GET'])
|
||||||
def add_book():
|
def add_book():
|
||||||
upload_form = UploadForm()
|
upload_form = UploadForm()
|
||||||
|
allbooks = db.session.query(Book).all()
|
||||||
|
books_all = len(allbooks)
|
||||||
|
allauthors = db.session.query(Author).all()
|
||||||
|
authors_all = len(allauthors)
|
||||||
|
stacks_all = [s.stack_name for s in db.session.query(Stack.stack_name)]
|
||||||
|
categories = [r.category for r in db.session.query(Book.category).distinct()]
|
||||||
|
allpotential = db.session.query(Book).filter(Book.file.contains('potential.pdf')).all()
|
||||||
|
books_potential = len(allpotential)
|
||||||
|
earliest = db.session.query(func.min(Book.year_published)).scalar()
|
||||||
|
latest = db.session.query(func.max(Book.year_published)).scalar()
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if upload_form.validate_on_submit():
|
if upload_form.validate_on_submit():
|
||||||
@ -256,7 +279,7 @@ def add_book():
|
|||||||
return redirect(url_for('show_books'))
|
return redirect(url_for('show_books'))
|
||||||
|
|
||||||
flash_errors(upload_form)
|
flash_errors(upload_form)
|
||||||
return render_template('add_book.html', form=upload_form)
|
return render_template('add_book.html', form=upload_form, books_all=books_all, authors_all=authors_all, categories=categories, stacks_all=stacks_all, books_potential=books_potential, earliest=earliest, latest=latest)
|
||||||
|
|
||||||
|
|
||||||
# Flash errors from the form if validation fails
|
# Flash errors from the form if validation fails
|
||||||
@ -397,8 +420,8 @@ def show_books():
|
|||||||
@app.route('/search/<searchtype>/<viewby>/<query>', methods=['POST', 'GET'])
|
@app.route('/search/<searchtype>/<viewby>/<query>', methods=['POST', 'GET'])
|
||||||
def search_results(searchtype, query, viewby):
|
def search_results(searchtype, query, viewby):
|
||||||
search = SearchForm(request.form, search=query)
|
search = SearchForm(request.form, search=query)
|
||||||
random_order=Book.query.all()
|
|
||||||
results=Book.query.filter(Book.title.contains(query)).order_by(Book.title)
|
results=Book.query.filter(Book.title.contains(query)).order_by(Book.title)
|
||||||
|
allbooks = set(Book.query.all())
|
||||||
viewby = view[-1]
|
viewby = view[-1]
|
||||||
|
|
||||||
if searchtype == 'Title':
|
if searchtype == 'Title':
|
||||||
@ -430,14 +453,16 @@ def search_results(searchtype, query, viewby):
|
|||||||
count = results.count()
|
count = results.count()
|
||||||
whole = Book.query.count()
|
whole = Book.query.count()
|
||||||
percentage = float(count / whole * 100)
|
percentage = float(count / whole * 100)
|
||||||
|
fbooks = set(results)
|
||||||
|
books_all = allbooks - fbooks
|
||||||
|
|
||||||
if search.listview.data:
|
if search.listview.data:
|
||||||
view.append('1')
|
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:
|
if search.grid.data:
|
||||||
view.append('2')
|
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':
|
if request.method == 'POST':
|
||||||
newmsg = 'searched for: ' + search.search.data
|
newmsg = 'searched for: ' + search.search.data
|
||||||
@ -462,10 +487,10 @@ def search_results(searchtype, query, viewby):
|
|||||||
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
||||||
|
|
||||||
if viewby == '2':
|
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:
|
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
|
# ## Search - autocomplete
|
||||||
|
Loading…
Reference in New Issue
Block a user