MORE GRADIENT

geo
Alex 7 years ago
commit d0db637115

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

@ -46,10 +46,9 @@ class Book(db.Model):
diversity = db.Column(db.Numeric())
gender = db.Column(db.Numeric())
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.file = file
self.cover = cover
@ -64,7 +63,6 @@ class Book(db.Model):
self.diversity = diversity
self.gender = gender
self.who = who
self.time = time
def __repr__(self):

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

@ -63,13 +63,34 @@ function generateTitle(elem) {
}
$(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");
});
$(".no_cover").each(function() {
var string = $(this).attr('id')
var randomColor = colorHash(string).rgb
@ -201,7 +222,7 @@ var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}

@ -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.
<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>
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>
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>

@ -68,17 +68,12 @@ Check the bibliography. How diverse are the references in this book? <br>
<br><hr align="left" style="width:96%;"><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>
<br><hr align="left" style="width:96%;"><br>
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>
<div style="width: 40%;">

@ -22,12 +22,26 @@
{{form.hidden_tag()}}
<br>
{{ 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)}}
<br>
<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' %}
{% 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">
<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.csrf_token }}
<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">
{{ 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>
<table>
<tr>
@ -25,28 +39,45 @@
</tr>
{% for author in form.author %}
<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>
</tr>
{% endfor %}
</table>
</div><br>
<div class="form-group" style="padding-bottom: 10px;">
Category: {{ form.category(size=20,
class="form-control") }}
</div>
<div class="form-group" style="padding-bottom: 10px;">
Year published: {{ form.year_published(size=8, class="form-control") }}
</div>
</table><br>
<br>
Category:* <br> {{ form.category(size=50, class="form-control") }} <br><br>
Year published: <br> {{ form.year_published(size=8, class="form-control") }} <br><br>
How different is this item to the rest of the collection?
Or is it more of the same? <br>
{{ form.sameness(min=0, max=100, oninput="outputUpdate(value)") }} &nbsp;
<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;">
Current file: {{ book.file }}
Current file: {{ book.file }} &nbsp;&nbsp;&nbsp;&nbsp; Upload new file: {{form.file}}
</div>
<div class="form-group" style="padding-bottom: 10px;">
Upload new file: {{form.file}}
</div>
<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>
<br>

@ -3,10 +3,10 @@
{% block main %}
<div id="home_content">
<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}}
<br>
This might only be one interface to this library:
Feel free to browse our catalogue, interfaced in many different ways.
</p>
<a href="{{url_for('scape')}}">Scape</a>

@ -60,19 +60,16 @@
</table>
</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") }}
<br>
<br>
Year published: {{ form.year_published(size=8, class="form-control") }}
<br>
<br>
{{ form.file }}
{{ form.upload }}
{{ form.wish }}
</form>
<br>
<p><a href="{{ url_for('home') }}" style="font-size: 9pt;">go back home</a></p>
<br>
</div>
<div class= "Container" style= "border-top: dashed; border-width: 1px;">

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

@ -3,7 +3,7 @@
{% block main %}
<div class="container">
{% from "_formhelpers.html" import render_field %}
<form method="POST">
<div>{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}</div>
<div class="search">
@ -59,10 +59,17 @@
{% endfor %}</td>
<td id='fileformat'>{{ book.year_published or ''}}</td>
<td>{{ book.category}}</td>
<td>
<td id='ascii'>
{% for stack in book.stacks %}
<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 %}

@ -6,33 +6,39 @@
<h1 class="header">{{ stack.stack_name }}</h1>
<p>{{ stack.stack_description }} </p>
<p id='creator'>Created by:
<p id='creator'>Created by:
{% if stack.stack_author == None %} anon</p>
{% else %}
{{ stack.stack_author }}
{% endif %}
<h2>Books in this stack:</h2>
<p>
{% 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>
<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'>
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
</div>
{% endfor %}</p>
{% endfor %}</p>
<br>
<br>
<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><a href="{{url_for('show_books')}}">Add some more books</a></p>
<p><a href="{{ url_for('edit_stack_by_id', id=stack.id )}}">Edit title and/or description</a> </p>
<p><a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Remove stack</a> </p>
<p><a href="{{url_for('show_stacks')}}">Go back to the other stacks</p>
</div>

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

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

@ -20,7 +20,7 @@ with open(args.csv) as f:
print ('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)
authors = row['Author'].split(',')

Loading…
Cancel
Save