diff --git a/app/main/views.py b/app/main/views.py index 52dce8d49a05c0b1a804628b86d4115d5ea019ea..5ef53c422d802117399515cd8396957ee1ca61f1 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -6,6 +6,7 @@ from . import main from .forms import CreateCorpusForm from .. import db from ..models import Corpus, CorpusFile, Job +from werkzeug.utils import secure_filename import os import threading @@ -38,7 +39,7 @@ def corpus(corpus_id): return render_template('main/corpora/corpus.html.j2', corpus=corpus, files=files, - title='Corpus') + title='Corpus: ' + corpus.title) @main.route('/corpora/<int:corpus_id>/download') @@ -61,6 +62,15 @@ def corpus_download(corpus_id): filename=file) +@main.route('/corpora/<int:corpus_id>/analysis') +@login_required +def corpus_analysis(corpus_id): + corpus = Corpus.query.get_or_404(corpus_id) + return render_template('main/corpora/corpus_analysis.html.j2', + corpus=corpus, + title='Corpus: ' + corpus.title) + + @main.route('/dashboard', methods=['GET', 'POST']) @login_required def dashboard(): @@ -85,15 +95,16 @@ def dashboard(): flash('OSError!') else: for file in create_corpus_form.files.data: - file.save(os.path.join(dir, file.filename)) - dir = os.path.join(str(corpus.user_id), - 'corpora', - str(corpus.id)) - corpus_file = CorpusFile(filename=file.filename, + filename = secure_filename(file.filename) + file.save(os.path.join(dir, filename)) + file_dir = os.path.join(str(corpus.user_id), + 'corpora', + str(corpus.id)) + corpus_file = CorpusFile(filename=filename, corpus_id=corpus.id, - dir=dir) + dir=file_dir) db.session.add(corpus_file) - db.session.commit() + db.session.commit() flash('Corpus created!') return redirect(url_for('main.dashboard')) diff --git a/app/services/views.py b/app/services/views.py index 49d008afffba5f6ec26863d8481cbb64aa480dea..413d5573868c5aa44e54b6ae87be2f66597d2d82 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -53,7 +53,6 @@ def service(service_handle): db.session.commit() else: for file in new_job_form.files.data: - ''' TODO: Use secure filename ''' filename = secure_filename(file.filename) file.save(os.path.join(dir, filename)) job_input = JobInput( diff --git a/app/static/css/opaque.css b/app/static/css/opaque.css index f46e2f60039409b9f019e01d8ca78970e097a3a3..7fa300c92ce5a266ff468ad5b175be4caeb5c4c6 100644 --- a/app/static/css/opaque.css +++ b/app/static/css/opaque.css @@ -73,3 +73,11 @@ indicator will show up how the column is sorted right now.; */ top:-10px; right:-5px; } + +/* Sticy side elements */ +.sticky { + position: -webkit-sticky; + position: sticky; + top: 80px; + padding: 50px; +} diff --git a/app/templates/403.html.j2 b/app/templates/403.html.j2 index 70f7d846a9eada674af5515946744574a28fde89..5381a3def7e316e0d9dea29048f9659055b1854b 100644 --- a/app/templates/403.html.j2 +++ b/app/templates/403.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="page-header"> diff --git a/app/templates/404.html.j2 b/app/templates/404.html.j2 index 85a2a8423e5535223be4adc026ce219bc87ce8d8..2e9e5e143a111b3dcf497ee683c7c56e1ff91af2 100644 --- a/app/templates/404.html.j2 +++ b/app/templates/404.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="page-header"> diff --git a/app/templates/500.html.j2 b/app/templates/500.html.j2 index 3e869656022b37ecb9bbeecb2cd52acb2456d3f0..d1314384f182c579a6b53e464c8157448df3f639 100644 --- a/app/templates/500.html.j2 +++ b/app/templates/500.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="page-header"> diff --git a/app/templates/admin/admin.html.j2 b/app/templates/admin/admin.html.j2 index 673f6cbc460d853c37a4a4718bfee47f82c9b104..8fbb368ce542867bfc0a49ab1cd7a3fd0e1bc775 100644 --- a/app/templates/admin/admin.html.j2 +++ b/app/templates/admin/admin.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "full_width.html.j2" %} {% block page_content %} <div class="col s12"> diff --git a/app/templates/admin/admin_user_page.html.j2 b/app/templates/admin/admin_user_page.html.j2 index 019442354b3b7d4b58cacd4dbe758b67380b9a7b..c37f08f08cc304dca471631b6696ab1a20502d19 100644 --- a/app/templates/admin/admin_user_page.html.j2 +++ b/app/templates/admin/admin_user_page.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m6"> diff --git a/app/templates/admin/edit_profile_admin.html.j2 b/app/templates/admin/edit_profile_admin.html.j2 index af27c067631cbe3b4353bdd747082e86acc5dba0..f96aabc651ea0d6c21e28240a5f1e54d227b47ef 100644 --- a/app/templates/admin/edit_profile_admin.html.j2 +++ b/app/templates/admin/edit_profile_admin.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m8"> diff --git a/app/templates/auth/login.html.j2 b/app/templates/auth/login.html.j2 index cc649b6acee38d730e5ecdbf810e776eca1dcf53..df8dce84732ef9907d82c24a2e12b6b5c21b98bc 100644 --- a/app/templates/auth/login.html.j2 +++ b/app/templates/auth/login.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/auth/register.html.j2 b/app/templates/auth/register.html.j2 index acbaa2bef4eb54b2dfae41d2f9b5e7ddf52a4509..0c8ee6647801fa59858daaf19b5f288a033e1b8d 100644 --- a/app/templates/auth/register.html.j2 +++ b/app/templates/auth/register.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/auth/reset_password.html.j2 b/app/templates/auth/reset_password.html.j2 index 5985c7cfd805cc91182185f69ca1a77b0d7f0139..dd4efb883ea9be469da35ebdeeb1f42a7bf35d88 100644 --- a/app/templates/auth/reset_password.html.j2 +++ b/app/templates/auth/reset_password.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/auth/reset_password_request.html.j2 b/app/templates/auth/reset_password_request.html.j2 index 8ef88700bfd61a04647f7318b62db8b4e2579f09..895e4f80d7311670a2ff8acb1512e1630a48e47d 100644 --- a/app/templates/auth/reset_password_request.html.j2 +++ b/app/templates/auth/reset_password_request.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/auth/unconfirmed.html.j2 b/app/templates/auth/unconfirmed.html.j2 index 78ac1510c0c81c2280f29509e5875dd65416ff5a..d2ecd62a9d368f72e7ea0d715e37fa38a165fd67 100644 --- a/app/templates/auth/unconfirmed.html.j2 +++ b/app/templates/auth/unconfirmed.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block title %}Opaque - Confirm your account{% endblock %} diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index 487241d6a00a0acaa1068cd265b590bf65013ec3..a3206a90a6000e4058bf4cf47d91223ede4993ef 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -24,8 +24,8 @@ {% if current_user.is_dark == True %} DarkReader.enable({ brightness: 100, - contrast: 90, - sepia: 10 + contrast: 100, + sepia: 0 }); {% else %} DarkReader.disable(); @@ -182,15 +182,9 @@ </header> <main class="grey lighten-5"> - <div class="container"> - <div class="row"> - <div class="col s12"> - <h2>{% if title %}{{ title }}{% else %}Unnamed page{% endif %}</h2> - </div> - {% block page_content %} + {% block main_block %} {% endblock %} - </div> - </div> + </main> <footer class="page-footer"> diff --git a/app/templates/full_width.html.j2 b/app/templates/full_width.html.j2 new file mode 100644 index 0000000000000000000000000000000000000000..b4de437f0385eab9824cfda346c17b2e9d369c7e --- /dev/null +++ b/app/templates/full_width.html.j2 @@ -0,0 +1,11 @@ +{% extends "base.html.j2" %} + +{% block main_block %} +<div class="row"> + <div class="col s12"> + <h2>{% if title %}{{ title }}{% else %}Unnamed page{% endif %}</h2> + </div> + {% block page_content %} + {% endblock %} +</div> +{% endblock %} diff --git a/app/templates/limited_width.html.j2 b/app/templates/limited_width.html.j2 new file mode 100644 index 0000000000000000000000000000000000000000..272433203abde05d887bdd2e89116b5a9b4d928c --- /dev/null +++ b/app/templates/limited_width.html.j2 @@ -0,0 +1,13 @@ +{% extends "base.html.j2" %} + +{% block main_block %} +<div class="container"> + <div class="row"> + <div class="col s12"> + <h2>{% if title %}{{ title }}{% else %}Unnamed page{% endif %}</h2> + </div> + {% block page_content %} + {% endblock %} + </div> +</div> +{% endblock %} diff --git a/app/templates/main/corpora/corpus.html.j2 b/app/templates/main/corpora/corpus.html.j2 index 2751e4e2e5f3b21ed176ccab7d3a68458f9c3f69..321f9c284e0739ceb0e9daa9b598d2d176733fa4 100644 --- a/app/templates/main/corpora/corpus.html.j2 +++ b/app/templates/main/corpora/corpus.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <script> @@ -84,6 +84,7 @@ <!-- Confirm deletion of job with modal dialogue Modal Trigger--> <a href="#modal-confirm-delete" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete Corpus</a> + <a href="{{ url_for('main.corpus_analysis', corpus_id=corpus.id) }}" class="waves-effect waves-light btn "><i class="material-icons left">help</i>Analyse</a> <!-- Modal Strucutre --> <div id="modal-confirm-delete" class="modal"> <div class="modal-content"> diff --git a/app/templates/main/corpora/corpus_analysis.html.j2 b/app/templates/main/corpora/corpus_analysis.html.j2 new file mode 100644 index 0000000000000000000000000000000000000000..cbe60bcf451f412855b19658e5cb3054c6cee45e --- /dev/null +++ b/app/templates/main/corpora/corpus_analysis.html.j2 @@ -0,0 +1,54 @@ +{% extends "full_width.html.j2" %} + +{% block page_content %} +<div class="col s12 m9 l9"> + <div class="card"> + <div class="card-content"> + <span class="card-title">Query Results</span> + <table class="responsive highlight"> + <tr> + <th>Firstname</th> + <th>Lastname</th> + <th>Age</th> + </tr> + <tr> + <td>Jill</td> + <td>Smith</td> + <td>50</td> + </tr> + {% for i in range(0,51) %} + <tr> + <td>Eve</td> + <td>Jackson</td> + <td>94</td> + </tr> + {% endfor %} + </table> + </div> + </div> +</div> +<div class="col s12 m3 l3 sticky"> + <div class="card"> + <div class="card-content"> + <span class="card-title">Card Title</span> + <table class="responsive highlight"> + <tr> + <th>Firstname</th> + <th>Lastname</th> + <th>Age</th> + </tr> + <tr> + <td>Jill</td> + <td>Smith</td> + <td>50</td> + </tr> + <tr> + <td>Eve</td> + <td>Jackson</td> + <td>94</td> + </tr> + </table> + </div> + </div> + </div> +{% endblock %} diff --git a/app/templates/main/dashboard.html.j2 b/app/templates/main/dashboard.html.j2 index 20df65dfcfb0a2cf3d384420020c02caf78dab55..2f77ba77f0c8e39421ba42707ba90c536c37e42e 100644 --- a/app/templates/main/dashboard.html.j2 +++ b/app/templates/main/dashboard.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/main/index.html.j2 b/app/templates/main/index.html.j2 index a796f3bf57fbd24c749f5f351f3b28ed25e06ad1..2abd190cca4491f7abad3974536497fac1979f61 100644 --- a/app/templates/main/index.html.j2 +++ b/app/templates/main/index.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/main/jobs/job.html.j2 b/app/templates/main/jobs/job.html.j2 index 4e045d36175ebde446cd8c875b568adaad1dec96..1a43d9dbf5615f82f9ebf3db597d421d6035d6ca 100644 --- a/app/templates/main/jobs/job.html.j2 +++ b/app/templates/main/jobs/job.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <script> diff --git a/app/templates/profile/index.html.j2 b/app/templates/profile/index.html.j2 index 8ce29ea6ea64208626edc009f9429d993951aaf4..0f09b4ca0e38d8a31ada4b01a12754542729eac6 100644 --- a/app/templates/profile/index.html.j2 +++ b/app/templates/profile/index.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/services/nlp.html.j2 b/app/templates/services/nlp.html.j2 index c5353ab1401f2adbabcaa4aac50f8eb923e05c6e..521296cf3aa37b6c1b5743a0ae6d1ea962fd0c8d 100644 --- a/app/templates/services/nlp.html.j2 +++ b/app/templates/services/nlp.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4"> diff --git a/app/templates/services/ocr.html.j2 b/app/templates/services/ocr.html.j2 index c04c09c87072d7942f66fdcebe0179d5069b2e94..68887f83889c59a0346f096a3307861a539939d2 100644 --- a/app/templates/services/ocr.html.j2 +++ b/app/templates/services/ocr.html.j2 @@ -1,4 +1,4 @@ -{% extends "base.html.j2" %} +{% extends "limited_width.html.j2" %} {% block page_content %} <div class="col s12 m4">