From ff507913e25715abef852bf1182aecd8ea835202 Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 11 Jun 2018 16:56:34 +0200 Subject: [PATCH 1/8] added stack length limit and ascii in catalog view --- app/static/css/style.css | 4 ++++ app/templates/show_books.html | 11 +++++++++-- app/templates/show_stack_detail.html | 15 ++++++++++++++- app/templates/show_stack_detail_tab.html | 11 +++-------- app/views.py | 2 +- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index 5573e85..7fc3444 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -121,6 +121,10 @@ display: inline-block; font-size: 10px; } +#ascii { + text-align: center; +} + .library_table tr:nth-child(even){ background-color: #fafafa; diff --git a/app/templates/show_books.html b/app/templates/show_books.html index 04a9d0b..2c2e6fb 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -3,7 +3,7 @@ {% block main %}
{% from "_formhelpers.html" import render_field %} - +
{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}
diff --git a/app/views.py b/app/views.py index b8b4447..430b6cd 100755 --- a/app/views.py +++ b/app/views.py @@ -393,7 +393,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) From f1b27bff5d8e5ad0043e1bc707250fb2971d77cc Mon Sep 17 00:00:00 2001 From: nberting Date: Mon, 11 Jun 2018 17:24:30 +0200 Subject: [PATCH 2/8] update upload form extra questions --- app/forms.py | 12 +++++- app/models.py | 4 +- app/templates/add_book.html | 7 +-- app/templates/edit_book_detail.html | 67 +++++++++++++++++++++-------- app/templates/show_book_detail.html | 6 +-- app/views.py | 34 ++++++++++++--- import_csv.py | 2 +- 7 files changed, 93 insertions(+), 39 deletions(-) diff --git a/app/forms.py b/app/forms.py index c3aacd0..3c749ac 100755 --- a/app/forms.py +++ b/app/forms.py @@ -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()]) diff --git a/app/models.py b/app/models.py index 68b7a23..77cb93f 100755 --- a/app/models.py +++ b/app/models.py @@ -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): diff --git a/app/templates/add_book.html b/app/templates/add_book.html index 6326174..9a97139 100755 --- a/app/templates/add_book.html +++ b/app/templates/add_book.html @@ -68,17 +68,12 @@ Check the bibliography. How diverse are the references in this book?



Check the writing. Who is speaking? Is the voice more often male or female?
-{{ form.diversity(min=1, max=100, oninput="outputUpdate3(value)") }}   +{{ form.gender(min=1, max=100, oninput="outputUpdate3(value)") }}   {{ form.gender.data }} % female


Who are you? {{ render_field(form.who) }} -


-How much time have you spent with this item? -Include the time spent looking for it, and uploading it.
-{{ form.time (size = 50, class="form-control")}} hours -



diff --git a/app/templates/edit_book_detail.html b/app/templates/edit_book_detail.html index 2fa5268..7a9675f 100755 --- a/app/templates/edit_book_detail.html +++ b/app/templates/edit_book_detail.html @@ -1,22 +1,36 @@ {% extends 'base.html' %} {% block main %} +{% from "_formhelpers.html" import render_field %} + + + +
back - - {{ form.csrf_token }}

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

- +
+
-

+
- {{ form.author.label }} @@ -25,28 +39,45 @@ {% for author in form.author %} - + {% endfor %} -
{{ author.author_name }}{{ author.author_name (size=50, class="form-control") }}
-

-
- Category: {{ form.category(size=20, - class="form-control") }} -
-
- Year published: {{ form.year_published(size=8, class="form-control") }} -
+
+
+ Category:*
{{ form.category(size=50, class="form-control") }}

+ Year published:
{{ form.year_published(size=8, class="form-control") }}

+ +How different is this item to the rest of the collection? +Or is it more of the same?
+{{ form.sameness(min=0, max=100, oninput="outputUpdate(value)") }}   +{{ form.sameness.data }} % different + +


+ +Check the bibliography. How diverse are the references in this book?
+{{ form.diversity(min=0, max=100, oninput="outputUpdate2(value)") }}   +{{ form.diversity.data }} % diverse + +


