changes to annotations
This commit is contained in:
parent
6205fc7272
commit
d21cfdaafc
@ -1,38 +1,75 @@
|
|||||||
#https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd
|
|
||||||
|
|
||||||
|
# #https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd
|
||||||
|
# import requests
|
||||||
|
# import json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # This script demonstrates how to query annotations for a particular URL using the hypothes.is API. An API key is required.
|
||||||
|
# # The end result of this script is a Python dictionary with annotation data in it. Top save to csv or other format, further parsing would be required
|
||||||
|
# def get_annotations():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# This script demonstrates how to query annotations for a particular URL using the hypothes.is API. An API key is required.
|
||||||
|
# The end result of this script is a Python dictionary with annotation data in it. Top save to csv or other format, further parsing would be required
|
||||||
def get_annotations():
|
def get_annotations():
|
||||||
KEY = "6879-rwfbfodYqhBn2OK2ODnNGkzlWUa4bPCoJi2U8pgTYHg"
|
KEY = "6879-n8AksBoSB7kYoQ3eEwzpEr3nFQEmSp3XN-0PcKL_Sik"
|
||||||
|
# URL = "https://monoskop.org/Monoskop"
|
||||||
|
|
||||||
headers = {
|
#a dictionary containing necessary http headers
|
||||||
"Host": "xppl",
|
headers = {
|
||||||
"Accept": "application/json",
|
"Host": "hypothes.is",
|
||||||
"Content-Type": "application/json",
|
"Accept": "application/json",
|
||||||
"Authorization": "Bearer %s" % KEY
|
"Authorization": "Bearer %s" % KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
search_url = "".join("http://localhost:5000/api/search")
|
|
||||||
|
|
||||||
r = requests.get(search_url, headers=headers)
|
|
||||||
data = json.loads(r.text)
|
|
||||||
return data
|
|
||||||
|
|
||||||
# extract=[]
|
|
||||||
# for item in data['rows']:
|
|
||||||
# # if 'exact' in item['target'][0]['selector'][2]:
|
|
||||||
# if 'selector' in item['target'][0]:
|
|
||||||
# if len(item['target'][0]['selector']) > 2:
|
|
||||||
# extract.append('extract:' + (item['target'][0]['selector'][2]['exact']))
|
|
||||||
# extract.append('annotation:' + item['text'])
|
|
||||||
# extract.append ('-----------')
|
|
||||||
# else:
|
|
||||||
# extract.append('annotation:' + item['text'])
|
|
||||||
# extract.append ('-----------')
|
|
||||||
# return extract
|
|
||||||
|
|
||||||
|
base_url = "https://hypothes.is/api/search?user=xpub@hypothes.is"
|
||||||
|
|
||||||
|
search_url = "".join([base_url])
|
||||||
|
|
||||||
|
r = requests.get(search_url, headers=headers)
|
||||||
|
#data is a python dictionary
|
||||||
|
data = json.loads(r.text)
|
||||||
|
|
||||||
|
# r = requests.get(search_url, headers=headers)
|
||||||
|
# data = json.loads(r.text)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def get_annot_results(annot,name):
|
||||||
|
res=[]
|
||||||
|
annot=get_annotations()
|
||||||
|
for item in annot['rows']:
|
||||||
|
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']}
|
||||||
|
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']}
|
||||||
|
res.append(data)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def get_annot_book(annot,name):
|
||||||
|
bannot=[]
|
||||||
|
annot=get_annotations()
|
||||||
|
for item in annot['rows']:
|
||||||
|
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']}
|
||||||
|
bannot.append(data)
|
||||||
|
else:
|
||||||
|
if name in item['uri']:
|
||||||
|
data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title']}
|
||||||
|
bannot.append(data)
|
||||||
|
return bannot
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,3 +437,12 @@ box-sizing: border-box;
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body { font-family: "Archivo Narrow"}
|
||||||
|
nav { font-size: .7em }
|
||||||
|
|
||||||
|
@page { size: A5; margin: 1cm }
|
||||||
|
@media print {
|
||||||
|
nav { display: none }
|
||||||
|
}
|
@ -413,25 +413,35 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <script type="application/json" class="js-hypothesis-config">
|
<script type="text/javascript">
|
||||||
{
|
window.hypothesisConfig = function () {
|
||||||
"openSidebar": true,
|
|
||||||
"branding": {"appBackgroundColor": "yellow"},
|
|
||||||
"services": {"authority": "http://localhost:8080/", "grantToken": "***", "icon": "https://openclipart.org/download/272629/sihouette-animaux-10.svg"}
|
|
||||||
}</script> -->
|
|
||||||
|
|
||||||
<!-- <script type="text/javascript">
|
|
||||||
window.hypothesisConfig = function () {
|
|
||||||
return {
|
return {
|
||||||
services: [{
|
openSidebar: true,
|
||||||
apiUrl: 'https://hypothes.is/api/',
|
branding: {
|
||||||
authority: 'partner.org',
|
appBackgroundColor: 'yellow',
|
||||||
grantToken: '***',
|
ctaBackgroundColor: 'rgba(227, 38, 54, 1)',
|
||||||
icon: 'https://openclipart.org/download/272629/sihouette-animaux-10.svg'
|
ctaTextColor: '#eee',
|
||||||
}],
|
selectionFontFamily: 'archivo narrow',
|
||||||
|
annotationFontFamily: 'archivo narrow',
|
||||||
|
accentColor: 'red'
|
||||||
|
},
|
||||||
|
// services: [{
|
||||||
|
// apiUrl: 'http://hypothes.is/api/',
|
||||||
|
// authority: 'http://hypothes.is/',
|
||||||
|
// grantToken: '6879-n8AksBoSB7kYoQ3eEwzpEr3nFQEmSp3XN-0PcKL_Sik',
|
||||||
|
// icon: 'https://pzwiki.wdka.nl/mw-mediadesign/images/9/9c/Xppl-logo.svg'
|
||||||
|
// }],
|
||||||
|
onLayoutChange: {
|
||||||
|
width:50
|
||||||
|
},
|
||||||
|
sidebarAppUrl: 'http://hypothes.is/app.html'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script> -->
|
</script>
|
||||||
|
|
||||||
|
<script async src= "//hypothes.is/embed.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <script src="//localhost:5000/embed.js"></script> -->
|
<!-- <script src="//localhost:5000/embed.js"></script> -->
|
||||||
|
|
||||||
@ -465,12 +475,15 @@ window.hypothesisConfig = function () {
|
|||||||
</script> -->
|
</script> -->
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<!-- <script async src= "//localhost:5000/embed.js"></script> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <script type="text/javascript">
|
||||||
window.hypothesisConfig = function () {
|
window.hypothesisConfig = function () {
|
||||||
return {
|
return {
|
||||||
openSidebar: true,
|
openSidebar: true,
|
||||||
showHighlights: true,
|
showHighlights: true,
|
||||||
usernameUrl: 'localhost:8080/annotations',
|
// usernameUrl: 'localhost:8080/annotations',
|
||||||
branding: {
|
branding: {
|
||||||
appBackgroundColor: 'yellow',
|
appBackgroundColor: 'yellow',
|
||||||
ctaBackgroundColor: 'rgba(227, 38, 54, 1)',
|
ctaBackgroundColor: 'rgba(227, 38, 54, 1)',
|
||||||
@ -479,12 +492,12 @@ window.hypothesisConfig = function () {
|
|||||||
annotationFontFamily: 'archivo narrow',
|
annotationFontFamily: 'archivo narrow',
|
||||||
accentColor: 'red'
|
accentColor: 'red'
|
||||||
},
|
},
|
||||||
services: {
|
// services: {
|
||||||
apiUrl: 'http://localhost:5000/api/'
|
// apiUrl: 'http://localhost:5000/api/'
|
||||||
// authority: 'http://localhost:5000/',
|
// // authority: 'http://localhost:5000/',
|
||||||
// grantToken: '6879-rwfbfodYqhBn2OK2ODnNGkzlWUa4bPCoJi2U8pgTYHg',
|
// // grantToken: '6879-rwfbfodYqhBn2OK2ODnNGkzlWUa4bPCoJi2U8pgTYHg',
|
||||||
// icon: 'https://pzwiki.wdka.nl/mw-mediadesign/images/9/9c/Xppl-logo.svg'
|
// // icon: 'https://pzwiki.wdka.nl/mw-mediadesign/images/9/9c/Xppl-logo.svg'
|
||||||
},
|
// },
|
||||||
onLayoutChange: {
|
onLayoutChange: {
|
||||||
width:'200',
|
width:'200',
|
||||||
height:'2'
|
height:'2'
|
||||||
@ -492,14 +505,26 @@ window.hypothesisConfig = function () {
|
|||||||
// sidebarAppUrl: 'http://localhost:5000/app.html'
|
// sidebarAppUrl: 'http://localhost:5000/app.html'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script> -->
|
||||||
|
|
||||||
<script async id="location" src= "//localhost:5000/embed.js"></script>
|
|
||||||
<!-- <p id="location"></p> -->
|
|
||||||
|
|
||||||
<script >
|
|
||||||
|
<!-- <script>
|
||||||
|
// wait until the page has loaded (and document.body is ready)
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
var script = document.createElement("script");
|
||||||
|
|
||||||
|
script.src = "//"+window.location.hostname+":5000/embed.js";
|
||||||
|
script.setAttribute("async", "");
|
||||||
|
document.body.appendChild(script);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script> -->
|
||||||
|
|
||||||
|
<!-- <script >
|
||||||
document.getElementById("#location").src = window.location.hostname + ":5000/embed.js";
|
document.getElementById("#location").src = window.location.hostname + ":5000/embed.js";
|
||||||
</script>
|
</script> -->
|
||||||
|
|
||||||
<!-- <script>
|
<!-- <script>
|
||||||
document.getElementById("location").src = window.location.hostname + ":5000/embed.js";
|
document.getElementById("location").src = window.location.hostname + ":5000/embed.js";
|
||||||
@ -510,6 +535,8 @@ document.getElementById("demo").innerHTML =
|
|||||||
"Page hostname is " + window.location.hostname;
|
"Page hostname is " + window.location.hostname;
|
||||||
</script>
|
</script>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -1,57 +1,55 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<h1 class="header">Annotations</h1>
|
<h1 class="header">Annotations of XPPL</h1>
|
||||||
<!-- create pdf from the html annotations -->
|
<nav><a href="{{ url_for('annotations_pdf') }}">Get as PDF</a></nav><nav><a href="/search_annot">search</a></nav><br><br><br><br><br><br><br><br>
|
||||||
<!-- <link rel=stylesheet href="{{ url_for('static', filename='style.css') }}" /> -->
|
|
||||||
<nav><a href="{{ url_for('annotations_pdf') }}">Get as PDF</a></nav><br><br>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <iframe src="/static/viewer/web/viewer.html?file=%2Fuploads%2FParatexts__Thresholds_of_Interpretation_-_Gerard_Genette.pdf" style="width:718px; height:700px;" frameborder="0"></iframe>
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- annotations and extracts from API -->
|
|
||||||
|
|
||||||
{% for row in annot.rows %}
|
{% for row in annot.rows %}
|
||||||
{% if 'selector' in row.target[0] %}
|
{% if 'selector' in row.target[0] %}
|
||||||
|
|
||||||
|
{%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 %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if row.target[0].selector|length > 2%}
|
{% if row.target[0].selector|length > 2%}
|
||||||
<a href="{{row.uri}}"><p align="right" style="font-family:archivo narrow;font-size:12;">{{row.document.title}}</p></a><br>
|
<p style="font-family:archivo narrow;font-size:8px;">Extracts:</p>
|
||||||
|
<div style="font-family:archivo narrow;font-size:18px;"><i>"{{row.target[0].selector[2].exact}}"</i></div><br>
|
||||||
<div style="font-family:archivo narrow;font-size:18;">
|
<p style="font-family:archivo narrow;font-size:8px;color:#ff3300;">Annotations:</p>
|
||||||
<i>"{{row.target[0].selector[2].exact}}"</i></div><br>
|
{%if 'https://www.youtube.com' in row.text %}
|
||||||
|
|
||||||
{%if 'https://www.youtube.com'in row.text %}
|
|
||||||
<!-- <embed src="{{row.text}}" width="50%"></embed> -->
|
<!-- <embed src="{{row.text}}" width="50%"></embed> -->
|
||||||
<a style="font-family:archivo narrow;font-size:18;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
|
<a style="font-family:archivo narrow;font-size:18px;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
|
||||||
{%elif '.jpg' in row.text%}
|
{%elif '.jpg' in row.text%}
|
||||||
<img src="{{row.text}}" alt="{{row.document.title}}" width="400">
|
<img src="{{row.text}}" alt="{{row.document.title}}" width="400">
|
||||||
|
{%elif '.mp3' in row.text %}
|
||||||
|
<!-- <embed src="{{row.text}}" width="50%"></embed> -->
|
||||||
|
<a style="font-family:archivo narrow;font-size:18px;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
|
||||||
{%else%}
|
{%else%}
|
||||||
<div style="font-family:archivo narrow;font-size:18;color:#ff3300;">{{row.text}}</div><br>
|
<div style="font-family:archivo narrow;font-size:18px;color:#ff3300;">{{row.text}}</div><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{%else%}
|
{%else%}
|
||||||
<a href="{{row.uri}}"><p align="right" style="font-family:archivo narrow;font-size:12;">{{row.document.title}}</p></a><br>
|
<div style="font-family:archivo narrow;font-size:18px;">
|
||||||
|
|
||||||
<div style="font-family:archivo narrow;font-size:18;">
|
|
||||||
<i>"{{row.target[0].selector[1].exact}}"</i></div><br>
|
<i>"{{row.target[0].selector[1].exact}}"</i></div><br>
|
||||||
|
|
||||||
{%if 'https://www.youtube.com'in row.text %}
|
{%if 'https://www.youtube.com'in row.text %}
|
||||||
<!-- <embed src="{{row.text}}" width="50%"></embed> -->
|
<!-- <embed src="{{row.text}}" width="50%"></embed> -->
|
||||||
|
<a style="font-family:archivo narrow;font-size:18px;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
|
||||||
<a style="font-family:archivo narrow;font-size:18;color:#ff3300;" href="{{row.text}}">{{row.text}}</a><br>
|
|
||||||
{%elif '.jpg' in row.text%}
|
{%elif '.jpg' in row.text%}
|
||||||
<img src="{{row.text}}" alt="{{row.document.title}}" width="400">
|
<img src="{{row.text}}" alt="{{row.document.title}}" width="400">
|
||||||
{%else%}
|
{%else%}
|
||||||
<div style="font-family:archivo narrow;font-size:18;color:#ff3300;">{{row.text}}</div><br>
|
<div style="font-family:archivo narrow;font-size:18px;color:#ff3300;">{{row.text}}</div><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%else%}
|
{%else%}
|
||||||
<a href="{{row.uri}}"style="font-family:archivo narrow;font-size:12;">{{row.document.title}}</a><br>
|
<p style="font-family:archivo narrow;font-size:18px;color:#ff3300;">{{row.text}}</p><br>
|
||||||
<p style="font-family:archivo narrow;font-size:18;color:#ff3300;">{{row.text}}</p><br>
|
|
||||||
<hr><br>
|
<hr><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -60,63 +58,7 @@
|
|||||||
<!-- dump:
|
<!-- dump:
|
||||||
<pre>
|
<pre>
|
||||||
{{dump}}
|
{{dump}}
|
||||||
</pre>
|
</pre> -->
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- <script type="application/json" class="js-hypothesis-config">
|
|
||||||
{
|
|
||||||
"openSidebar": true,
|
|
||||||
"branding": {"appBackgroundColor": "yellow"},
|
|
||||||
"enableExperimentalNewNoteButton": true
|
|
||||||
|
|
||||||
}
|
|
||||||
</script> -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <script type="text/javascript">
|
|
||||||
window.hypothesisConfig = function () {
|
|
||||||
return {
|
|
||||||
openSidebar: true,
|
|
||||||
showHighlights: true,
|
|
||||||
usernameUrl: 'localhost:8080/annotations',
|
|
||||||
branding: {
|
|
||||||
appBackgroundColor: 'yellow',
|
|
||||||
ctaBackgroundColor: 'rgba(227, 38, 54, 1)',
|
|
||||||
ctaTextColor: '#eee',
|
|
||||||
selectionFontFamily: 'archivo narrow',
|
|
||||||
annotationFontFamily: 'archivo narrow',
|
|
||||||
accentColor: 'red'
|
|
||||||
},
|
|
||||||
services: {
|
|
||||||
apiUrl: 'http://localhost:5000/api/',
|
|
||||||
onProfileRequest: 'http://localhost:8080/',
|
|
||||||
onHelpRequest: 'http://localhost:8080/',
|
|
||||||
authority: 'http://localhost:5000/',
|
|
||||||
grantToken: '6879-rwfbfodYqhBn2OK2ODnNGkzlWUa4bPCoJi2U8pgTYHg',
|
|
||||||
icon: 'https://pzwiki.wdka.nl/mw-mediadesign/images/9/9c/Xppl-logo.svg'
|
|
||||||
},
|
|
||||||
onLayoutChange: {
|
|
||||||
width:200
|
|
||||||
},
|
|
||||||
// sidebarAppUrl: 'http://localhost:5000/app.html'
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script async id="location" src="http://localhost:5000/embed.js"></script> -->
|
|
||||||
|
|
||||||
<!-- <script async type="text/javascript" document.getElementById("location").src = window.location.hostname + ":5000/embed.js";></script> -->
|
|
||||||
|
|
||||||
<!-- <script async id="location" src= "//localhost:5000/embed.js"></script> -->
|
|
||||||
<!-- <p id="location"></p> -->
|
|
||||||
|
|
||||||
<!-- <script >
|
|
||||||
document.getElementById("#location").src = window.location.hostname + ":5000/embed.js";
|
|
||||||
</script>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- <script async src="http://localhost:5000/embed.js"></script> -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<li><a href="{{ url_for('show_stacks') }}">Stacks</a></li>
|
<li><a href="{{ url_for('show_stacks') }}">Stacks</a></li>
|
||||||
<li><a href="{{ url_for('add_book') }}">Add Book</a></li>
|
<li><a href="{{ url_for('add_book') }}">Add Book</a></li>
|
||||||
<li><a href="{{ url_for ('add_stack') }}">Add Stack</a></li>
|
<li><a href="{{ url_for ('add_stack') }}">Add Stack</a></li>
|
||||||
|
<li><a href="{{ url_for('annotations') }}">Annotations</a></li>
|
||||||
<li><a href="{{ url_for('about') }}">About</a></li>
|
<li><a href="{{ url_for('about') }}">About</a></li>
|
||||||
<li><a href="{{ url_for('show_instances') }}">Instances</a></li>
|
<li><a href="{{ url_for('show_instances') }}">Instances</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
56
app/templates/results_annot.html
Normal file
56
app/templates/results_annot.html
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<br><br><br>
|
||||||
|
<!-- <nav><a href="{{ url_for('mybook_pdf') }}">Get as PDF</a></nav> -->
|
||||||
|
|
||||||
|
<form style="float:left;" action="/search_annot" method="GET">
|
||||||
|
Browse annotations:<br>
|
||||||
|
<div style="float:left;" class="search">
|
||||||
|
<input type="text" name="query" value="{{name}}">
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Submit"></input>
|
||||||
|
</form>
|
||||||
|
<br><br><br><br><br>
|
||||||
|
|
||||||
|
<a href="/annotations" style="font-family:archivo narrow;font-size:18px; float:center;"> All</a>
|
||||||
|
|
||||||
|
|
||||||
|
<br><br><br><br>
|
||||||
|
{% for row in res %}
|
||||||
|
{%for book in books%}
|
||||||
|
{%if book.file == row.uri%}
|
||||||
|
<a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:18px;">{{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 %}
|
@ -66,35 +66,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<a href="/viewpdf/{{ book.file }}">download {{ book.fileformat }}</a>
|
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
|
||||||
<div id="annotindication">
|
|
||||||
--> Feel free to annotate</div>
|
|
||||||
|
|
||||||
<!-- <embed src="../uploads/{{ book.file }}" width="50%" ></embed> -->
|
|
||||||
<!--
|
|
||||||
<embed src="../uploads/web/viewer.html?file=%2F{{ book.file }}" width="50%" ></embed> -->
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a>
|
|
||||||
=======
|
|
||||||
{% if book.file %}
|
|
||||||
<button id="myBtn" style= "width: 180px; font-size: 10pt;"><a> Download this {{ book.fileformat }}</a></button>
|
|
||||||
<div id="myModal" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<span class="close">×</span>
|
|
||||||
<h3>A message from the uploading librarian:</h3>
|
|
||||||
<span style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </span><br>
|
|
||||||
<h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4></a></div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
{% endif %}
|
|
||||||
>>>>>>> stack_stuff
|
|
||||||
=======
|
|
||||||
<a href="../uploads/{{ book.file }}">download {{ book.fileformat }}</a>
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>Instances:</p>
|
<p>Instances:</p>
|
||||||
@ -124,11 +95,11 @@
|
|||||||
<span class="close">×</span>
|
<span class="close">×</span>
|
||||||
<h3>A message from the uploading librarian:</h3>
|
<h3>A message from the uploading librarian:</h3>
|
||||||
<span style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </span><br>
|
<span style="font-style: italic;">"{{book.message or 'Happy reading.'}}" </span><br>
|
||||||
<h4><a href="../uploads/{{ book.file }}"> >>>> Link to file <<<<</h4></a></div>
|
<h4><a href="/viewpdf/{{ book.file }}"> >>>> Link to file <<<<</h4></a></div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
<button style= "font-size: 10pt;"> <a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a></button>
|
<button style= "font-size: 10pt;"> <a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a></button>
|
||||||
<button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>
|
<button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>
|
||||||
@ -141,4 +112,32 @@
|
|||||||
<a href="{{ url_for('show_book_by_id', id=nextbook.id )}}" style="float:right; font-size: 9pt;"> see the next book added to XPPL: <i>{{ nextbook.title|truncate(40,True,'...')}} </i>> </a>{% endif %}
|
<a href="{{ url_for('show_book_by_id', id=nextbook.id )}}" style="float:right; font-size: 9pt;"> see the next book added to XPPL: <i>{{ nextbook.title|truncate(40,True,'...')}} </i>> </a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% 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 %}
|
{% endblock %}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
||||||
<div class='widget'>
|
<div class='widget'>
|
||||||
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
|
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}</p>
|
{% endfor %}</p>
|
||||||
|
|
||||||
|
121
app/views.py
121
app/views.py
@ -15,12 +15,9 @@ from sqlalchemy.sql import except_
|
|||||||
from app.forms import UploadForm, EditForm, SearchForm, ChatForm, StackForm, AddtoStackForm, EditStackForm
|
from app.forms import UploadForm, EditForm, SearchForm, ChatForm, StackForm, AddtoStackForm, EditStackForm
|
||||||
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema, Instance, Potential
|
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema, Instance, Potential
|
||||||
from app.cover import get_cover
|
from app.cover import get_cover
|
||||||
<<<<<<< HEAD
|
from app.getannot import get_annotations, get_annot_results, get_annot_book
|
||||||
from app.getannot import get_annotations
|
|
||||||
from urllib.parse import quote as urlquote
|
from urllib.parse import quote as urlquote
|
||||||
=======
|
|
||||||
from app.extractText import extract_text
|
from app.extractText import extract_text
|
||||||
>>>>>>> master
|
|
||||||
from os import environ
|
from os import environ
|
||||||
from flask_socketio import SocketIO, emit
|
from flask_socketio import SocketIO, emit
|
||||||
from weasyprint import HTML
|
from weasyprint import HTML
|
||||||
@ -141,6 +138,9 @@ def show_books_grid():
|
|||||||
books = db.session.query(Book).all() # or you could have used User.query.all()
|
books = db.session.query(Book).all() # or you could have used User.query.all()
|
||||||
return render_template('show_books_grid.html', books=books)
|
return render_template('show_books_grid.html', books=books)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/books/<int:id>')
|
@app.route('/books/<int:id>')
|
||||||
def show_book_by_id(id):
|
def show_book_by_id(id):
|
||||||
book = Book.query.get(id)
|
book = Book.query.get(id)
|
||||||
@ -168,6 +168,16 @@ def show_book_by_id(id):
|
|||||||
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@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'])
|
@app.route('/books/<int:id>/delete', methods=['POST', 'GET'])
|
||||||
def remove_book_by_id(id):
|
def remove_book_by_id(id):
|
||||||
book_to_edit = Book.query.filter_by(id=id).first()
|
book_to_edit = Book.query.filter_by(id=id).first()
|
||||||
@ -474,18 +484,10 @@ def remove_from_stack(bookid, stackid):
|
|||||||
## search
|
## search
|
||||||
view = ['1']
|
view = ['1']
|
||||||
|
|
||||||
|
|
||||||
@app.route('/books', methods= ['POST','GET'])
|
@app.route('/books', methods= ['POST','GET'])
|
||||||
def show_books():
|
def show_books():
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
autocomplete.load() #Train markov model once, for autocomplete in search
|
|
||||||
books = db.session.query(Book).all()
|
|
||||||
=======
|
|
||||||
books = db.session.query(Book).order_by(Book.title)
|
books = db.session.query(Book).order_by(Book.title)
|
||||||
>>>>>>> stack_stuff
|
|
||||||
=======
|
|
||||||
books = db.session.query(Book).order_by(Book.title)
|
|
||||||
>>>>>>> master
|
|
||||||
search = SearchForm(request.form)
|
search = SearchForm(request.form)
|
||||||
view.append('1')
|
view.append('1')
|
||||||
viewby = '1'
|
viewby = '1'
|
||||||
@ -535,13 +537,6 @@ def search_results(searchtype, query, viewby):
|
|||||||
|
|
||||||
if searchtype== 'Stack':
|
if searchtype== 'Stack':
|
||||||
results=db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query)).order_by(Book.title)
|
results=db.session.query(Book).join(Book.stacks).filter(Stack.stack_name.contains(query)).order_by(Book.title)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
# if searchtype== 'Annotation':
|
|
||||||
# results=Book.query.filter(Book.category.contains(query)).all()
|
|
||||||
|
|
||||||
if not results:
|
|
||||||
=======
|
|
||||||
if searchtype== 'All':
|
if searchtype== 'All':
|
||||||
# results=Book.query.whoosh_search(query)
|
# results=Book.query.whoosh_search(query)
|
||||||
results=Book.query.filter(Book.title.contains(query))
|
results=Book.query.filter(Book.title.contains(query))
|
||||||
@ -553,7 +548,6 @@ def search_results(searchtype, query, viewby):
|
|||||||
|
|
||||||
if results.count() == 0:
|
if results.count() == 0:
|
||||||
books = Book.query.filter(Book.file.like('potential.pdf'))
|
books = Book.query.filter(Book.file.like('potential.pdf'))
|
||||||
>>>>>>> stack_stuff
|
|
||||||
upload_form = UploadForm(title= query, author='')
|
upload_form = UploadForm(title= query, author='')
|
||||||
return render_template('red_link.html', form=upload_form, title=query, books=books)
|
return render_template('red_link.html', form=upload_form, title=query, books=books)
|
||||||
|
|
||||||
@ -596,73 +590,18 @@ def search_results(searchtype, query, viewby):
|
|||||||
if viewby == '2':
|
if viewby == '2':
|
||||||
return render_template('results_grid.html', form=search, books=results, books_all=books_all, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage)
|
return render_template('results_grid.html', form=search, books=results, books_all=books_all, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
@app.route('/search_annot', methods=['POST', 'GET'])
|
||||||
<<<<<<< HEAD
|
def search_annot():
|
||||||
## Search - autocomplete
|
books = db.session.query(Book).all()
|
||||||
autocomplete_suggestions = []
|
if request.method=='POST':
|
||||||
autocomplete.load() #Train markov model once, for autocomplete in search
|
return redirect (url_for('annotations'))
|
||||||
|
|
||||||
@app.route('/autocomplete_suggestions', methods=['GET', 'POST'])
|
|
||||||
def test1():
|
|
||||||
if request.method == 'POST':
|
|
||||||
query = request.form['search']
|
|
||||||
query_tokenized = query.lower().split()
|
|
||||||
print(query_tokenized)
|
|
||||||
word_1 = query_tokenized[-2]
|
|
||||||
word_2 = query_tokenized[-1]
|
|
||||||
#print(word_1)
|
|
||||||
autocomplete_output = autocomplete.predict(word_1 , word_2)
|
|
||||||
autocomplete_suggestions.clear()
|
|
||||||
for suggestion, score in autocomplete_output:
|
|
||||||
autocomplete_suggestions.append(suggestion)
|
|
||||||
|
|
||||||
session['autocomplete_suggestions'] = str(autocomplete_suggestions)
|
|
||||||
|
|
||||||
print(session['autocomplete_suggestions'])
|
|
||||||
|
|
||||||
return Response(json.dumps(session['autocomplete_suggestions']), mimetype='application/json')
|
|
||||||
|
|
||||||
## STACKS!
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
else:
|
else:
|
||||||
return render_template('results.html', form=search, books=results, books_all=books_all, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage)
|
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)
|
||||||
|
|
||||||
|
|
||||||
# ## Search - autocomplete
|
|
||||||
# autocomplete_suggestions = []
|
|
||||||
|
|
||||||
# @app.route('/autocomplete_suggestions', methods=['GET', 'POST'])
|
|
||||||
# def test1():
|
|
||||||
# if request.method == 'POST':
|
|
||||||
# autocomplete.load()
|
|
||||||
# query = request.form['search']
|
|
||||||
# query_tokenized = query.lower().split()
|
|
||||||
# print(query_tokenized)
|
|
||||||
# word_1 = query_tokenized[-2]
|
|
||||||
# word_2 = query_tokenized[-1]
|
|
||||||
# #print(word_1)
|
|
||||||
# autocomplete_output = autocomplete.predict(word_1 , word_2)
|
|
||||||
# autocomplete_suggestions.clear()
|
|
||||||
# for suggestion, score in autocomplete_output:
|
|
||||||
# autocomplete_suggestions.append(suggestion)
|
|
||||||
#
|
|
||||||
# session['autocomplete_suggestions'] = str(autocomplete_suggestions)
|
|
||||||
#
|
|
||||||
# print(session['autocomplete_suggestions'])
|
|
||||||
#
|
|
||||||
# return Response(json.dumps(session['autocomplete_suggestions']), mimetype='application/json')
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
# print(autocomplete_suggestions)
|
|
||||||
|
|
||||||
# return Response(json.dumps(autocomplete_suggestions), mimetype='application/json')
|
|
||||||
>>>>>>> stack_stuff
|
|
||||||
=======
|
|
||||||
## STACKS!
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
@app.route('/add_to_stack/<int:id>', methods=['GET', 'POST'])
|
@app.route('/add_to_stack/<int:id>', methods=['GET', 'POST'])
|
||||||
def add_to_stack(id):
|
def add_to_stack(id):
|
||||||
stacks = db.session.query(Stack).all()
|
stacks = db.session.query(Stack).all()
|
||||||
@ -812,10 +751,12 @@ def send_text_file(file_name):
|
|||||||
@app.route('/annotations')
|
@app.route('/annotations')
|
||||||
def annotations():
|
def annotations():
|
||||||
"""Render annotations page."""
|
"""Render annotations page."""
|
||||||
|
books = db.session.query(Book).all()
|
||||||
|
# books = db.session.query(Book).order_by(Book.title)
|
||||||
|
# id = book.id
|
||||||
annot = get_annotations()
|
annot = get_annotations()
|
||||||
print(annot)
|
print(annot)
|
||||||
dump = json.dumps(annot, indent=2)
|
return render_template('annotations.html', annot=annot, books=books)
|
||||||
return render_template('annotations.html', annot=annot, dump=dump)
|
|
||||||
|
|
||||||
# PDF from annotations
|
# PDF from annotations
|
||||||
@app.route('/annotations.pdf')
|
@app.route('/annotations.pdf')
|
||||||
@ -825,6 +766,12 @@ def annotations_pdf():
|
|||||||
html = render_template(('annotations.html'), annot=annot)
|
html = render_template(('annotations.html'), annot=annot)
|
||||||
return render_pdf(HTML(string=html))
|
return render_pdf(HTML(string=html))
|
||||||
|
|
||||||
|
@app.route('/mybook.pdf')
|
||||||
|
def mybook_pdf():
|
||||||
|
# Make a PDF straight from HTML in a string.
|
||||||
|
html = redirect(url_for('search_annot'))
|
||||||
|
return render_pdf(HTML(string=html))
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def add_header(response):
|
def add_header(response):
|
||||||
|
10
run.py
10
run.py
@ -1,13 +1,3 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
from app import app, socketio
|
from app import app, socketio
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
# socketio.run(app)
|
|
||||||
app.run(debug=True,host="0.0.0.0",port=8080)
|
|
||||||
=======
|
|
||||||
socketio.run(app, port=8080)
|
|
||||||
=======
|
|
||||||
socketio.run(app,host="0.0.0.0", port=8080)
|
socketio.run(app,host="0.0.0.0", port=8080)
|
||||||
>>>>>>> master
|
|
||||||
#app.run(debug=True,host="0.0.0.0",port=8080)
|
|
||||||
>>>>>>> stack_stuff
|
|
||||||
|
Loading…
Reference in New Issue
Block a user