Style it a bit.
This commit is contained in:
parent
c62d56684d
commit
f42632a451
23
main.py
23
main.py
@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import config
|
||||
from libbmc.citations import pdf
|
||||
import html
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from bottle import redirect, request, route, run, view
|
||||
from libbmc import doi
|
||||
from libbmc.citations import pdf
|
||||
|
||||
|
||||
@route("/upload", method="POST")
|
||||
@ -30,12 +33,21 @@ def do_upload():
|
||||
# Process citations
|
||||
with tempfile.NamedTemporaryFile() as fh:
|
||||
upload.save(fh)
|
||||
citations = pdf.cermine_dois(fh.name,
|
||||
override_local=config.CERMINE_PATH)
|
||||
raw_citations = pdf.cermine_dois(fh.name,
|
||||
override_local=config.CERMINE_PATH)
|
||||
citations = {
|
||||
html.unescape(k): {
|
||||
"doi": doi.to_canonical(v) if v is not None else v,
|
||||
"oa": doi.get_oa_version(doi.to_canonical(v) if v is not None
|
||||
else v)
|
||||
}
|
||||
for k, v in raw_citations.items()
|
||||
}
|
||||
|
||||
return {
|
||||
"params": {
|
||||
"citations": citations
|
||||
"citations": citations,
|
||||
"upload_name": upload.filename
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +67,7 @@ def index():
|
||||
Main index view, upload form.
|
||||
"""
|
||||
return {
|
||||
"params": {
|
||||
}
|
||||
"params": {}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,18 +3,66 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>CitationExtractor</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: auto;
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
h1 a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
form {
|
||||
padding-left: 25%;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
dt:not(:first-child) {
|
||||
margin-top: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1><a href="/">Citation Extractor</a></h1>
|
||||
|
||||
%if "error" in params:
|
||||
<p><strong>Error: {{ params["error"] }}</strong></p>
|
||||
% end
|
||||
|
||||
% if "citations" in params:
|
||||
<pre>{{ params["citations"] }}</pre>
|
||||
<p>Extracted citations for your paper <code>{{ params["upload_name"] }}</code> (not that some citations may have not been extracted properly):</p>
|
||||
<hr/>
|
||||
<dl>
|
||||
% for k, v in params["citations"].items():
|
||||
<dt>• {{ k }}</dt>
|
||||
<dd>>
|
||||
% if v["doi"] is not None:
|
||||
<a href="http://dx.doi.org/{{v["doi"]}}">doi://{{ v["doi"] }}</a>
|
||||
% else:
|
||||
<em>No DOI found.</em>
|
||||
% end
|
||||
</dd>
|
||||
<dd>>
|
||||
% if v["oa"] is not None:
|
||||
<a href="{{ v["oa"] }}">{{ v["oa"] }}</a>
|
||||
% else:
|
||||
<em>No OpenAccess version found.</em>
|
||||
% end
|
||||
</dd>
|
||||
% end
|
||||
</dl>
|
||||
% else:
|
||||
<p>This tool allows you to extract citations from a given PDF paper. Upload a file below and let it process your paper!</p>
|
||||
<hr/>
|
||||
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||
<p><label for="upload">Select a file: </label><input type="file" name="upload" id="upload" /></p>
|
||||
<p><input type="submit" value="Extract citations!" /></p>
|
||||
<p><input type="file" name="upload" id="upload" /> <span style="margin-left: 5em"><input type="submit" value="Extract citations!" /></span></p>
|
||||
</form>
|
||||
% end
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user