+ +Check the writing. Who is speaking? Is the voice more often male or female?
+{{ form.gender(min=1, max=100, oninput="outputUpdate3(value)") }}   +{{ form.gender.data }} % female + +


+Who are you? {{ render_field(form.who)}} +


+
- Current file: {{ book.file }} + Current file: {{ book.file }}      Upload new file: {{form.file}}
- Upload new file: {{form.file}} +
- If uploading, write a new message: {{form.message(size=150, class="form-control") }} + If uploading, write a new message:
{{form.message(size=135, class="form-control") }}

diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 06690c1..25ad556 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -1,6 +1,8 @@ {% extends 'base.html' %} {% block main %} + +

{{ book.title }}

@@ -58,10 +60,6 @@ Who is uploading
{{ book.who or '?' }} - - How much time has been spent with this item?
- {{ book.time or '?' }} - diff --git a/app/views.py b/app/views.py index b8b4447..04dcd31 100755 --- a/app/views.py +++ b/app/views.py @@ -172,7 +172,7 @@ def remove_book_by_id(id): @app.route('/books//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,7 +267,6 @@ def add_book(): sameness = upload_form.sameness.data gender = upload_form.gender.data diversity = upload_form.diversity.data - time = upload_form.time.data who = upload_form.who.data if year_published=="": @@ -308,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") @@ -667,17 +674,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) book.scapeX = float(row['scapeX']) book.scapeY = float(row['scapeY']) diff --git a/import_csv.py b/import_csv.py index df681c0..de0df75 100644 --- a/import_csv.py +++ b/import_csv.py @@ -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(',') From 4fd80f4c65bc592e3c1f41e30d43375b1a66b7e3 Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 11 Jun 2018 17:57:22 +0200 Subject: [PATCH 3/8] edited add_stack page --- app/static/js/app.js | 27 ++++++++++++++++++++++++--- app/templates/about.html | 7 ++++--- app/templates/add_book.html | 2 +- app/templates/add_stack.html | 18 ++++++++++++++++-- app/templates/home.html | 4 ++-- app/templates/show_books.html | 6 +++--- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/app/static/js/app.js b/app/static/js/app.js index 10eb513..0a59cea 100755 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -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 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"; } diff --git a/app/templates/about.html b/app/templates/about.html index 67aae18..67ab4db 100755 --- a/app/templates/about.html +++ b/app/templates/about.html @@ -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.

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

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

- It starts at XPUB, but can go anywhere we want it to.

+Are you interested in how this library works? Have a look at the source code in our git. +

What's the deal with the stacks?

diff --git a/app/templates/add_book.html b/app/templates/add_book.html index 6326174..2c95484 100755 --- a/app/templates/add_book.html +++ b/app/templates/add_book.html @@ -36,7 +36,7 @@ function outputUpdate3(gender) {
Title:*
{{ form.title (size=50, class="form-control") }}

- Author(s):* + Author(s):* diff --git a/app/templates/add_stack.html b/app/templates/add_stack.html index c960eb3..5f9a8f0 100644 --- a/app/templates/add_stack.html +++ b/app/templates/add_stack.html @@ -22,12 +22,26 @@ {{form.hidden_tag()}}
{{ render_field(form.stack_name)}} -{{ render_field(form.stack_description)}} +
+Add a nice description: {{ form.stack_description(size=90, class="form-control") }} +
{{ render_field(form.stack_author)}} +
+ +
+
+
+

Stacks currently in the library

+ diff --git a/app/templates/home.html b/app/templates/home.html index 089c2ba..e36b2ed 100755 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -3,10 +3,10 @@ {% block main %}

XPPL

-

This is the awesome library of Experimental Publishing.
+

Welcome to our digital library.
On instance: {{server}} / From: {{client}}
-This might only be one interface to this library: +Feel free to browse our catalogue, interfaced in many different ways.

Scape diff --git a/app/templates/show_books.html b/app/templates/show_books.html index 2c2e6fb..94dba3b 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -66,9 +66,9 @@ {% else %}
  • - |----------|
    - |----------|
    - |----------|
    + XXXXXXXXXX
    + XXXXXXXXXX
    + XXXXXXXXXX
    {% endfor %} From aa3c461d2ee925956eef537ef4ca0aa12caaf873 Mon Sep 17 00:00:00 2001 From: nberting Date: Mon, 11 Jun 2018 18:09:17 +0200 Subject: [PATCH 4/8] added outlier search category --- app/forms.py | 3 ++- app/templates/red_link.html | 7 ++----- app/templates/show_book_detail.html | 2 +- app/views.py | 6 ++++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/forms.py b/app/forms.py index 3c749ac..6083f5a 100755 --- a/app/forms.py +++ b/app/forms.py @@ -76,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') diff --git a/app/templates/red_link.html b/app/templates/red_link.html index 22f101d..77883b0 100755 --- a/app/templates/red_link.html +++ b/app/templates/red_link.html @@ -60,19 +60,16 @@
  • -
    +
    +
    Category: {{ form.category(size=27, class="form-control") }}
    -
    - Year published: {{ form.year_published(size=8, class="form-control") }} -

    {{ form.file }} {{ form.upload }} {{ form.wish }}
    -

    go back home


    diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 25ad556..3667538 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -93,7 +93,7 @@
    {% else %} diff --git a/app/views.py b/app/views.py index b8b9882..9548e4f 100755 --- a/app/views.py +++ b/app/views.py @@ -524,6 +524,9 @@ 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) @@ -531,8 +534,7 @@ def search_results(searchtype, query, viewby): 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')) From 4161d01d56ab31117595ed96612e251dd325fea9 Mon Sep 17 00:00:00 2001 From: nberting Date: Mon, 11 Jun 2018 18:15:58 +0200 Subject: [PATCH 5/8] link to add stack on show book detail --- app/templates/show_book_detail.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 3667538..056d5b0 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -63,6 +63,7 @@ + Add book to Stack ===>

    download {{ book.fileformat }}
    From 36c1590e241767c98861d0d89a7785c59f45c64d Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 11 Jun 2018 18:23:42 +0200 Subject: [PATCH 6/8] edited stack detail --- app/templates/show_stack_detail.html | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html index 021460a..b40c49d 100644 --- a/app/templates/show_stack_detail.html +++ b/app/templates/show_stack_detail.html @@ -34,18 +34,11 @@ {% endfor %}

    -

    Add some more books

    - -

    - Remove stack

    -

    - Edit title and/or description

    - - - +

    Edit title and/or description

    +

    Remove stack

    Go back to the other stacks

    From 1575ba828ffd07b5703511ca7fb5c8e0fd3077b7 Mon Sep 17 00:00:00 2001 From: nberting Date: Mon, 11 Jun 2018 18:45:09 +0200 Subject: [PATCH 7/8] update css grid responsiveness --- app/static/css/style.css | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index 7fc3444..c7a3740 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -357,7 +357,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; @@ -365,15 +365,16 @@ box-sizing: border-box; align-items: top; 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; } -} + .gridbox { display: inline-block; From 5c87a17f6ec1d53739f82df298232d26ccc8d811 Mon Sep 17 00:00:00 2001 From: nberting Date: Mon, 11 Jun 2018 19:16:06 +0200 Subject: [PATCH 8/8] goddamn bracket missing from css file --- app/static/css/style.css | 4 +++- app/templates/show_book_detail.html | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index c7a3740..f319f47 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -365,6 +365,7 @@ box-sizing: border-box; align-items: top; justify-items: center; } +} @media screen and (max-width: 600px) { .grid{ @@ -374,7 +375,7 @@ box-sizing: border-box; align-items: top; justify-items: center; } - +} .gridbox { display: inline-block; @@ -382,6 +383,7 @@ box-sizing: border-box; align-items: center; justify-items: center; } + .gridbox:hover{ opacity: 0.5; } diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 056d5b0..9bef803 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -1,9 +1,8 @@ {% extends 'base.html' %} {% block main %} - -
    +

    {{ book.title }}

    @@ -63,6 +62,7 @@ +
    Add book to Stack ===>

    download {{ book.fileformat }} @@ -87,18 +87,18 @@ {% endfor %}
    - - {% if book.file %} - - - {% else %} - {% endif %} +{% if book.file %} + + +{% else %} +{% endif %}