Merge branch 'master' of git.xpub.nl:/var/www/git.xpub.nl/repos/xpub-lib
This commit is contained in:
commit
0b70070c1f
@ -1,15 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
# #https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd
|
|
||||||
from flask import request
|
from flask import request
|
||||||
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-n8AksBoSB7kYoQ3eEwzpEr3nFQEmSp3XN-0PcKL_Sik"
|
KEY = "6879-n8AksBoSB7kYoQ3eEwzpEr3nFQEmSp3XN-0PcKL_Sik"
|
||||||
# URL = "https://monoskop.org/Monoskop"
|
|
||||||
|
|
||||||
#a dictionary containing necessary http headers
|
#a dictionary containing necessary http headers
|
||||||
headers = {
|
headers = {
|
||||||
@ -25,9 +19,9 @@ def get_annotations():
|
|||||||
r = requests.get(search_url, headers=headers)
|
r = requests.get(search_url, headers=headers)
|
||||||
#data is a python dictionary
|
#data is a python dictionary
|
||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
|
server = request.host
|
||||||
# r = requests.get(search_url, headers=headers)
|
for row in data['rows']:
|
||||||
# data = json.loads(r.text)
|
row['uri']= row['uri'].replace('http://' + server+'/uploads/','')
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{% 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%}
|
{%for book in books%}
|
||||||
{%if book.file == row.uri|replace('http://localhost:8080/uploads/','')%}
|
{%if book.file == row.uri%}
|
||||||
<p align="right" style="font-family:archivo narrow;font-size:10px;">Book</p>
|
<p align="right" style="font-family:archivo narrow;font-size:10px;">Book</p>
|
||||||
<a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:18px;">{{book.title}}</p></a><br>
|
<a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:18px;">{{book.title}}</p></a><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
14
app/views.py
14
app/views.py
@ -109,6 +109,8 @@ def annotations():
|
|||||||
books = db.session.query(Book).all()
|
books = db.session.query(Book).all()
|
||||||
# books = db.session.query(Book).order_by(Book.title)
|
# books = db.session.query(Book).order_by(Book.title)
|
||||||
# id = book.id
|
# id = book.id
|
||||||
|
server = request.host
|
||||||
|
rstr=('http://' + server+'/uploads/','')
|
||||||
annot = get_annotations()
|
annot = get_annotations()
|
||||||
print(annot)
|
print(annot)
|
||||||
return render_template('annotations.html', annot=annot, books=books, light=light)
|
return render_template('annotations.html', annot=annot, books=books, light=light)
|
||||||
@ -121,6 +123,17 @@ def annotations_pdf():
|
|||||||
html = render_template(('annotations.html'), annot=annot, light=light)
|
html = render_template(('annotations.html'), annot=annot, light=light)
|
||||||
return render_pdf(HTML(string=html))
|
return render_pdf(HTML(string=html))
|
||||||
|
|
||||||
|
# @app.route('/myannotations.pdf')
|
||||||
|
# def myannotations_pdf():
|
||||||
|
# books = db.session.query(Book).all()
|
||||||
|
# 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 = render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
|
||||||
|
# return render_pdf(HTML(string=html))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/viewpdf/<filename>')
|
@app.route('/viewpdf/<filename>')
|
||||||
def viewtestfile1_file(filename):
|
def viewtestfile1_file(filename):
|
||||||
return redirect("/static/viewer/web/viewer.html?file=%2Fuploads%2F"+urlquote(filename))
|
return redirect("/static/viewer/web/viewer.html?file=%2Fuploads%2F"+urlquote(filename))
|
||||||
@ -677,6 +690,7 @@ def search_annot():
|
|||||||
res = get_annot_results(annot,name)
|
res = get_annot_results(annot,name)
|
||||||
return render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
|
return render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
|
||||||
|
|
||||||
|
|
||||||
## STACKS!
|
## STACKS!
|
||||||
|
|
||||||
@app.route('/add_to_stack/<int:id>', methods=['GET', 'POST'])
|
@app.route('/add_to_stack/<int:id>', methods=['GET', 'POST'])
|
||||||
|
Loading…
Reference in New Issue
Block a user