Browse Source

Merge branch 'master' of git.xpub.nl:/var/www/git.xpub.nl/repos/xpub-lib

ansible-setup-and-deploy
Alex 6 years ago
parent
commit
28301aa037
  1. 17
      app/getannot.py
  2. 60
      app/static/css/style.css
  3. 2
      app/templates/about.html
  4. 1
      app/templates/base.html
  5. 1
      app/templates/home.html
  6. 6
      app/templates/results_annot.html
  7. 10
      app/templates/show_book_detail.html
  8. 10
      app/views.py

17
app/getannot.py

@ -1,17 +1,7 @@
# #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():
from flask import request
import requests
import json
@ -58,16 +48,17 @@ def get_annot_results(annot,name):
def get_annot_book(annot,name):
res=[]
server = request.host
for item in annot['rows']:
if 'selector' in item['target'][0]:
if len(item['target'][0]['selector'])>2:
string=item['uri']
if name==string.replace('http://localhost:8080/uploads/',''):
if name==string.replace('http://' + server+'/uploads/',''):
data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title'], 'url':item['uri']}
res.append(data)
else:
string=item['uri']
if name==string.replace('http://localhost:8080/uploads/',''):
if name==string.replace('http://' + server+'/uploads/',''):
data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title'], 'url':item['uri']}
res.append(data)
return res

60
app/static/css/style.css

@ -176,6 +176,64 @@ background-color:red;
color: #fafafa;
}
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
float: left;
display: none;
min-width: 160px;
padding: 4px 0;
margin: 0 0 10px 25px;
list-style: none;
background-color: #ffffff;
border-color: #ccc;
border-color: rgba(0, 0, 0, 0.2);
border-style: solid;
border-width: 1px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
*border-right-width: 2px;
*border-bottom-width: 2px;
}
.ui-menu-item > a.ui-corner-all {
display: block;
padding: 3px 15px;
clear: both;
font-weight: normal;
line-height: 18px;
color: #555555;
white-space: nowrap;
text-decoration: none;
}
.ui-menu-item {
margin: 3px 15px;
}
.ui-state-hover, .ui-state-active {
color: #ffffff;
text-decoration: none;
background-color: #0088cc;
border-radius: 0px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
background-image: none;
}
.ui-helper-hidden-accessible {
display: none;
}
.footer{
@ -489,4 +547,4 @@ nav { font-size: .7em }
@page { size: A5; margin: 1cm }
@media print {
nav { display: none }
}
}

2
app/templates/about.html

@ -13,7 +13,7 @@ This digital library gathers all the books and articles floating around on the s
It starts at XPUB, but can go anywhere we want it to.
<br>
<br>
Are you interested in how this library works? Have a look at the source code in <a href 'https://git.xpub.nl/xpub-lib/log.html'> our git. </a>
Are you interested in how this library works? Have a look at the source code in <a href= 'https://git.xpub.nl/xpub-lib/log.html'> our git. </a>
</p>
<h2> What's the deal with the stacks? </h2>
<p class='about'>

1
app/templates/base.html

@ -15,7 +15,6 @@
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/js/jquery-ui-1.12.1.custom/jquery-ui.css">
{% block css %} {% endblock%}
</head>
<body>

1
app/templates/home.html

@ -26,6 +26,7 @@ Feel free to browse our catalogue, interfaced in many different ways.
</form>
</div>
{%endif%}
{{ chat.message }}
<div id="app" class="container">
<div class="messageback1"></div>

6
app/templates/results_annot.html

@ -6,12 +6,12 @@
<form style="float:left;" action="/search_annot" method="GET">
<div style="float:left;" class="search">
<input type="text" name="query" value="{{name}}">
<input type="text" name="query" value="">
</div>
<input style="background-color: grey; color:white; font-family: archivo narrow; font-size: 18px; border: none;padding: 8px 24px;" type="submit" value="browse annotations"></input>
</form>
<br><br><br>
<!-- <a href="{{ url_for('mybook_pdf')}}" style="color:#ff3300;">Get as PDF</a> -->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="annotations" style="color:#ff3300;"> All annotations</a><br><br>
<a href="annotations" style="color:#ff3300;"> All annotations</a><br><br>
<h1 class="header">Annotations/ Extracts with:&nbsp;&nbsp;<i>{{name}}</i></h1>
@ -52,4 +52,4 @@
{% endblock %}
{% endblock %}

10
app/templates/show_book_detail.html

@ -109,9 +109,9 @@
<br><br>
{%endif%}
{%if res %}
<div style="padding-bottom:20px;">
<p>Annotations for <i>{{book.title}}</i>:</p>
<h2>Annotations for <i>{{book.title}}</i>:</h4>
{% for row in res%}
<hr>
<p style="font-family:archivo narrow;font-size:10px;">Extract</p>
@ -128,6 +128,8 @@
{% endif %}
{% endfor %}
{%else%}<div style="padding-bottom:50px;"><i> No annotations yet for this book </i></div>
{%endif%}
</div>
<hr>
{% if previousbook %}
@ -137,8 +139,4 @@
</div>
{% endblock %}

10
app/views.py

@ -111,14 +111,14 @@ def annotations():
# id = book.id
annot = get_annotations()
print(annot)
return render_template('annotations.html', annot=annot, books=books)
return render_template('annotations.html', annot=annot, books=books, light=light)
# PDF from annotations
@app.route('/annotations.pdf')
def annotations_pdf():
annot = get_annotations()
# Make a PDF straight from HTML in a string.
html = render_template(('annotations.html'), annot=annot)
html = render_template(('annotations.html'), annot=annot, light=light)
return render_pdf(HTML(string=html))
@app.route('/viewpdf/<filename>')
@ -136,7 +136,7 @@ def get_updates():
allbooks = db.session.query(Book).all()
id = len(allbooks)
latest_upload = allbooks[-1]
return "This is the XPPL ~ Library XPUB ~ Updates / / / / / / / Last viewed: " + userin.info + " / / / / / / / " + str(len(allbooks)) + " Books online "+ " / / / / / / / " + "Latest upload: " + latest_upload.title
return "This is the XPPL ~ Library XPUB ~ Updates / / / / / / / Last viewed: " + userin.info + " / / / / / / / " + str(len(allbooks)) + " Books online "+ " / / / / / / / " + "Latest entry: " + latest_upload.title
@app.route('/scape', methods=['POST', 'GET'])
def scape():
@ -204,7 +204,7 @@ def show_book_by_id(id):
if not book:
return render_template('red_link.html', id=id, light=light)
else:
return render_template('show_book_detail.html', book=book, previousbook = previousbook, nextbook = nextbook, all_instances=all_instances, name=name, annot=annot, res=res)
return render_template('show_book_detail.html', book=book, previousbook = previousbook, nextbook = nextbook, all_instances=all_instances, name=name, annot=annot, res=res, light=light)
@ -763,7 +763,7 @@ def import_csv():
name, file_extension = os.path.splitext(row['file'])
print ('get_cover', fullpath, name)
cover = get_cover(fullpath, name)
file = str(id) + "_" + row['file']
file = row['file']
if row['year_published']:
year_published = int(row['year_published'])

Loading…
Cancel
Save