Build links: show existing links
This commit is contained in:
parent
781b8a7c8d
commit
267dcc3a4d
|
@ -45,7 +45,7 @@ body, html {
|
|||
<div class="card document" id="{{ name }}">
|
||||
<div class="card-header">{{ doc.raw_title() }}</div>
|
||||
<div class="card-body">
|
||||
{%- for start, line in iter_lines(doc.text) if line != '\r\n' %}
|
||||
{% for start, line in iter_lines(doc.text) if line != '\r\n' %}
|
||||
<p class="card-text margin-bottom-zero" data-start="{{ start }}">{{- nbsp_at_start(line) -}}</p>
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
|
@ -77,6 +77,19 @@ body, html {
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if links %}
|
||||
{% if links | count == 1 %}
|
||||
<p>There is one link between these documents.</p>
|
||||
{% else %}
|
||||
<p>There are {{ links | count }} links between these documents.</p>
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for link in links %}
|
||||
<li><a href="{{ link.url }}">link: {{ link.hashid }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="col col2">
|
||||
{% if doc1 %}
|
||||
|
|
|
@ -5,7 +5,7 @@ from flask_login import (login_user, current_user, logout_user,
|
|||
from .forms import (LoginForm, SignupForm, AccountSettingsForm,
|
||||
UploadSourceDocForm, SourceDocForm, ItemForm,
|
||||
ForgotPasswordForm, PasswordForm)
|
||||
from .model import User, SourceDoc, Item, XanaDoc, XanaLink
|
||||
from .model import User, SourceDoc, Item, XanaDoc, XanaLink, Reference
|
||||
from .url import get_url
|
||||
from .mail import send_mail
|
||||
from .edl import fulfil_edl_with_sources, fulfil_edl, parse_edl
|
||||
|
@ -18,7 +18,7 @@ from jinja2 import evalcontextfilter, Markup
|
|||
from functools import wraps
|
||||
from .utils import nbsp_at_start
|
||||
from itsdangerous import URLSafeTimedSerializer
|
||||
from sqlalchemy_continuum import version_class
|
||||
# from sqlalchemy_continuum import version_class
|
||||
from pprint import pformat
|
||||
|
||||
import json
|
||||
|
@ -282,6 +282,11 @@ def save_new_xanalink(doc1, doc2):
|
|||
obj = XanaLink(user=current_user, text=text)
|
||||
session.add(obj)
|
||||
session.commit()
|
||||
ref1 = Reference(subject_id=obj.id, object_id=doc1.id)
|
||||
ref2 = Reference(subject_id=obj.id, object_id=doc2.id)
|
||||
session.add(ref1)
|
||||
session.add(ref2)
|
||||
session.commit()
|
||||
|
||||
@bp.route('/build_links', methods=['GET', 'POST'])
|
||||
def build_links():
|
||||
|
@ -298,6 +303,9 @@ def build_links():
|
|||
save_new_xanalink(doc1, doc2)
|
||||
return redirect(url_for(request.endpoint, doc1=hashid1, doc2=hashid2))
|
||||
|
||||
links = list({i for i in doc1.subjects} &
|
||||
{i for i in doc2.subjects})
|
||||
|
||||
return render_template('build_links.html',
|
||||
iter_lines=iter_lines,
|
||||
nbsp_at_start=nbsp_at_start,
|
||||
|
@ -305,7 +313,8 @@ def build_links():
|
|||
hashid1=hashid1,
|
||||
hashid2=hashid2,
|
||||
doc1=doc1,
|
||||
doc2=doc2)
|
||||
doc2=doc2,
|
||||
links=links)
|
||||
|
||||
@bp.route('/<username>/<hashid>')
|
||||
def view_item(username, hashid, raw=False):
|
||||
|
|
Loading…
Reference in a new issue