From 389de3ecada9524ac4221b848a81cf978302c7c0 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 13 Jun 2018 14:34:15 +0200 Subject: [PATCH] changes to annotations again --- app/getannot.py | 15 ++++---- app/templates/results_annot.html | 1 - app/templates/show_book_detail.html | 56 +++++++++++++++++------------ app/views.py | 26 ++++++-------- 4 files changed, 52 insertions(+), 46 deletions(-) diff --git a/app/getannot.py b/app/getannot.py index 69e39df..aa23cee 100644 --- a/app/getannot.py +++ b/app/getannot.py @@ -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 diff --git a/app/templates/results_annot.html b/app/templates/results_annot.html index 96f959f..e6d008f 100644 --- a/app/templates/results_annot.html +++ b/app/templates/results_annot.html @@ -18,7 +18,6 @@ {% for row in res %} - {%for book in books%} {%if book.file == row.url|replace('http://localhost:8080/uploads/','')%}

Book

diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index f9b73a8..23b9fc2 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -66,6 +66,34 @@ + +
+

Annotations for {{book.title}}:

+{% for row in res%} +

Extract

+
+ "{{ row.extract }}"

+ +

Annotation

+{%if 'https://www.youtube.com'in row.text %} + {{row.text}}
+
+ {%elif '.jpg' in row.text%} + +
+ {%else%} +
{{row.text}}

+
+ {% endif %} +{% endfor %} +
+ + + + + + +

Instances:

@@ -88,6 +116,11 @@
+ + + + + {% if book.file %}