diff --git a/sourcing/static/js/build_link.js b/sourcing/static/js/build_link.js new file mode 100644 index 0000000..c64be01 --- /dev/null +++ b/sourcing/static/js/build_link.js @@ -0,0 +1,4 @@ +new Vue({ + el: '#app', +}); + diff --git a/sourcing/templates/build_links.html b/sourcing/templates/build_links.html new file mode 100644 index 0000000..bd01b85 --- /dev/null +++ b/sourcing/templates/build_links.html @@ -0,0 +1,100 @@ +{% extends "base_plain.html" %} + +{% block title %}Build links{% endblock %} + +{% block style %} +<style> +body, html { + height: 100%; margin: 0; padding: 0; + overflow: hidden; +} + +.col { + position: absolute; + height: calc(100% - 75px); + flex: 1; + margin-top: 10px; +} + +.col1 { + left: 0; + width: 20%; + overflow-y: auto; +} + +.col2 { + left: 20%; + width: 40%; + overflow-y: auto; +} + +.col3 { + left: 60%; + width: 40%; + overflow-y: auto; +} + +.selected-span { + background: yellow; +} + +</style> +{% endblock %} + +{% macro show_doc(doc) %} + <div class="card" id="text1"> + <div class="card-header">{{ doc.raw_title() }}</div> + <div class="card-body"> +{%- 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> + </div> +{% endmacro %} + +{% block content %} + +<div> +<div class="col col1"> + <h3>Link builder</h3> + <p>Select something in the first document.</p> + <button class="btn btn-primary" id="new-link">confirm selection</button> + +</div> +<div class="col col2"> + {% if doc1 %} + {{ show_doc(doc1) }} + {% else %} + <h3>select document 1</h3> + <ul> + {% for doc in SourceDoc.query %} + <li> + <a href="{{ url_for(request.endpoint, doc1=doc.hashid, doc2=hashid2) }}">{{ doc.raw_title() }}</a> + — {{ doc.user.username }} — {{ doc.created | datetime }} + </li> + {% endfor %} + </ul> + {% endif %} +</div> +<div class="col col3"> + {% if doc2 %} + {{ show_doc(doc2) }} + {% else %} + <h3>select document 2</h3> + <ul> + {% for doc in SourceDoc.query %} + <li> + <a href="{{ url_for(request.endpoint, doc1=hashid1, doc2=doc.hashid) }}">{{ doc.raw_title() }}</a> + — {{ doc.user.username }} — {{ doc.created | datetime }} + </li> + {% endfor %} + </ul> + {% endif %} +</div> +</div> + +{% endblock %} + +{% block scripts %} +<script src="{{ url_for('static', filename='js/build_links.js') }}"></script> +{% endblock %} diff --git a/sourcing/view.py b/sourcing/view.py index eb64a0b..38503ff 100644 --- a/sourcing/view.py +++ b/sourcing/view.py @@ -258,6 +258,25 @@ def delete_item(username, hashid): flash('item deleted') return redirect_to_home() +@bp.route('/build_links') +def build_links(): + doc1, doc2 = None, None + hashid1, hashid2 = None, None + if 'doc1' in request.args: + hashid1 = request.args['doc1'] + doc1 = Item.get_by_hashid(hashid1) + if 'doc2' in request.args: + hashid2 = request.args['doc2'] + doc2 = Item.get_by_hashid(hashid2) + return render_template('build_links.html', + iter_lines=iter_lines, + nbsp_at_start=nbsp_at_start, + SourceDoc=SourceDoc, + hashid1=hashid1, + hashid2=hashid2, + doc1=doc1, + doc2=doc2) + @bp.route('/<username>/<hashid>') def view_item(username, hashid, raw=False): if ',' in hashid: