mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
Add first iteration of query and analysis corpora page
This commit is contained in:
parent
409d94d0ae
commit
b46090133d
@ -1,7 +1,7 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (MultipleFileField, StringField, SubmitField,
|
||||
ValidationError)
|
||||
from wtforms.validators import DataRequired, Length
|
||||
ValidationError, IntegerField)
|
||||
from wtforms.validators import DataRequired, Length, NumberRange
|
||||
|
||||
|
||||
class CreateCorpusForm(FlaskForm):
|
||||
@ -16,3 +16,11 @@ class CreateCorpusForm(FlaskForm):
|
||||
if not file.filename.lower().endswith('.vrt'):
|
||||
raise ValidationError('File does not have an approved '
|
||||
'extension: .vrt')
|
||||
|
||||
|
||||
class QueryForm(FlaskForm):
|
||||
query = StringField('CQP Query', validators=[DataRequired()])
|
||||
# hits_per_page = IntegerField('Hits per page',
|
||||
# validators=[DataRequired(),
|
||||
# NumberRange(min=10, max=50)])
|
||||
submit = SubmitField('Start Query')
|
||||
|
@ -3,12 +3,13 @@ from flask import (abort, current_app, flash, redirect, request,
|
||||
render_template, url_for, send_from_directory)
|
||||
from flask_login import current_user, login_required
|
||||
from . import main
|
||||
from .forms import CreateCorpusForm
|
||||
from .forms import CreateCorpusForm, QueryForm
|
||||
from .. import db
|
||||
from ..models import Corpus, CorpusFile, Job
|
||||
from werkzeug.utils import secure_filename
|
||||
import os
|
||||
import threading
|
||||
import logging
|
||||
|
||||
|
||||
@main.route('/')
|
||||
@ -62,12 +63,19 @@ def corpus_download(corpus_id):
|
||||
filename=file)
|
||||
|
||||
|
||||
@main.route('/corpora/<int:corpus_id>/analysis')
|
||||
@main.route('/corpora/<int:corpus_id>/analysis', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def corpus_analysis(corpus_id):
|
||||
corpus = Corpus.query.get_or_404(corpus_id)
|
||||
form = QueryForm()
|
||||
if form.validate_on_submit():
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('Data has been sent!')
|
||||
flash('Query has been sent!')
|
||||
return redirect(url_for('main.corpus_analysis', corpus_id=corpus_id))
|
||||
return render_template('main/corpora/corpus_analysis.html.j2',
|
||||
corpus=corpus,
|
||||
form=form,
|
||||
title='Corpus: ' + corpus.title)
|
||||
|
||||
|
||||
|
@ -29,26 +29,43 @@
|
||||
</div>
|
||||
<div class="col s12 m3 l3 sticky">
|
||||
<div class="card">
|
||||
<form method="POST">
|
||||
<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>
|
||||
{{ form.hidden_tag() }}
|
||||
<span class="card-title">Query and analysis</span>
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">search</i>
|
||||
<textarea id="{{ form.query.id }}" name="{{ form.query.id }}" required="" type="text" value="" class="materialize-textarea"></textarea>
|
||||
{{ form.query.label }}
|
||||
{% for error in form.query.errors %}
|
||||
<span class="helper-text red-text">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="right-align">
|
||||
{{ form.submit(class='btn') }}
|
||||
</div>
|
||||
<!-- <br>
|
||||
<span class="card-title">Help</span>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="http://cwb.sourceforge.net/files/CQP_Tutorial/">
|
||||
CQP Query Language Tutorial</a>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<span class="card-title">Options</span>
|
||||
<select>
|
||||
<option value="" disabled selected>Choose your option</option>
|
||||
<option value="1">10</option>
|
||||
<option value="2">20</option>
|
||||
<option value="3">25</option>
|
||||
<option value="3">50</option>
|
||||
</select>
|
||||
<label>Materialize Select</label>
|
||||
<br>
|
||||
<span class="card-title">Download Results</span>
|
||||
</div> -->
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user