Now list cited papers that could be uploaded to an OA repository

This commit is contained in:
Lucas Verney 2016-02-11 15:42:31 +01:00
parent f42632a451
commit 662a328047
3 changed files with 40 additions and 8 deletions

29
main.py
View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import config import config
import html import html
import json
import os import os
import tempfile import tempfile
@ -10,6 +9,28 @@ from libbmc import doi
from libbmc.citations import pdf from libbmc.citations import pdf
def format_citation(doi_url):
if doi_url is None:
return {
"doi": None,
"oa": None,
"sharable": None
}
canonical_doi = doi.to_canonical(doi_url)
sharable = doi.get_oa_policy(canonical_doi)
if sharable is None:
sharable = False
else:
sharable = "can" in sharable.values()
return {
"doi": canonical_doi,
"oa": doi.get_oa_version(canonical_doi),
"sharable": sharable
}
@route("/upload", method="POST") @route("/upload", method="POST")
@view("template.tpl") @view("template.tpl")
def do_upload(): def do_upload():
@ -36,11 +57,7 @@ def do_upload():
raw_citations = pdf.cermine_dois(fh.name, raw_citations = pdf.cermine_dois(fh.name,
override_local=config.CERMINE_PATH) override_local=config.CERMINE_PATH)
citations = { citations = {
html.unescape(k): { html.unescape(k): format_citation(v)
"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() for k, v in raw_citations.items()
} }

View File

@ -1,2 +1,2 @@
bottle>=0.12.9 bottle>=0.12.9
libbmc>=0.1.2 libbmc>=0.1.3.1

View File

@ -27,6 +27,14 @@
dt:not(:first-child) { dt:not(:first-child) {
margin-top: 1em; margin-top: 1em;
} }
.red {
text-color: red;
}
.green {
text-color: green;
}
</style> </style>
</head> </head>
<body> <body>
@ -53,7 +61,14 @@
% if v["oa"] is not None: % if v["oa"] is not None:
<a href="{{ v["oa"] }}">{{ v["oa"] }}</a> <a href="{{ v["oa"] }}">{{ v["oa"] }}</a>
% else: % else:
<em>No OpenAccess version found.</em> <em>
No OpenAccess version found.
% if v["sharable"]:
<strong class="green">It could be shared.</strong>
% else:
<strong class="red">It could not be shared.</strong>
% end
</em>
% end % end
</dd> </dd>
% end % end