MORE GRADIENT

geo
Alex 7 years ago
commit d0db637115

@ -25,7 +25,6 @@ class UploadForm(FlaskForm):
sameness = DecimalRangeField('sameness', default=0) sameness = DecimalRangeField('sameness', default=0)
diversity = DecimalRangeField('diversity', default=0) diversity = DecimalRangeField('diversity', default=0)
gender = DecimalRangeField('gender', default=50) gender = DecimalRangeField('gender', default=50)
time = StringField('time', [validators.Length(max=5)],default=None)
choices = [('Student', 'Student'), choices = [('Student', 'Student'),
('Librarian', 'Librarian'), ('Librarian', 'Librarian'),
('Pirate', 'Pirate'), ('Pirate', 'Pirate'),
@ -43,6 +42,17 @@ class EditForm(FlaskForm):
year_published = StringField('year published', [validators.Length(max=4)],default=None) year_published = StringField('year published', [validators.Length(max=4)],default=None)
file = FileField() file = FileField()
message = StringField('message') message = StringField('message')
sameness = DecimalRangeField('sameness', default=0)
diversity = DecimalRangeField('diversity', default=0)
gender = DecimalRangeField('gender', default=50)
choices = [('Student', 'Student'),
('Librarian', 'Librarian'),
('Pirate', 'Pirate'),
('Teacher', 'Teacher'),
('Institution', 'Institution'),
('All of the above', 'All of the above'),
('None of the above', 'None of the above')]
who = SelectField('', choices=choices, default='Student')
class ChatForm(FlaskForm): class ChatForm(FlaskForm):
message = StringField('message', validators=[InputRequired()]) message = StringField('message', validators=[InputRequired()])
@ -66,7 +76,8 @@ class SearchForm(FlaskForm):
('Title', 'Title'), ('Title', 'Title'),
('Author', 'Author'), ('Author', 'Author'),
('Category', 'Category'), ('Category', 'Category'),
('Stack', 'Stack')] ('Stack', 'Stack'),
('Outliers', 'Outliers')]
select = SelectField('', choices=choices, default='All') select = SelectField('', choices=choices, default='All')
search = StringField('', validators=[InputRequired()]) search = StringField('', validators=[InputRequired()])
grid = SubmitField('Grid') grid = SubmitField('Grid')

@ -46,10 +46,9 @@ class Book(db.Model):
diversity = db.Column(db.Numeric()) diversity = db.Column(db.Numeric())
gender = db.Column(db.Numeric()) gender = db.Column(db.Numeric())
who = db.Column(db.String(255)) who = db.Column(db.String(255))
time = db.Column(db.Numeric())
def __init__(self, title, file, cover, fileformat, category, year_published, message, sameness, diversity, gender, who, time): def __init__(self, title, file, cover, fileformat, category, year_published, message, sameness, diversity, gender, who):
self.title = title self.title = title
self.file = file self.file = file
self.cover = cover self.cover = cover
@ -64,7 +63,6 @@ class Book(db.Model):
self.diversity = diversity self.diversity = diversity
self.gender = gender self.gender = gender
self.who = who self.who = who
self.time = time
def __repr__(self): def __repr__(self):

@ -121,6 +121,10 @@ display: inline-block;
font-size: 10px; font-size: 10px;
} }
#ascii {
text-align: center;
}
.library_table tr:nth-child(even){ .library_table tr:nth-child(even){
background-color: #fafafa; background-color: #fafafa;
@ -391,7 +395,7 @@ box-sizing: border-box;
justify-items: center; justify-items: center;
} }
@media screen and (max-width: 900px) { @media screen and (max-width: 1000px) {
.grid{ .grid{
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr 1fr;
@ -400,11 +404,13 @@ box-sizing: border-box;
justify-items: center; justify-items: center;
} }
} }
@media screen and (max-width: 400px) {
@media screen and (max-width: 600px) {
.grid{ .grid{
display: grid; display: grid;
grid-template-columns: 1fr; grid-template-columns: 1fr 1fr 1fr;
align-items: center; grid-gap: 2px;
align-items: top;
justify-items: center; justify-items: center;
} }
} }
@ -415,6 +421,7 @@ box-sizing: border-box;
align-items: center; align-items: center;
justify-items: center; justify-items: center;
} }
.gridbox:hover{ .gridbox:hover{
opacity: 0.5; opacity: 0.5;
} }

