Pass xanadoc text to view template.
This commit is contained in:
parent
2eabe72776
commit
85ae5e3be5
|
@ -115,7 +115,7 @@ def reset_with_token(token):
|
||||||
ts = URLSafeTimedSerializer(current_app.config["SECRET_KEY"])
|
ts = URLSafeTimedSerializer(current_app.config["SECRET_KEY"])
|
||||||
try:
|
try:
|
||||||
user_id = ts.loads(token, salt='password-reset', max_age=86400)
|
user_id = ts.loads(token, salt='password-reset', max_age=86400)
|
||||||
except:
|
except Exception:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
form = PasswordForm()
|
form = PasswordForm()
|
||||||
|
@ -192,6 +192,12 @@ def get_source_doc(username, hashid):
|
||||||
doc = None
|
doc = None
|
||||||
return doc if doc else abort(404)
|
return doc if doc else abort(404)
|
||||||
|
|
||||||
|
def get_xanadoc(username, hashid):
|
||||||
|
doc = Item.get_by_hashid(hashid)
|
||||||
|
if doc and doc.user.username != username:
|
||||||
|
doc = None
|
||||||
|
return doc if doc and doc.type == 'xanadoc' else abort(404)
|
||||||
|
|
||||||
def get_item(username, hashid):
|
def get_item(username, hashid):
|
||||||
doc = Item.get_by_hashid(hashid)
|
doc = Item.get_by_hashid(hashid)
|
||||||
if doc and doc.user.username != username:
|
if doc and doc.user.username != username:
|
||||||
|
@ -200,9 +206,7 @@ def get_item(username, hashid):
|
||||||
|
|
||||||
@bp.route('/<username>/<hashid>/edl')
|
@bp.route('/<username>/<hashid>/edl')
|
||||||
def view_edl(username, hashid):
|
def view_edl(username, hashid):
|
||||||
item = get_item(username, hashid)
|
item = get_xanadoc(username, hashid)
|
||||||
if item.type != 'xanadoc':
|
|
||||||
return abort(404)
|
|
||||||
|
|
||||||
return render_template('view.html',
|
return render_template('view.html',
|
||||||
doc=item,
|
doc=item,
|
||||||
|
@ -211,9 +215,7 @@ def view_edl(username, hashid):
|
||||||
|
|
||||||
@bp.route('/<username>/<hashid>/realize')
|
@bp.route('/<username>/<hashid>/realize')
|
||||||
def realize_edl(username, hashid):
|
def realize_edl(username, hashid):
|
||||||
item = get_item(username, hashid)
|
item = get_xanadoc(username, hashid)
|
||||||
if item.type != 'xanadoc':
|
|
||||||
return abort(404)
|
|
||||||
|
|
||||||
spans = list(fulfil_edl(item.text))
|
spans = list(fulfil_edl(item.text))
|
||||||
|
|
||||||
|
@ -231,9 +233,8 @@ def view_item_raw(username, hashid):
|
||||||
|
|
||||||
@bp.route('/<username>/<hashid>/fulfil')
|
@bp.route('/<username>/<hashid>/fulfil')
|
||||||
def fulfil(username, hashid):
|
def fulfil(username, hashid):
|
||||||
item = get_item(username, hashid)
|
item = get_xanadoc(username, hashid)
|
||||||
if item.type != 'xanadoc':
|
|
||||||
return abort(404)
|
|
||||||
return render_template('view/xanadoc.html',
|
return render_template('view/xanadoc.html',
|
||||||
item=item,
|
item=item,
|
||||||
doc=fulfil_edl_with_sources(item.text))
|
doc=fulfil_edl_with_sources(item.text))
|
||||||
|
@ -273,8 +274,15 @@ def view_item(username, hashid, raw=False):
|
||||||
version = None
|
version = None
|
||||||
text = item.text
|
text = item.text
|
||||||
|
|
||||||
|
if item.type == 'xanadoc':
|
||||||
|
spans = list(fulfil_edl(item.text))
|
||||||
|
doc_text = ''.join(span['text'] for span in spans)
|
||||||
|
else:
|
||||||
|
doc_text = None
|
||||||
|
|
||||||
return render_template('view.html',
|
return render_template('view.html',
|
||||||
doc=item,
|
doc=item,
|
||||||
|
doc_text=doc_text,
|
||||||
version=version,
|
version=version,
|
||||||
text=text,
|
text=text,
|
||||||
span_start=start,
|
span_start=start,
|
||||||
|
|
Loading…
Reference in a new issue