changes to annotations again

master
ange 6 years ago
parent f75bd69d37
commit 389de3ecad

@ -57,19 +57,20 @@ def get_annot_results(annot,name):
return res
def get_annot_book(annot,name):
bannot=[]
annot=get_annotations()
res=[]
for item in annot['rows']:
if 'selector' in item['target'][0]:
if len(item['target'][0]['selector'])>2:
if name==item['uri']:
string=item['uri']
if name==string.replace('http://localhost:8080/uploads/',''):
data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title'], 'url':item['uri']}
bannot.append(data)
res.append(data)
else:
if name in item['uri']:
string=item['uri']
if name==string.replace('http://localhost:8080/uploads/',''):
data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title'], 'url':item['uri']}
bannot.append(data)
return bannot
res.append(data)
return res

@ -18,7 +18,6 @@
{% for row in res %}
{%for book in books%}
{%if book.file == row.url|replace('http://localhost:8080/uploads/','')%}
<p align="right" style="font-family:archivo narrow;font-size:10px;">Book</p>

@ -66,6 +66,34 @@
</tbody>
</table>
<div align="right">
<p>Annotations for <i>{{book.title}}</i>:</p>
{% for row in res%}
<p style="font-family:archivo narrow;font-size:8px;">Extract</p>
<div style="font-family:archivo narrow;font-family:archivo narrow;font-size:16px;">
<i>"{{ row.extract }}"</i></div><br>
<p style="font-family:archivo narrow;font-size:8px;color:#ff3300;">Annotation</p>
{%if 'https://www.youtube.com'in row.text %}
<a style="font-family:archivo narrow;font-size:16px;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
<hr>
{%elif '.jpg' in row.text%}
<img src="{{row.text}}" alt="" width="400">
<hr>
{%else%}
<div style="font-family:archivo narrow;font-size:16px;color:#ff3300;">{{row.text}}</div><br>
<hr>
{% endif %}
{% endfor %}
</div>
<br>
<br>
<p>Instances:</p>
@ -88,6 +116,11 @@
<br>
{% if book.file %}
<button id="myBtn" style= "width: 180px; font-size: 10pt;"><a> Download this {{ book.fileformat }}</a></button>
<div id="myModal" class="modal">
@ -114,30 +147,7 @@
{% for row in bannot %}
{%for book in books%}
{%if book.file == row.uri%}
<a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:12px;">{{book.title}}</p></a><br>
{% endif %}
{% endfor %}
<p align="right" style="font-family:archivo narrow;font-size:14px;">{{row.title}}</p><br>
<p style="font-family:archivo narrow;font-size:8px;">Extracts:</p>
<div style="font-family:archivo narrow;font-family:archivo narrow;font-size:18px;">
<i>"{{ row.extract }}"</i></div><br>
<p style="font-family:archivo narrow;font-size:8px;color:#ff3300;">Annotations:</p>
{%if 'https://www.youtube.com'in row.text %}
<a style="font-family:archivo narrow;font-size:18px;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
<hr>
{%elif '.jpg' in row.text%}
<img src="{{row.text}}" alt="" width="400">
<hr>
{%else%}
<div style="font-family:archivo narrow;font-size:18px;color:#ff3300;">{{row.text}}</div><br>
<hr>
{% endif %}
{%endfor%}
{% endblock %}

@ -154,6 +154,12 @@ def show_book_by_id(id):
if id == edge:
nextbook = None
name= book.file
annot = get_annotations()
res = get_annot_book(annot,name)
userin = UserIns.query.filter_by(title="lastViewed").first()
if userin != None:
userin.info = book.title
@ -165,17 +171,10 @@ def show_book_by_id(id):
if not book:
return render_template('red_link.html', id=id)
else:
return render_template('show_book_detail.html', book=book, previousbook = previousbook, nextbook = nextbook, all_instances=all_instances)
return render_template('show_book_detail.html', book=book, previousbook = previousbook, nextbook = nextbook, all_instances=all_instances, name=name, annot=annot, res=res)
@app.route('/books/<int:id>/annotations', methods=['POST', 'GET'])
def book_annot():
books = db.session.query(Book).all()
name=book.file
annot = get_annotations()
res = get_annot_book(annot,name)
return redirect(url_for('show_book_detail'), name=name, annot=annot, res=res, books=books)
@app.route('/books/<int:id>/delete', methods=['POST', 'GET'])
@ -593,13 +592,10 @@ def search_results(searchtype, query, viewby):
@app.route('/search_annot', methods=['POST', 'GET'])
def search_annot():
books = db.session.query(Book).all()
if request.method=='POST':
return redirect (url_for('annotations'))
else:
name=str(request.args.get('query'))
annot = get_annotations()
res = get_annot_results(annot,name)
return render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
name=str(request.args.get('query'))
annot = get_annotations()
res = get_annot_results(annot,name)
return render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
@app.route('/add_to_stack/<int:id>', methods=['GET', 'POST'])

Loading…
Cancel
Save