@ -63,13 +63,34 @@ function generateTitle(elem) {
} }
$(function() { $(function() {
$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix"); var index = 'ui-tabs-active';
// Define friendly data store name
var dataStore = window.sessionStorage;
var oldIndex = 0;
// Start magic!
try {
// getter: Fetch previous value
oldIndex = dataStore.getItem(index);
} catch(e) {}
$("#tabs").tabs({
active: oldIndex,
activate: function(event, ui) {
// Get future value
var newIndex = ui.newTab.parent().children().index(ui.newTab);
// Set future value
try {
dataStore.setItem( index, newIndex );
} catch(e) {}
}
});
$("#tabs").addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left"); $("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
}); });
$(".no_cover").each(function() { $(".no_cover").each(function() {
var string = $(this).attr('id') var string = $(this).attr('id')
var randomColor = colorHash(string).rgb var randomColor = colorHash(string).rgb

@ -6,13 +6,14 @@
XPPL is a project aimed at people who are studying the field of media culture, or as we like to call them: knowledge comrades. XPPL is a project aimed at people who are studying the field of media culture, or as we like to call them: knowledge comrades.
<br> <br>
<br> <br>
This digital library gathers all the books and articles floating around on the shelves of the Piet Zwart Institute, and our hard drives and memory sticks, so that they can be shared, annotated and grouped together into stacks... This digital library gathers all the books and articles floating around on the shelves of the Piet Zwart Institute, and our hard drives and memory sticks, so that they can be shared, annotated and grouped together into stacks... Its web interface hosts a curated catalogue of books and articles, and its distributed architecture provides instances for uploading and downloading.
<br> <br>
<br> <br>
Its web interface hosts a curated catalogue of books and articles, and its distributed architecture provides instances for uploading and downloading. It starts at XPUB, but can go anywhere we want it to.
<br> <br>
<br> <br>
It starts at XPUB, but can go anywhere we want it to.</p> Are you interested in how this library works? Have a look at the source code in <a href 'https://git.xpub.nl/xpub-lib/log.html'> our git. </a>
</p>
<h2> What's the deal with the stacks? </h2> <h2> What's the deal with the stacks? </h2>

@ -68,17 +68,12 @@ Check the bibliography. How diverse are the references in this book? <br>
<br><hr align="left" style="width:96%;"><br> <br><hr align="left" style="width:96%;"><br>
Check the writing. Who is speaking? Is the voice more often male or female? <br> Check the writing. Who is speaking? Is the voice more often male or female? <br>
{{ form.diversity(min=1, max=100, oninput="outputUpdate3(value)") }} &nbsp; {{ form.gender(min=1, max=100, oninput="outputUpdate3(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="diversity" id="selected-gender">{{ form.gender.data }} </output> % female</span> <span style="color: #d3d3d3;"><output for="diversity" id="selected-gender">{{ form.gender.data }} </output> % female</span>
<br><hr align="left" style="width:96%;"><br> <br><hr align="left" style="width:96%;"><br>
Who are you? {{ render_field(form.who) }} Who are you? {{ render_field(form.who) }}
<br><hr align="left" style="width:96%;"><br>
How much time have you spent with this item?
Include the time spent looking for it, and uploading it.<br>
{{ form.time (size = 50, class="form-control")}} <span style="color: #d3d3d3;">hours</span>
<br>
<br><hr align="left" style="width:96%;"><br> <br><hr align="left" style="width:96%;"><br>
<div style="width: 40%;"> <div style="width: 40%;">

@ -22,12 +22,26 @@
{{form.hidden_tag()}} {{form.hidden_tag()}}
<br> <br>
{{ render_field(form.stack_name)}} {{ render_field(form.stack_name)}}
{{ render_field(form.stack_description)}} <div style="width: 40%;">
Add a nice description: {{ form.stack_description(size=90, class="form-control") }}
</div>
{{ render_field(form.stack_author)}} {{ render_field(form.stack_author)}}
<br>
<button type="submit" class='button'>Create</button> <button type="submit" class='button'>Create</button>
</form>
<br>
<hr>
<br>
<h1> Stacks currently in the library </h1>
<ul>
{% for stack in stacks %}
<li> <a href="stacks/tab/{{ stack.id }}">
</form> {{ stack.stack_name }}
</a></td>
{% endfor %}
</ul>

@ -1,22 +1,36 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block main %} {% block main %}
{% from "_formhelpers.html" import render_field %}
<head>
<script>
function outputUpdate(sameness) {
document.querySelector('#selected-sameness').value = sameness;
}
function outputUpdate2(diversity) {
document.querySelector('#selected-diversity').value = diversity;
}
function outputUpdate3(gender) {
document.querySelector('#selected-gender').value = gender;
}
</script>
</head>
<div class="container"> <div class="container">
<a href="{{ url_for('show_book_by_id', id=book.id )}}">back</a> <a href="{{ url_for('show_book_by_id', id=book.id )}}">back</a>
<form method="POST" action="{{ url_for('edit_book_by_id', id=book.id )}}" enctype=multipart/form-data> <form method="POST" action="{{ url_for('edit_book_by_id', id=book.id )}}" enctype=multipart/form-data>
{{ form.csrf_token }} {{ form.csrf_token }}
<div class="form-group"><h1 class="header">{{ form.title.label }} {{ form.title(size=20, class="form-control") }}</h1></div> <div class="form-group"><h1 class="header">{{ form.title.label }} {{ form.title(size=20, class="form-control") }}</h1></div>
<img class="no_cover" id="{{ book.title }}" src="/uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '/uploads/cover/{{ book.cover }}') this.src = '/static/img/default_cover.gif';"> <div style="float:right; padding-right: 300px;">
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="280px" onerror="if (this.src != '/uploads/cover/{{ book.cover }}') this.src = '/static/img/default_cover.gif';"></div>
<br> <br> <br>
<div data-toggle="fieldset" id="phone-fieldset"> <div data-toggle="fieldset" id="phone-fieldset">
{{ form.author.label }} <button type="button" data-toggle="fieldset-add-row" {{ form.author.label }}*: <button type="button" data-toggle="fieldset-add-row"
data-target="#phone-fieldset">+</button> data-target="#phone-fieldset">+</button>
<table> <table>
<tr> <tr>
@ -25,28 +39,45 @@
</tr> </tr>
{% for author in form.author %} {% for author in form.author %}
<tr data-toggle="fieldset-entry"> <tr data-toggle="fieldset-entry">
<td>{{ author.author_name }}</td> <td>{{ author.author_name (size=50, class="form-control") }}</td>
<td><button type="button" data-toggle="fieldset-remove-row" id="phone-{{loop.index0}}-remove">-</button></td> <td><button type="button" data-toggle="fieldset-remove-row" id="phone-{{loop.index0}}-remove">-</button></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table><br>
</div><br> <br>
<div class="form-group" style="padding-bottom: 10px;"> Category:* <br> {{ form.category(size=50, class="form-control") }} <br><br>
Category: {{ form.category(size=20, Year published: <br> {{ form.year_published(size=8, class="form-control") }} <br><br>
class="form-control") }}
</div> How different is this item to the rest of the collection?
<div class="form-group" style="padding-bottom: 10px;"> Or is it more of the same? <br>
Year published: {{ form.year_published(size=8, class="form-control") }} {{ form.sameness(min=0, max=100, oninput="outputUpdate(value)") }} &nbsp;
</div> <span style="color: #d3d3d3;"><output for="sameness" id="selected-sameness">{{ form.sameness.data }} </output> % different</span>
<br><hr align="left" style="width:40%;"><br>
Check the bibliography. How diverse are the references in this book? <br>
{{ form.diversity(min=0, max=100, oninput="outputUpdate2(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="diversity" id="selected-diversity">{{ form.diversity.data }} </output> % diverse</span>
<br><hr align="left" style="width:40%;"><br>
Check the writing. Who is speaking? Is the voice more often male or female? <br>
{{ form.gender(min=1, max=100, oninput="outputUpdate3(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="diversity" id="selected-gender">{{ form.gender.data }} </output> % female</span>
<br><hr align="left" style="width:40%;"><br>
Who are you? {{ render_field(form.who)}}
<br><hr align="left" style="width:40%;"><br>
<div class="form-group" style="padding-bottom: 10px;"> <div class="form-group" style="padding-bottom: 10px;">
Current file: {{ book.file }} Current file: {{ book.file }} &nbsp;&nbsp;&nbsp;&nbsp; Upload new file: {{form.file}}
</div> </div>
<div class="form-group" style="padding-bottom: 10px;"> <div class="form-group" style="padding-bottom: 10px;">
Upload new file: {{form.file}}
</div> </div>
<div class="form-group" style="padding-bottom: 10px;"> <div class="form-group" style="padding-bottom: 10px;">
If uploading, write a new message: {{form.message(size=150, class="form-control") }} If uploading, write a new message: <br>{{form.message(size=135, class="form-control") }}
</div> </div>
<br> <br>

@ -3,10 +3,10 @@
{% block main %} {% block main %}
<div id="home_content"> <div id="home_content">
<h1 class="header" id="title_xppl">XPPL</h1> <h1 class="header" id="title_xppl">XPPL</h1>
<p class="lead">This is the awesome library of Experimental Publishing. <br> <p class="lead"> Welcome to our digital library. <br>
On instance: {{server}} / From: {{client}} On instance: {{server}} / From: {{client}}
<br> <br>
This might only be one interface to this library: Feel free to browse our catalogue, interfaced in many different ways.
</p> </p>
<a href="{{url_for('scape')}}">Scape</a> <a href="{{url_for('scape')}}">Scape</a>

@ -60,19 +60,16 @@
</table> </table>
</div> </div>
</div> </div>
<div style="padding-left:10px; padding-bottom: 50px;"> <div style="padding-left:10px; padding-bottom: 100px;">
<br>
Category: {{ form.category(size=27, class="form-control") }} Category: {{ form.category(size=27, class="form-control") }}
<br> <br>
<br>
Year published: {{ form.year_published(size=8, class="form-control") }}
<br>
<br> <br>
{{ form.file }} {{ form.file }}
{{ form.upload }} {{ form.upload }}
{{ form.wish }} {{ form.wish }}
</form> </form>
<br> <br>
<p><a href="{{ url_for('home') }}" style="font-size: 9pt;">go back home</a></p>
<br> <br>
</div> </div>
<div class= "Container" style= "border-top: dashed; border-width: 1px;"> <div class= "Container" style= "border-top: dashed; border-width: 1px;">

@ -2,6 +2,7 @@
{% block main %} {% block main %}
<div class="container"> <div class="container">
<h1 class="header">{{ book.title }}</h1> <h1 class="header">{{ book.title }}</h1>
<div style="float:right; padding-right: 140px;"> <div style="float:right; padding-right: 140px;">
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="280px" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';"></div> <img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="280px" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';"></div>
@ -58,10 +59,7 @@
<td>Who is uploading<br></td> <td>Who is uploading<br></td>
<td>{{ book.who or '?' }} </td> <td>{{ book.who or '?' }} </td>
</tr> </tr>
<tr>
<td>How much time has been spent with this item?<br></td>
<td>{{ book.time or '?' }} </td>
</tr>
<tr> <tr>
<td>Instances:</td> <td>Instances:</td>
<td>{% set got = {} %} <td>{% set got = {} %}
@ -83,21 +81,22 @@
</tbody> </tbody>
</table> </table>
<br>
<a href="{{url_for('add_to_stack', id=book.id)}}">Add book to Stack ===></a> <br><br>
<br> <br>
{% if book.file %}
{% 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> <div id="myModal" class="modal">
<div id="myModal" class="modal">
<div class="modal-content"> <div class="modal-content">
<span class="close">&times;</span> <span class="close">&times;</span>
<h3>A message from the uploading librarian:</h3> <h3>A message from the uploading librarian:</h3>
<span style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </span><br> <span style="font-style: italic;">"{{book.message or '...'}}" </span><br>
<h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4></a></div> <h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4></a>
</div> </div>
{% else %} </div>
{% endif %} {% 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('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> <button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>

@ -59,10 +59,17 @@
{% endfor %}</td> {% endfor %}</td>
<td id='fileformat'>{{ book.year_published or ''}}</td> <td id='fileformat'>{{ book.year_published or ''}}</td>
<td>{{ book.category}}</td> <td>{{ book.category}}</td>
<td> <td id='ascii'>
{% for stack in book.stacks %} {% for stack in book.stacks %}
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}"> {{ stack.stack_name }} </a></li> <li><a href="{{url_for('show_stack_by_id', id=stack.id)}}"> {{ stack.stack_name }} </a></li>
{% else %}
<li style='font-size:10px;'>
XXXXXXXXXX <br>
XXXXXXXXXX <br>
XXXXXXXXXX <br>
{% endfor %} {% endfor %}

@ -13,26 +13,32 @@
{{ stack.stack_author }} {{ stack.stack_author }}
{% endif %} {% endif %}
<h2>Books in this stack:</h2> <h2>Books in this stack:</h2>
<p> <p>
{% for book in stack.books %} {% for book in stack.books %}
{% if loop.length >= 5 %}
{% if loop.index == 6 %}
<p style='color:red;'>Your stack is getting a little too big. Are these next books really relevant?</p>
<br>
<br>
{% endif %}
{% endif %}
<li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li> <li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" 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="150" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
<div class='widget'> <div class='widget'>
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe> <iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
</div> </div>
{% endfor %}</p>
{% endfor %}</p>
<br> <br>
<br> <br>
<p> <p><a href="{{url_for('show_books')}}">Add some more books</a></p>
<a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Remove stack</a> </p> <p><a href="{{ url_for('edit_stack_by_id', id=stack.id )}}">Edit title and/or description</a> </p>
<p> <p><a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Remove stack</a> </p>
<a href="{{ url_for('edit_stack_by_id', id=stack.id )}}">Edit title and/or description</a> </p>
<p><a href="{{url_for('show_stacks')}}">Go back to the other stacks</p> <p><a href="{{url_for('show_stacks')}}">Go back to the other stacks</p>
</div> </div>

@ -17,17 +17,12 @@
{{ stack.stack_author }} {{ stack.stack_author }}
{% endif %} {% endif %}
<p style='font-weight:bold;'>Books in this stack: {% for book in stack.books %} </p>
<p style='font-weight:bold;'>Books in this stack: {% for book in stack.books %}
<li style="font-size: 18px;"> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li> <li style="font-size: 18px;"> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
<p style="font-size: 10px;"><a href='{{url_for('add_to_stack', id=book.id)}}'> <p style="font-size: 10px;"><a href='{{url_for('add_to_stack', id=book.id)}}'> Add to another stack </a></p>
Add to another stack
</a></p>
{% endfor %}</p>
{% endfor %}
</div> </div>

@ -172,7 +172,7 @@ def remove_book_by_id(id):
@app.route('/books/<int:id>/edit', methods=['POST', 'GET']) @app.route('/books/<int:id>/edit', methods=['POST', 'GET'])
def edit_book_by_id(id): def edit_book_by_id(id):
book_to_edit = Book.query.filter_by(id=id).first() book_to_edit = Book.query.filter_by(id=id).first()
user_form = EditForm(title = book_to_edit.title, author =book_to_edit.authors, category = book_to_edit.category, year_published= book_to_edit.year_published, message= book_to_edit.message) user_form = EditForm(title = book_to_edit.title, author =book_to_edit.authors, category = book_to_edit.category, year_published= book_to_edit.year_published, message= book_to_edit.message, sameness=book_to_edit.sameness, gender=book_to_edit.gender, diversity=book_to_edit.diversity, who=book_to_edit.who)
if request.method == 'POST': if request.method == 'POST':
if user_form.validate_on_submit(): if user_form.validate_on_submit():
@ -182,6 +182,11 @@ def edit_book_by_id(id):
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 message = user_form.message.data
sameness = user_form.sameness.data
gender = user_form.gender.data
diversity = user_form.diversity.data
who = user_form.who.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()
@ -189,6 +194,10 @@ def edit_book_by_id(id):
book.category = category book.category = category
book.year_published = year_published book.year_published = year_published
book.message = message book.message = message
book.sameness = sameness
book.gender = gender
book.diversity = diversity
book.who = who
#authors update #authors update
book.authors.clear() book.authors.clear()
@ -258,9 +267,6 @@ def add_book():
sameness = upload_form.sameness.data sameness = upload_form.sameness.data
gender = upload_form.gender.data gender = upload_form.gender.data
diversity = upload_form.diversity.data diversity = upload_form.diversity.data
time = None
if time:
time = upload_form.time.data
who = upload_form.who.data who = upload_form.who.data
if year_published=="": if year_published=="":
@ -310,9 +316,8 @@ def add_book():
html_string = render_template('potential_pdf.html', pbooks = pbooks) html_string = render_template('potential_pdf.html', pbooks = pbooks)
html = HTML(string=html_string) html = HTML(string=html_string)
html.write_pdf(target='app/uploads/potential.pdf'); html.write_pdf(target='app/uploads/potential.pdf');
print ('potential_pdf')
book = Book(title, filename, cover, file_extension, category, year_published, message, sameness, diversity, gender, who, time) book = Book(title, filename, cover, file_extension, category, year_published, message, sameness, diversity, gender, who)
db.session.add(book) db.session.add(book)
for author in authors: for author in authors:
author_name = author.get("author_name") author_name = author.get("author_name")
@ -395,7 +400,7 @@ def show_stack_by_id(id, is_tab=False):
stack = Stack.query.get(id) stack = Stack.query.get(id)
if not stack: if not stack:
abort (404) return render_template('add_stack.html', stacks=stacks, form=form)
else: else:
if is_tab == False: if is_tab == False:
return render_template('show_stack_detail.html', stack=stack) return render_template('show_stack_detail.html', stack=stack)
@ -520,14 +525,16 @@ def search_results(searchtype, query, viewby):
if searchtype== 'Stack': if searchtype== 'Stack':
results=db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query)).order_by(Book.title) results=db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query)).order_by(Book.title)
if searchtype== 'Outliers':
results=Book.query.filter(Book.sameness > 50).order_by(Book.title)
if searchtype== 'All': if searchtype== 'All':
# results=Book.query.whoosh_search(query) # results=Book.query.whoosh_search(query)
results=Book.query.filter(Book.title.contains(query)) results=Book.query.filter(Book.title.contains(query))
results=results.union(Book.query.filter(Book.category.contains(query))) results=results.union(Book.query.filter(Book.category.contains(query)))
results=results.union(Book.query.filter(Book.year_published.contains(query))) results=results.union(Book.query.filter(Book.year_published.contains(query)))
results=results.union(db.session.query(Book).join(Book.authors).filter(Author.author_name.contains(query))) results=results.union(db.session.query(Book).join(Book.authors).filter(Author.author_name.contains(query)))
results=results.union(db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query))) results=results.union(db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query))).order_by(Book.title)
results=results.union(db.session.query(Book).join(Book.stacks).filter(Stack.stack_description.contains(query))).order_by(Book.title)
if results.count() == 0: if results.count() == 0:
books = Book.query.filter(Book.file.like('potential.pdf')) books = Book.query.filter(Book.file.like('potential.pdf'))
@ -669,17 +676,32 @@ def import_csv():
print("allreadyexists") print("allreadyexists")
else: else:
cover = '' cover = ''
if row['file']: if row['file'] == '':
file = 'potential.pdf'
# file_extension = '.pdf'
# ptitle = row['title']
# pbook = Potential(ptitle)
# db.session.add(pbook)
# db.session.commit()
# pbooks = Potential.query.all()
# template = 'app/templates/potential_pdf.html'
# html_string = render_template('potential_pdf.html', pbooks = pbooks)
# html = HTML(string=html_string)
# html.write_pdf(target='app/uploads/potential.pdf')
# print ('writing to potential_pdf')
else:
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], row['file']) fullpath = os.path.join(app.config['UPLOAD_FOLDER'], row['file'])
name, file_extension = os.path.splitext(row['file']) name, file_extension = os.path.splitext(row['file'])
print ('get_cover', fullpath, name) print ('get_cover', fullpath, name)
cover = get_cover(fullpath, name) cover = get_cover(fullpath, name)
file = str(id) + "_" + row['file']
if row['year_published']: if row['year_published']:
year_published = int(row['year_published']) year_published = int(row['year_published'])
else: else:
year_published = None; year_published = None;
book = Book(row['title'], row['file'], cover, row['fileformat'], row['category'], year_published, None, None, None, None, None, None) book = Book(row['title'], file, cover, row['fileformat'], row['category'],year_published, None, None, None, None, None)
if row['scapeX']: if row['scapeX']:
book.scapeX = float(row['scapeX']) book.scapeX = float(row['scapeX'])
if row['scapeY']: if row['scapeY']:

@ -20,7 +20,7 @@ with open(args.csv) as f:
print ('get_cover', fullpath, name) print ('get_cover', fullpath, name)
cover = get_cover(fullpath, name) cover = get_cover(fullpath, name)
book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None, None, None, None, None, None, None) book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None, None, None, None, None, None)
db.session.add(book) db.session.add(book)
authors = row['Author'].split(',') authors = row['Author'].split(',')

Loading…
Cancel
Save