From 736f229eb7ada3e40eafe69ad0736075637345f3 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 13 Jun 2018 10:20:53 +0200 Subject: [PATCH] changes to templates annotations --- app/getannot.py | 8 +-- app/static/viewer/web/viewer.html | 94 +------------------------------ app/templates/annotations.html | 18 +++--- app/templates/results_annot.html | 23 ++++---- app/views.py | 5 +- 5 files changed, 31 insertions(+), 117 deletions(-) diff --git a/app/getannot.py b/app/getannot.py index 895200a..69e39df 100644 --- a/app/getannot.py +++ b/app/getannot.py @@ -48,11 +48,11 @@ def get_annot_results(annot,name): if 'selector' in item['target'][0]: if len(item['target'][0]['selector'])>2: if name in item['text'] or name in item['target'][0]['selector'][2]['exact']: - data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title']} + data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title'], 'url':item['uri']} res.append(data) else: if name in item['text'] or name in item['target'][0]['selector'][1]['exact']: - data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title']} + data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title'], 'url':item['uri']} res.append(data) return res @@ -63,11 +63,11 @@ def get_annot_book(annot,name): if 'selector' in item['target'][0]: if len(item['target'][0]['selector'])>2: if name==item['uri']: - data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title']} + data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title'], 'url':item['uri']} bannot.append(data) else: if name in item['uri']: - data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title']} + data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title'], 'url':item['uri']} bannot.append(data) return bannot diff --git a/app/static/viewer/web/viewer.html b/app/static/viewer/web/viewer.html index ab725c9..8712fed 100755 --- a/app/static/viewer/web/viewer.html +++ b/app/static/viewer/web/viewer.html @@ -432,7 +432,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/ // icon: 'https://pzwiki.wdka.nl/mw-mediadesign/images/9/9c/Xppl-logo.svg' // }], onLayoutChange: { - width:50 + width:'50' }, sidebarAppUrl: 'http://hypothes.is/app.html' }; @@ -443,98 +443,6 @@ http://sourceforge.net/adobe/cmap/wiki/License/ - - - - - - - - - - - - - - - - - - - - - diff --git a/app/templates/annotations.html b/app/templates/annotations.html index 77bbc7e..0a52125 100644 --- a/app/templates/annotations.html +++ b/app/templates/annotations.html @@ -2,32 +2,32 @@ {% block main %}

Annotations of XPPL

-







+Get as PDF      Search







{% for row in annot.rows %} {% if 'selector' in row.target[0] %} +

Book

+

{{row.uri|replace('.pdf','')|replace('http://localhost:8080/uploads/','')|replace('.','')}}


{%for book in books%} {%if book.file == row.uri%} -

{{book.title}}


+

=d=


{% endif %} {% endfor %} {% if row.target[0].selector|length > 2%} -

Extracts:

+

Extract

"{{row.target[0].selector[2].exact}}"

-

Annotations:

+

Annotation

{%if 'https://www.youtube.com' in row.text %} - {{row.text}}
{%elif '.jpg' in row.text%} {{row.document.title}} {%elif '.mp3' in row.text %} - {{row.text}}
{%else%}
{{row.text}}

@@ -35,14 +35,16 @@
{%else%} +

Extracts:

"{{row.target[0].selector[1].exact}}"

- +

Annotations:

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

{% endif %} diff --git a/app/templates/results_annot.html b/app/templates/results_annot.html index a9f47f1..c6ef032 100644 --- a/app/templates/results_annot.html +++ b/app/templates/results_annot.html @@ -2,35 +2,36 @@ {% block main %}


- +
- Browse annotations:
- +
-




+


+      All annotations

- All +

Annotations/ Extracts with:  {{name}}

-



{% for row in res %} +

Book

+

{{row.url|replace('.pdf','')|replace('http://localhost:8080/uploads/','')|replace('.','')}}


+ {%for book in books%} - {%if book.file == row.uri%} -

{{book.title}}


+ {%if book.file == row.url%} +

=d=


{% endif %} {% endfor %} -

{{row.title}}


-

Extracts:

+

Extract

"{{ row.extract }}"

-

Annotations:

+

Annotation

{%if 'https://www.youtube.com'in row.text %} {{row.text}}

diff --git a/app/views.py b/app/views.py index 5fcdb17..1cfbb63 100755 --- a/app/views.py +++ b/app/views.py @@ -768,8 +768,11 @@ def annotations_pdf(): @app.route('/mybook.pdf') def mybook_pdf(): + name=str(request.args.get('query')) + annot = get_annotations() + res = get_annot_results(annot,name) # Make a PDF straight from HTML in a string. - html = redirect(url_for('search_annot')) + html = redirect(url_for('search_annot?query=the'), name=name, annot=annot, res=res) return render_pdf(HTML(string=html))