mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Update landing page.
This commit is contained in:
parent
bf00670784
commit
a5b7ccaeb7
@ -0,0 +1,21 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import MultipleFileField, SelectField, StringField, SubmitField
|
||||
from wtforms.validators import DataRequired, Length
|
||||
|
||||
|
||||
class CreateCorpusForm(FlaskForm):
|
||||
description = StringField(
|
||||
'Description',
|
||||
validators=[DataRequired(), Length(1, 64)]
|
||||
)
|
||||
files = MultipleFileField('Files')
|
||||
title = StringField(
|
||||
'Title',
|
||||
validators=[DataRequired(), Length(1, 32)]
|
||||
)
|
||||
submit = SubmitField('Create corpus')
|
||||
'''
|
||||
def validate_files(form, field):
|
||||
for file in form.files.getlist[field.name]:
|
||||
if file.mimetype
|
||||
'''
|
@ -1,14 +1,47 @@
|
||||
from flask import render_template
|
||||
from flask import current_app, flash, redirect, render_template, request, url_for
|
||||
from flask_login import current_user, login_required
|
||||
from ..models import User
|
||||
from ..tables import AdminUserTable, AdminUserItem
|
||||
from . import main
|
||||
from .forms import CreateCorpusForm
|
||||
from ..decorators import admin_required
|
||||
from flask_login import login_required
|
||||
import os
|
||||
|
||||
|
||||
@main.route('/')
|
||||
def index():
|
||||
return render_template('main/index.html.j2', title='Portal')
|
||||
@main.route('/', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def dashboard():
|
||||
create_corpus_form = CreateCorpusForm()
|
||||
|
||||
if create_corpus_form.validate_on_submit():
|
||||
app = current_app._get_current_object()
|
||||
files = request.FILES
|
||||
print(files)
|
||||
corpus = {
|
||||
'description': create_corpus_form.description.data,
|
||||
'files': [],
|
||||
'owner': current_user.id,
|
||||
'title': create_corpus_form.title.data
|
||||
}
|
||||
corpus_dir = os.path.join(
|
||||
app.config['OPAQUE_FILES'],
|
||||
'corpora',
|
||||
corpus['title']
|
||||
)
|
||||
|
||||
try:
|
||||
os.mkdir(corpus_dir)
|
||||
except FileExistsError:
|
||||
flash('FileExistsError')
|
||||
else:
|
||||
flash('Corpus created!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
return render_template(
|
||||
'main/dashboard.html.j2',
|
||||
title='Dashboard',
|
||||
create_corpus_form=create_corpus_form
|
||||
)
|
||||
|
||||
|
||||
@main.route('/about')
|
||||
|
@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from flask import current_app, flash, redirect, render_template, url_for, request
|
||||
from flask import current_app, flash, redirect, render_template, url_for
|
||||
from . import services
|
||||
from flask_login import current_user, login_required
|
||||
from .forms import OCRJobForm
|
||||
@ -18,7 +18,7 @@ def ocr():
|
||||
id = hashlib.md5(
|
||||
(current_user.username + '_' + datetime.now().isoformat()).encode()
|
||||
).hexdigest()
|
||||
dir = os.path.join(app.config['OPAQUE_UPLOAD_DIRECTORY'], id)
|
||||
dir = os.path.join(app.config['OPAQUE_FILES'], 'jobs', id)
|
||||
|
||||
try:
|
||||
os.mkdir(dir)
|
||||
|
@ -29,7 +29,7 @@
|
||||
<div class="navbar-fixed">
|
||||
<nav>
|
||||
<div class="nav-wrapper">
|
||||
<a href="{{ url_for('main.index') }}" class="brand-logo"><i class="material-icons">opacity</i>Opaque</a>
|
||||
<a href="{{ url_for('main.dashboard') }}" class="brand-logo"><i class="material-icons">opacity</i>Opaque</a>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<ul class="right hide-on-med-and-down">
|
||||
<li><a id="nav-notifications" class="dropdown-trigger" href="#!" data-target="nav-notifications-dropdown"><i class="material-icons">notifications</i></a></li>
|
||||
@ -60,7 +60,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
<li><a href="{{ url_for('main.index') }}"><i class="material-icons">opacity</i>Portal</a></li>
|
||||
<li><a href="{{ url_for('main.dashboard') }}"><i class="material-icons">dashboard</i>Dashboard</a></li>
|
||||
<li><a href="{{ url_for('main.about') }}"><i class="material-icons">info</i>About</a></li>
|
||||
<li class="no-padding">
|
||||
<ul class="collapsible collapsible-accordion">
|
||||
@ -78,7 +78,6 @@
|
||||
{% if current_user.is_authenticated %}
|
||||
<li><div class="divider"></div></li>
|
||||
<li><a class="subheader">Account</a></li>
|
||||
<li><a href="#!"><i class="material-icons">dashboard</i>Dashboard</a></li>
|
||||
<li><a href="{{ url_for('auth.settings') }}"><i class="material-icons">settings</i>Settings</a></li>
|
||||
{% endif %}
|
||||
{% if current_user.is_administrator() %} <!-- Shows only for admins -->
|
||||
|
66
app/templates/main/dashboard.html.j2
Normal file
66
app/templates/main/dashboard.html.j2
Normal file
@ -0,0 +1,66 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="col s12 m4">
|
||||
<h3>Corpora</h3>
|
||||
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,</p>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m8">
|
||||
<ul class="collection">
|
||||
<li class="collection-item avatar">
|
||||
<i class="material-icons circle">book</i>
|
||||
<span class="title">Utopias</span>
|
||||
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed dia</p>
|
||||
<a href="#!" class="secondary-content"><i class="material-icons">send</i></a>
|
||||
</li>
|
||||
<li class="collection-item avatar">
|
||||
<i class="material-icons circle">book</i>
|
||||
<span class="title">Dystopias</span>
|
||||
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed dia</p>
|
||||
<a href="#!" class="secondary-content"><i class="material-icons">send</i></a>
|
||||
</li>
|
||||
<li class="collection-item avatar">
|
||||
<i class="material-icons circle">book</i>
|
||||
<span class="title">Mungo Park - Travel books</span>
|
||||
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed dia</p>
|
||||
<a href="#!" class="secondary-content"><i class="material-icons">send</i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col s12">
|
||||
<h3>Create new Corpus</h3>
|
||||
</div>
|
||||
|
||||
<div class="col s12">
|
||||
<div class="card small">
|
||||
<div class="card-content">
|
||||
<form method="POST">
|
||||
{{ create_corpus_form.hidden_tag() }}
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">title</i>
|
||||
{{ create_corpus_form.title() }}
|
||||
{{ create_corpus_form.title.label }}
|
||||
{% for error in create_corpus_form.title.errors %}
|
||||
<span class="helper-text red-text">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">description</i>
|
||||
{{ create_corpus_form.description() }}
|
||||
{{ create_corpus_form.description.label }}
|
||||
{% for error in create_corpus_form.description.errors %}
|
||||
<span class="helper-text red-text">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
{{ create_corpus_form.submit(class='btn') }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -1,53 +0,0 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block page_content %}
|
||||
<h2>Services</h2>
|
||||
<div class="row">
|
||||
<div class="col s12 m4">
|
||||
<div class="card small">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Optical Character Recognition</span>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m4">
|
||||
<div class="card small">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Natural language processing</span>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m4">
|
||||
<div class="card small">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Text analysis</span>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Statistics</h2>
|
||||
<div class="row">
|
||||
<div class="col s12 m4">
|
||||
<div class="card small">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Server activity</span>
|
||||
<div class="center">
|
||||
<img src="{{ url_for('static', filename='images/server_activity.png') }}" alt="server activity"
|
||||
class="responsive-image">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
|
||||
-->
|
||||
{% endblock %}
|
@ -12,9 +12,9 @@ class Config:
|
||||
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||
OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN')
|
||||
OPAQUE_FILES = os.environ.get('OPAQUE_FILES')
|
||||
OPAQUE_MAIL_SUBJECT_PREFIX = '[Opaque]'
|
||||
OPAQUE_MAIL_SENDER = 'Opaque Development <dev.opaque@gmail.com>'
|
||||
OPAQUE_UPLOAD_DIRECTORY = os.environ.get('OPAQUE_UPLOAD_DIRECTORY')
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user