diff --git a/app/corpora/cqi_over_socketio/__init__.py b/app/corpora/cqi_over_socketio/__init__.py index c122e12e..cd02bedd 100644 --- a/app/corpora/cqi_over_socketio/__init__.py +++ b/app/corpora/cqi_over_socketio/__init__.py @@ -62,7 +62,9 @@ def connect(auth): if corpus is None: # return {'code': 404, 'msg': 'Not Found'} raise ConnectionRefusedError('Not Found') - if not (corpus.user == current_user or current_user.is_administrator()): + if not (corpus.user == current_user + or current_user.is_following_corpus(corpus) + or current_user.is_administrator()): # return {'code': 403, 'msg': 'Forbidden'} raise ConnectionRefusedError('Forbidden') if corpus.status not in [ diff --git a/app/corpora/forms.py b/app/corpora/forms.py index 12ec1d9c..8403e621 100644 --- a/app/corpora/forms.py +++ b/app/corpora/forms.py @@ -1,6 +1,7 @@ from flask_wtf import FlaskForm from flask_wtf.file import FileField, FileRequired from wtforms import ( + BooleanField, StringField, SubmitField, TextAreaField, diff --git a/app/corpora/routes.py b/app/corpora/routes.py index f3cdf8f1..4b10fa2c 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -1,3 +1,4 @@ +from datetime import datetime from flask import ( abort, current_app, @@ -5,37 +6,130 @@ from flask import ( Markup, redirect, render_template, - send_from_directory + request, + send_from_directory, + url_for ) from flask_login import current_user, login_required from threading import Thread +import jwt import os -from app import db -from app.models import Corpus, CorpusFile, CorpusStatus +from app import db, hashids +from app.models import Corpus, CorpusFile, CorpusStatus, User from . import bp -from .forms import CreateCorpusFileForm, CreateCorpusForm, UpdateCorpusFileForm +from .forms import ( + CreateCorpusFileForm, + CreateCorpusForm, + UpdateCorpusFileForm +) -def user_can_read_corpus(user, corpus): - return corpus.user == user or user.is_administrator() or corpus.is_public +# @bp.route('/share/', methods=['GET', 'POST']) +# def share_corpus(token): +# try: +# payload = jwt.decode( +# token, +# current_app.config['SECRET_KEY'], +# algorithms=['HS256'], +# issuer=current_app.config['SERVER_NAME'], +# options={'require': ['iat', 'iss', 'sub']} +# ) +# except jwt.PyJWTError: +# return False +# corpus_hashid = payload.get('sub') +# corpus_id = hashids.decode(corpus_hashid) +# return redirect(url_for('.corpus', corpus_id=corpus_id)) -def user_can_update_corpus(user, corpus): - return corpus.user == user or user.is_administrator() - - -def user_can_delete_corpus(user, corpus): - return user_can_update_corpus(user, corpus) - - -@bp.route('') +@bp.route('//enable_is_public', methods=['POST']) @login_required -def corpora(): - query = Corpus.query.filter( - (Corpus.user_id == current_user.id) | (Corpus.is_public == True) +def enable_corpus_is_public(corpus_id): + corpus = Corpus.query.get_or_404(corpus_id) + if not (corpus.user == current_user or current_user.is_administrator()): + abort(403) + corpus.is_public = True + db.session.commit() + return '', 204 + + +@bp.route('//disable_is_public', methods=['POST']) +@login_required +def disable_corpus_is_public(corpus_id): + corpus = Corpus.query.get_or_404(corpus_id) + if not (corpus.user == current_user or current_user.is_administrator()): + abort(403) + corpus.is_public = False + db.session.commit() + return '', 204 + + +# @bp.route('//follow', methods=['GET', 'POST']) +# @login_required +# def follow_corpus(corpus_id): +# corpus = Corpus.query.get_or_404(corpus_id) +# user_hashid = request.args.get('user_id') +# if user_hashid is None: +# user = current_user +# else: +# if not current_user.is_administrator(): +# abort(403) +# else: +# user_id = hashids.decode(user_hashid) +# user = User.query.get_or_404(user_id) +# if not user.is_following_corpus(corpus): +# user.follow_corpus(corpus) +# db.session.commit() +# flash(f'You are following {corpus.title} now', category='corpus') +# return {}, 202 + + +@bp.route('//unfollow', methods=['GET', 'POST']) +@login_required +def unfollow_corpus(corpus_id): + corpus = Corpus.query.get_or_404(corpus_id) + user_hashid = request.args.get('user_id') + if user_hashid is None: + user = current_user + elif current_user.is_administrator(): + user_id = hashids.decode(user_hashid) + user = User.query.get_or_404(user_id) + else: + abort(403) + if user.is_following_corpus(corpus): + user.unfollow_corpus(corpus) + db.session.commit() + flash(f'You are not following {corpus.title} anymore', category='corpus') + return {}, 202 + + +# @bp.route('/add_permission///') +# def add_permission(corpus_id, user_id, permission): +# a = CorpusFollowerAssociation.query.filter_by(followed_corpus_id=corpus_id, following_user_id=user_id).first_or_404() +# a.add_permission(permission) +# db.session.commit() +# return 'ok' + + +# @bp.route('/remove_permission///') +# def remove_permission(corpus_id, user_id, permission): +# a = CorpusFollowerAssociation.query.filter_by(followed_corpus_id=corpus_id, following_user_id=user_id).first_or_404() +# a.remove_permission(permission) +# db.session.commit() +# return 'ok' + + +@bp.route('/public') +@login_required +def public_corpora(): + corpora = [ + c.to_json_serializeable() + for c in Corpus.query.filter(Corpus.is_public == True).all() + ] + return render_template( + 'corpora/public_corpora.html.j2', + corpora=corpora, + title='Corpora' ) - corpora = [c.to_json_serializeable() for c in query.all()] - return render_template('corpora/corpora.html.j2', corpora=corpora, title='Corpora') @bp.route('/create', methods=['GET', 'POST']) @@ -64,30 +158,38 @@ def create_corpus(): ) -@bp.route('/') +@bp.route('/', methods=['GET', 'POST']) @login_required def corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) - if not user_can_read_corpus(current_user, corpus): - abort(403) - return render_template( - 'corpora/corpus.html.j2', - corpus=corpus, - title='Corpus' - ) - - -# @bp.route('//update') -# @login_required -# def update_corpus(corpus_id): -# corpus = Corpus.query.get_or_404(corpus_id) -# if not user_can_update_corpus(current_user, corpus): -# abort(403) -# return render_template( -# 'corpora/update_corpus.html.j2', -# corpus=corpus, -# title='Corpus' -# ) + if corpus.user == current_user or current_user.is_administrator(): + # now = datetime.utcnow() + # payload = { + # 'exp': now + timedelta(weeks=1), + # 'iat': now, + # 'iss': current_app.config['SERVER_NAME'], + # 'sub': corpus.hashid + # } + # token = jwt.encode( + # payload, + # current_app.config['SECRET_KEY'], + # algorithm='HS256' + # ) + return render_template( + 'corpora/corpus.html.j2', + corpus=corpus, + # token=token, + title='Corpus' + ) + if current_user.is_following_corpus(corpus) or corpus.is_public: + corpus_files = [x.to_json_serializeable() for x in corpus.files] + return render_template( + 'corpora/public_corpus.html.j2', + corpus=corpus, + corpus_files=corpus_files, + title='Corpus' + ) + abort(403) @bp.route('/', methods=['DELETE']) @@ -100,7 +202,7 @@ def delete_corpus(corpus_id): db.session.commit() corpus = Corpus.query.get_or_404(corpus_id) - if not user_can_delete_corpus(current_user, corpus): + if not (corpus.user == current_user or current_user.is_administrator()): abort(403) thread = Thread( target=_delete_corpus, @@ -114,7 +216,9 @@ def delete_corpus(corpus_id): @login_required def analyse_corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) - if not user_can_read_corpus(current_user, corpus): + if not (corpus.user == current_user + or current_user.is_administrator() + or current_user.is_following_corpus(corpus)): abort(403) return render_template( 'corpora/analyse_corpus.html.j2', @@ -133,7 +237,7 @@ def build_corpus(corpus_id): db.session.commit() corpus = Corpus.query.get_or_404(corpus_id) - if not user_can_update_corpus(current_user, corpus): + if not (corpus.user == current_user or current_user.is_administrator()): abort(403) # Check if the corpus has corpus files if not corpus.files.all(): @@ -151,7 +255,7 @@ def build_corpus(corpus_id): @login_required def create_corpus_file(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) - if not user_can_update_corpus(current_user, corpus): + if not (corpus.user == current_user or current_user.is_administrator()): abort(403) form = CreateCorpusFileForm() if form.is_submitted(): diff --git a/app/main/routes.py b/app/main/routes.py index 9935c479..eff0dadd 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -1,7 +1,7 @@ from flask import flash, redirect, render_template, url_for from flask_login import current_user, login_required, login_user from app.auth.forms import LoginForm -from app.models import User +from app.models import Corpus, User from . import bp @@ -27,11 +27,20 @@ def faq(): @bp.route('/dashboard') @login_required def dashboard(): - users = [ - u.to_json_serializeable(filter_by_privacy_settings=True) for u - in User.query.filter(User.is_public == True, User.id != current_user.id).all() - ] - return render_template('main/dashboard.html.j2', title='Dashboard', users=users) + # users = [ + # u.to_json_serializeable(filter_by_privacy_settings=True) for u + # in User.query.filter(User.is_public == True, User.id != current_user.id).all() + # ] + # corpora = [ + # c.to_json_serializeable() for c + # in Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all() + # ] + return render_template( + 'main/dashboard.html.j2', + title='Dashboard', + # users=users, + # corpora=corpora + ) @bp.route('/dashboard2') diff --git a/app/models.py b/app/models.py index af3d1cfc..4c7a1362 100644 --- a/app/models.py +++ b/app/models.py @@ -68,6 +68,11 @@ class ProfilePrivacySettings(IntEnum): SHOW_EMAIL = 1 SHOW_LAST_SEEN = 2 SHOW_MEMBER_SINCE = 4 + +class CorpusFollowPermission(IntEnum): + VIEW = 1 + CONTRIBUTE = 2 + ADMINISTRATE = 4 # endregion enums @@ -298,6 +303,16 @@ class CorpusFollowerAssociation(db.Model): def __repr__(self): return f'' + def has_permission(self, permission): + return self.permissions & permission == permission + + def add_permission(self, permission): + if not self.has_permission(permission): + self.permissions += permission + + def remove_permission(self, permission): + if self.has_permission(permission): + self.permissions -= permission class User(HashidMixin, UserMixin, db.Model): __tablename__ = 'users' @@ -576,6 +591,18 @@ class User(HashidMixin, UserMixin, db.Model): self.profile_privacy_settings = 0 #endregion Profile Privacy settings + def follow_corpus(self, corpus): + if not self.is_following_corpus(corpus): + self.followed_corpora.append(corpus) + + def unfollow_corpus(self, corpus): + if self.is_following_corpus(corpus): + self.followed_corpora.remove(corpus) + + def is_following_corpus(self, corpus): + return corpus in self.followed_corpora + + def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False): json_serializeable = { 'id': self.hashid, @@ -623,6 +650,10 @@ class User(HashidMixin, UserMixin, db.Model): x.hashid: x.to_json_serializeable(relationships=True) for x in self.spacy_nlp_pipeline_models } + json_serializeable['followed_corpora'] = { + x.hashid: x.to_json_serializeable(relationships=True) + for x in self.followed_corpora + } if filter_by_privacy_settings: if not self.has_profile_privacy_setting(ProfilePrivacySettings.SHOW_EMAIL): diff --git a/app/static/js/App.js b/app/static/js/App.js index 532bff5c..87d44d71 100644 --- a/app/static/js/App.js +++ b/app/static/js/App.js @@ -8,7 +8,7 @@ class App { this.socket.on('PATCH', (patch) => {this.onPatch(patch);}); } - getUser(userId, backrefs=false, relationships=false) { + getUser(userId, backrefs=true, relationships=true) { if (userId in this.data.promises.getUser) { return this.data.promises.getUser[userId]; } diff --git a/app/static/js/ResourceLists/CorpusFileList.js b/app/static/js/ResourceLists/CorpusFileList.js index fd4ff480..c052b2ea 100644 --- a/app/static/js/ResourceLists/CorpusFileList.js +++ b/app/static/js/ResourceLists/CorpusFileList.js @@ -11,13 +11,14 @@ class CorpusFileList extends ResourceList { this.isInitialized = false; this.userId = listContainerElement.dataset.userId; this.corpusId = listContainerElement.dataset.corpusId; + if (this.userId === undefined || this.corpusId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} }); }); app.getUser(this.userId).then((user) => { - this.add(Object.values(user.corpora[this.corpusId].files)); + this.add(Object.values(user.corpora[this.corpusId].files || user.followed_corpora[this.corpusId].files)); this.isInitialized = true; }); } diff --git a/app/static/js/ResourceLists/CorpusList.js b/app/static/js/ResourceLists/CorpusList.js index e4af0b12..bf62ebed 100644 --- a/app/static/js/ResourceLists/CorpusList.js +++ b/app/static/js/ResourceLists/CorpusList.js @@ -8,8 +8,9 @@ class CorpusList extends ResourceList { constructor(listContainerElement, options = {}) { super(listContainerElement, options); this.listjs.list.addEventListener('click', (event) => {this.onClick(event)}); - this.isInitialized = false; + this.isInitialized = false this.userId = listContainerElement.dataset.userId; + if (this.userId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/JobInputList.js b/app/static/js/ResourceLists/JobInputList.js index 36cb47f7..7f1a5105 100644 --- a/app/static/js/ResourceLists/JobInputList.js +++ b/app/static/js/ResourceLists/JobInputList.js @@ -11,6 +11,7 @@ class JobInputList extends ResourceList { this.isInitialized = false; this.userId = listContainerElement.dataset.userId; this.jobId = listContainerElement.dataset.jobId; + if (this.userId === undefined || this.jobId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/JobList.js b/app/static/js/ResourceLists/JobList.js index 1fa14ea2..ff7f82b2 100644 --- a/app/static/js/ResourceLists/JobList.js +++ b/app/static/js/ResourceLists/JobList.js @@ -10,6 +10,7 @@ class JobList extends ResourceList { this.listjs.list.addEventListener('click', (event) => {this.onClick(event)}); this.isInitialized = false; this.userId = listContainerElement.dataset.userId; + if (this.userId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/JobResultList.js b/app/static/js/ResourceLists/JobResultList.js index 71c430af..b0cbc088 100644 --- a/app/static/js/ResourceLists/JobResultList.js +++ b/app/static/js/ResourceLists/JobResultList.js @@ -11,6 +11,7 @@ class JobResultList extends ResourceList { this.isInitialized = false; this.userId = listContainerElement.dataset.userId; this.jobId = listContainerElement.dataset.jobId; + if (this.userId === undefined || this.jobId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/PublicCorpusFileList.js b/app/static/js/ResourceLists/PublicCorpusFileList.js new file mode 100644 index 00000000..37a284cf --- /dev/null +++ b/app/static/js/ResourceLists/PublicCorpusFileList.js @@ -0,0 +1,15 @@ +class PublicCorpusFileList extends CorpusFileList { + get item() { + return ` + + + + + + + send + + + `.trim(); + } +} diff --git a/app/static/js/ResourceLists/PublicCorpusList.js b/app/static/js/ResourceLists/PublicCorpusList.js new file mode 100644 index 00000000..fdb2e9ed --- /dev/null +++ b/app/static/js/ResourceLists/PublicCorpusList.js @@ -0,0 +1,14 @@ +class PublicCorpusList extends CorpusList { + get item() { + return ` + + book +
+ + + send + + + `.trim(); + } +} diff --git a/app/static/js/ResourceLists/SpacyNLPPipelineModelList.js b/app/static/js/ResourceLists/SpacyNLPPipelineModelList.js index 078ec90c..b90fb06b 100644 --- a/app/static/js/ResourceLists/SpacyNLPPipelineModelList.js +++ b/app/static/js/ResourceLists/SpacyNLPPipelineModelList.js @@ -11,6 +11,7 @@ class SpaCyNLPPipelineModelList extends ResourceList { this.listjs.list.addEventListener('click', (event) => {this.onClick(event)}); this.isInitialized = false; this.userId = listContainerElement.dataset.userId; + if (this.userId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/TesseractOCRPipelineModelList.js b/app/static/js/ResourceLists/TesseractOCRPipelineModelList.js index ad319041..4ad3f5b1 100644 --- a/app/static/js/ResourceLists/TesseractOCRPipelineModelList.js +++ b/app/static/js/ResourceLists/TesseractOCRPipelineModelList.js @@ -11,6 +11,7 @@ class TesseractOCRPipelineModelList extends ResourceList { this.listjs.list.addEventListener('click', (event) => {this.onClick(event)}); this.isInitialized = false; this.userId = listContainerElement.dataset.userId; + if (this.userId === undefined) {return;} app.subscribeUser(this.userId).then((response) => { app.socket.on('PATCH', (patch) => { if (this.isInitialized) {this.onPatch(patch);} diff --git a/app/static/js/ResourceLists/UserList.js b/app/static/js/ResourceLists/UserList.js index d871ec31..03fabd73 100644 --- a/app/static/js/ResourceLists/UserList.js +++ b/app/static/js/ResourceLists/UserList.js @@ -1,7 +1,7 @@ class UserList extends ResourceList { static autoInit() { - for (let publicUserListElement of document.querySelectorAll('.user-list:not(.no-autoinit)')) { - new UserList(publicUserListElement); + for (let userListElement of document.querySelectorAll('.user-list:not(.no-autoinit)')) { + new UserList(userListElement); } } @@ -41,14 +41,14 @@ class UserList extends ResourceList { initListContainerElement() { if (!this.listContainerElement.hasAttribute('id')) { - this.listContainerElement.id = Utils.generateElementId('public-user-list-'); + this.listContainerElement.id = Utils.generateElementId('user-list-'); } let listSearchElementId = Utils.generateElementId(`${this.listContainerElement.id}-search-`); this.listContainerElement.innerHTML = `
search - +
@@ -77,7 +77,7 @@ class UserList extends ResourceList { 'full-name': user.full_name ? user.full_name : '', 'location': user.location ? user.location : '', 'organization': user.organization ? user.organization : '', - 'corpora-online': '0' + 'corpora-online': '-' }; }; diff --git a/app/static/js/RessourceDisplays/CorpusDisplay.js b/app/static/js/RessourceDisplays/CorpusDisplay.js index af4da56a..fd342dd4 100644 --- a/app/static/js/RessourceDisplays/CorpusDisplay.js +++ b/app/static/js/RessourceDisplays/CorpusDisplay.js @@ -12,6 +12,16 @@ class CorpusDisplay extends RessourceDisplay { .addEventListener('click', (event) => { Utils.deleteCorpusRequest(this.userId, this.corpusId); }); + this.displayElement + .querySelector('.action-switch[data-action="toggle-is-public"]') + .addEventListener('click', (event) => { + if (event.target.tagName !== 'INPUT') {return;} + if (event.target.checked) { + Utils.enableCorpusIsPublicRequest(this.userId, this.corpusId); + } else { + Utils.disableCorpusIsPublicRequest(this.userId, this.corpusId); + } + }); } init(user) { diff --git a/app/static/js/Utils.js b/app/static/js/Utils.js index d63be025..aee382a0 100644 --- a/app/static/js/Utils.js +++ b/app/static/js/Utils.js @@ -69,6 +69,88 @@ class Utils { return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2)); } + static enableCorpusIsPublicRequest(userId, corpusId) { + return new Promise((resolve, reject) => { + let corpus; + try { + corpus = app.data.users[userId].corpora[corpusId]; + } catch (error) { + corpus = {}; + } + + let modalElement = Utils.HTMLToElement( + ` + + ` + ); + document.querySelector('#modals').appendChild(modalElement); + let modal = M.Modal.init( + modalElement, + { + dismissible: false, + onCloseEnd: () => { + modal.destroy(); + modalElement.remove(); + } + } + ); + + let confirmElement = modalElement.querySelector('.action-button[data-action="confirm"]'); + confirmElement.addEventListener('click', (event) => { + let corpusTitle = corpus?.title; + fetch(`/corpora/${corpusId}/enable_is_public`, {method: 'POST', headers: {Accept: 'application/json'}}) + .then( + (response) => { + if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);} + if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);} + app.flash(`Corpus "${corpusTitle}" is public now`, 'corpus'); + resolve(response); + }, + (response) => { + app.flash('Something went wrong', 'error'); + reject(response); + } + ); + }); + modal.open(); + }); + } + + static disableCorpusIsPublicRequest(userId, corpusId) { + return new Promise((resolve, reject) => { + let corpus; + try { + corpus = app.data.users[userId].corpora[corpusId]; + } catch (error) { + corpus = {}; + } + + let corpusTitle = corpus?.title; + fetch(`/corpora/${corpusId}/disable_is_public`, {method: 'POST', headers: {Accept: 'application/json'}}) + .then( + (response) => { + if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);} + if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);} + app.flash(`Corpus "${corpusTitle}" is private now`, 'corpus'); + resolve(response); + }, + (response) => { + app.flash('Something went wrong', 'error'); + reject(response); + } + ); + }); + } + static buildCorpusRequest(userId, corpusId) { return new Promise((resolve, reject) => { let corpus; diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2 index 95406079..53a0469c 100644 --- a/app/templates/_scripts.html.j2 +++ b/app/templates/_scripts.html.j2 @@ -20,7 +20,9 @@ 'js/RessourceDisplays/JobDisplay.js', 'js/ResourceLists/ResourceList.js', 'js/ResourceLists/CorpusFileList.js', + 'js/ResourceLists/PublicCorpusFileList.js', 'js/ResourceLists/CorpusList.js', + 'js/ResourceLists/PublicCorpusList.js', 'js/ResourceLists/JobList.js', 'js/ResourceLists/JobInputList.js', 'js/ResourceLists/JobResultList.js', diff --git a/app/templates/_sidenav.html.j2 b/app/templates/_sidenav.html.j2 index eb547454..676b7069 100644 --- a/app/templates/_sidenav.html.j2 +++ b/app/templates/_sidenav.html.j2 @@ -20,6 +20,7 @@
  • dashboardDashboard
  • IMy Corpora
  • JMy Jobs
  • +
  • groupsSocial
  • new_labelContribute
  • Processes & Services
  • diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index 16af7d31..34228347 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -1,4 +1,5 @@ {% extends "base.html.j2" %} +{% import "materialize/wtf.html.j2" as wtf %} {% from "corpora/_breadcrumbs.html.j2" import breadcrumbs with context %} {% block main_attribs %} class="service-scheme" data-service="corpus-analysis"{% endblock main_attribs %} @@ -56,11 +57,13 @@ - @@ -76,6 +79,34 @@ + + {#
    +
    +
    +
    + + +
    + + Generate Share Link + + Copy +
    +
    +
    + +
    +
    +
    + Corpus followers +
    +
    +
    +
    #} {% endblock page_content %} @@ -85,4 +116,25 @@ +{# #} {% endblock scripts %} diff --git a/app/templates/corpora/corpora.html.j2 b/app/templates/corpora/public_corpora.html.j2 similarity index 100% rename from app/templates/corpora/corpora.html.j2 rename to app/templates/corpora/public_corpora.html.j2 diff --git a/app/templates/corpora/public_corpus.html.j2 b/app/templates/corpora/public_corpus.html.j2 new file mode 100644 index 00000000..94b3524c --- /dev/null +++ b/app/templates/corpora/public_corpus.html.j2 @@ -0,0 +1,80 @@ +{% extends "base.html.j2" %} +{% import "materialize/wtf.html.j2" as wtf %} + +{% block main_attribs %} class="service-scheme" data-service="corpus-analysis"{% endblock main_attribs %} + +{% block page_content %} +
    +
    +
    +

    {{ corpus.title }}

    +
    +
    + {% if current_user.is_following_corpus(corpus) %} + addUnfollow Corpus + {% endif %} + {% if corpus.status.name in ['BUILT', 'STARTING_ANALYSIS_SESSION', 'RUNNING_ANALYSIS_SESSION', 'CANCELING_ANALYSIS_SESSION'] and current_user.is_following_corpus(corpus) %} + Analyze + {% endif %} +
    +
    +
    +
    +
    +
    +

    Status:

    +

    +
    +
    +
    +

    Description: {{ corpus.description }}

    +
    +

    +
    +
    +

    Creation date: {{ corpus.creation_date }}

    +
    +
    +

    Number of tokens used: {{ corpus.num_tokens }}

    +
    +
    +
    +
    +
    +
    + Corpus files +
    +
    +
    +
    +
    +
    + +{% endblock page_content %} + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/app/templates/main/dashboard.html.j2 b/app/templates/main/dashboard.html.j2 index 5474db97..ca5422df 100644 --- a/app/templates/main/dashboard.html.j2 +++ b/app/templates/main/dashboard.html.j2 @@ -42,6 +42,23 @@ + {#
    +

    Social

    +
    +
    + Other users +

    Find other users and follow them to see their corpora.

    +
    +
    +
    +
    +
    + Public corpora +

    Find public corpora

    +
    +
    +
    +
    #} {% endblock page_content %} @@ -96,3 +113,14 @@ {% endblock modals %} + +{% block scripts %} +{{ super() }} +{# #} +{% endblock scripts %} + diff --git a/app/templates/main/news_new.html.j2 b/app/templates/main/news_new.html.j2 new file mode 100644 index 00000000..d3e2f9b6 --- /dev/null +++ b/app/templates/main/news_new.html.j2 @@ -0,0 +1,269 @@ +{% extends "base.html.j2" %} +{% from "main/_breadcrumbs.html.j2" import breadcrumbs with context %} + +{% block page_content %} +
    +
    +
    +

    {{ title }}

    +
    + +
    +
    +
    +
    + April 2022 update +

    Dear users

    +
    +

    + with the April 2022 update we have improved nopaque in all places. + We have significantly reworked our backend code to utilize our servers more efficiently, + integrated a new service, updated all previously existing ones, rewrote a lot of code and made a few minor design improvements. +

    +
    + + Where is my Job data? +

    + At the beginning of the year, we realized that our storage limit had been reached. + This was the time when some users may have noticed system instabilities. + We were fortunately able to temporarily solve this problem without data loss + by deleting some non-nopaque related data on our system (yes we also do other things then nopaque). + In order to not face the same problem again, we had to dedicate ourselves to a long-term solution. + This consists of deleting all previous job data with this update and henceforth storing new job data + only for three months after job creation (important note: corpora are not affected). + All job data prior to this update has been backed up for you, + feel free to contact us at nopaque@uni-bielefeld.de if you would like to get this data back. +

    +
    + + What's new? +

    + By partnering up with Transkribus we reached one of our long term goals: integrate a HTR service into nopaque. + The Transkribus HTR Pipeline service is implemented as a kind of proxied service where the work is split between Transkribus and us. + That means we do the preprocessing, storage and postprocessing, while Transkribus handles the HTR itself. +

    +
    + +

    + One of the changes in the background was to fix our performance issues. While implementing the Transkribus HTR Pipeline service we + found some optimization potential within different steps of our processing routine. These optimizations are now also + available in our Tesseract OCR Pipeline service, resulting in a speed up of about 4x. + For now we are done with the most obvious optimizations but we may include more in the near future, so stay tuned! +

    +
    + +

    + The next step was to reorganize our Corpus Analysis code. Unfortunatly it was a bit messy, after a complete rewrite we are + now able to query a corpus without long loading times and with better error handling, resulting in way more stable user experience. + The Corpus Analysis service is now modularized and comes with 2 modules that recreate and extend the functionality of the old service.
    + For now we had to disable the Query Result viewer, the code was based on the old Corpus Analysis service and will be reintegrated as a module to the Corpus Analysis. +

    +
    + +

    + The spaCy NLP Pipeline service got some love in the form of smaller updates too. + This is important preliminary work to support more models/languages that does not provide the full set of linguistic features (lemma, ner, pos, simple_pos). It still needs some testing and tweaking but will be ready soon! +

    +
    + +

    + Last but not least we made some design changes. Now you can find colors in places where we had just black and white before. + Nothing big but the new colors will help you identify ressources more efficient! +

    +
    + + Database cleanup +

    + We may be a bit late with our spring cleaning but with this update we tidied up within our database system. + This means we deleted old corpora with no corpus files, unconfirmed user accounts and in general unnecessary data fields. +

    +
    + +

    + That's it, thank you for using nopaque! We hope you like the update and appreciate all your past and future feedback. +

    +
    +
    +
    + +
    +
    +
    + Maintenance +

    Dear users

    +
    +

    Currently we are rewriting big parts of our project infrastructure. Due to this the following features are not available:

    +
      +
    • Corpus export and import
    • +
    • Query result export, import and view
    • +
    +

    We hope to add these features back in the near future, until then check out our updated corpus analysis.

    +
    +
    +
    + +
    +
    +
    + Natural Language Processing removed language support +

    Dear users

    +
    +

    Not all language models support all features we utizlize in our NLP service. Thats why we had to drop them, as soon as they meet our requirements we will add them back!

    +
    +
    +
    + +
    +
    +
    + nopaque's beta launch +

    Dear users

    +
    +

    A few days ago we went live with nopaque. Right now nopaque is still in its Beta phase. So some bugs are to be expected. If you encounter any bugs or some feature is not working as expected please send as an email using the feedback button at the botton of the page in the footer!

    +

    We are happy to help you with any issues and will use the feedback to fix all mentioned bugs!

    +
    +
    +
    +
    +
    +{% endblock page_content %} + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/app/templates/users/profile.html.j2 b/app/templates/users/profile.html.j2 index a98a372d..a6ad5b30 100644 --- a/app/templates/users/profile.html.j2 +++ b/app/templates/users/profile.html.j2 @@ -89,6 +89,24 @@ +
    +
    +
    +
    +

    Groups

    +
    +
    +
    +
    +
    +
    +

    Public corpora

    +
    +
    +
    +
    +
    + {% endblock page_content %} diff --git a/requirements.txt b/requirements.txt index 1c6a94f5..838cee8f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ eventlet Flask==2.1.3 Flask-APScheduler Flask-Assets -Flask-Hashids==1.0.0 +Flask-Hashids==1.0.1 Flask-HTTPAuth Flask-Login Flask-Mail @@ -24,6 +24,6 @@ pyScss python-dotenv pyyaml redis -SQLAlchemy==1.4.46 +SQLAlchemy==1.4.45 tqdm wtforms[email]