Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark MacGillivray committed Mar 20, 2019
2 parents 7d391f0 + 970f7f9 commit af60008
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 19 deletions.
2 changes: 1 addition & 1 deletion content/direct2aam.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1 style="font-size:2.4em; text-align:center;">Direct2AAM: Helping Authors Find
<!-- TODO add share buttons -->
<p style="text-align: center;">
<i>
and see our <a href="/versions-explained">version explainer for authors</a>.
and see our <br><a href="/versions-explained">version explainer for authors</a>.
</i>
</p>

Expand Down
4 changes: 2 additions & 2 deletions content/instantill.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
}
</style>

<!-- <div class="alert alert-info" style="display:solid;">
<div class="alert alert-info" style="display:solid;">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<p style="text-align:center">InstantILL is coming soon. See our <a href="https://blog.openaccessbutton.org/new-powerfully-simple-library-tool-to-deliver-articles-no-subscription-needed-1c8b7def604f">blog</a> for a preview of what to expect.</p>
</div> -->
</div>

<div class="container-fluid">

Expand Down
80 changes: 80 additions & 0 deletions content/instantill2.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@
$('#oabutton_find').trigger('click');
},500)
});

var save = function(e) {
if (e) e.preventDefault();
var data = {};
$('.setting').each(function(i, obj) {
if ( $(this).val() !== undefined ) {
data[$(this).attr('id')] = $(this).val();
}
});

var opts = {
url: api + '/ill/config',
type:'POST',
cache:false,
processData:false,
contentType: 'application/json',
dataType: 'json',
success: function(data) {
$('#save').hide().after('<span id="saved">Changes saved!</span>');
setTimeout(function() { $('#saved').hide(); $('#save').show(); }, 5000);
},
error: function(data) {
$('#save').hide().after('<span id="saved">Sorry, changes could not be saved.</span>');
setTimeout(function() { $('#saved').hide(); $('#save').show(); }, 5000);
},
beforeSend: function (request) { request.setRequestHeader("x-apikey", noddy.apikey); }
}
opts.data = JSON.stringify(data);
$.ajax(opts);
}

noddy.afterLogin = function() {
$('.promptsignup').hide();
Expand All @@ -16,6 +46,16 @@
$('.stickidin').html($('.stickidin').html().replace('instantill()','instantill({uid:"' + uid + '"})'));
$('#onlyyou').html($('#onlyyou').html().replace('but only you ','but only you (' + noddy.user.account.profile.firstname + ') '));
instantill({uid:uid, api:api});
console.log(noddy.user.account.service)
try {
for (var k in noddy.user.account.service.openaccessbutton.ill.config) {
$('#'+k).val(noddy.user.account.service.openaccessbutton.ill.config[k]);
}
} catch(err) {}
$('#save').bind('click',save);
if (noddy.hasRole('root')) {
$('#ill_config').prepend('<input style="border-color:red;" id="uid" type="text" class="form-control setting" placeholder="UID (ADMIN setting override)"><br>')
}
}
noddy.nologin = function() {
instantill({uid:'oab_site', api:api});
Expand Down Expand Up @@ -99,6 +139,46 @@ <h2>Install your own</h2>
<pre>
&lt;div id="instantill"&gt;&lt;/div&gt;</pre>
</ol>

<h2>Configure your OpenURL <small>(optional)</small></h2>

<p>We can forward OpenURL requests (or any request) to a URL of your choice, to trigger your ILL workflow.
Just set your base URL, any necessary URL params that must always be present, <!--, request method,-->
and the URL parameter keys you would like us to put the various bits of metadata in, if our defaults are not suitable.
(Our defaults are OpenURL compatible, so these can be used without changes if all you need is OpenURL compatibility.)</p>

<p id="ill_config">
URL (required)<br>
<input id="ill_redirect_base_url" type="text" class="form-control setting" placeholder="URL (required)"><br>
Add any additional params your base URL needs, such as a=b&c=d<br>
<input id="ill_redirect_params" type="text" class="form-control setting" placeholder="Add any additional params your base URL needs"><br>
<!--<input id="method" type="text" class="form-control setting" placeholder="Method (default GET)"><br>-->
Title<br>
<input id="title" type="text" class="form-control setting" placeholder="Title (default atitle)"><br>
Journal title<br>
<input id="journal" type="text" class="form-control setting" placeholder="Journal title (default title)"><br>
DOI<br>
<input id="doi" type="text" class="form-control setting" placeholder="DOI (default rft_id)"><br>
Author<br>
<input id="author" type="text" class="form-control setting" placeholder="Author (default au)"><br>
ISSN<br>
<input id="issn" type="text" class="form-control setting" placeholder="ISSN (default issn)"><br>
Volume<br>
<input id="volume" type="text" class="form-control setting" placeholder="Volume (default volume)"><br>
Issue<br>
<input id="issue" type="text" class="form-control setting" placeholder="Issue (default issue)"><br>
Page<br>
<input id="page" type="text" class="form-control setting" placeholder="Page (default pages)"><br>
Published<br>
<input id="published" type="text" class="form-control setting" placeholder="Published (default date)"><br>
PMID<br>
<input id="pmid" type="text" class="form-control setting" placeholder="PMID (default pmid)"><br>
<!--<input id="pmcid" type="text" class="form-control setting" placeholder="PMCID (default pmcid)"><br>-->
Year
<input id="year" type="text" class="form-control setting" placeholder="Year (default rft.year)">
</p>

<p><a id="save" class="btn btn-primary btn-block" href="#">Save your settings</a></p>

<p>If anything is wrong, <a href="mailto:[email protected]?Subject=Trouble%20setting%20up%20InstantILL&body=Please%20send%20us%20the%20URL%20of%20the%20page%20you're%20working%20on,%20or%20a%20screenshot%20of%20what%20you're%20seeing%20and%20a%20copy%20of%20the%20page's%20code%20-%20right-click%20on%20the%20page%20and%20View%20Page%20Source.">get in touch</a>.</p>
</div>
Expand Down
47 changes: 33 additions & 14 deletions content/permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

</style>

<div class="alert alert-info" style="display:solid;">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<p style="text-align:center">
This service is functional and in testing with early adopters but unfinished, and unannounced. Please don't share this page. To be notified when it is released, <a href="/libraries">sign up now</a>.
</p>
</div>

<div class="container-fluid">
<div class="col-lg-12">
<h1 style="font-size:2.4em; text-align:center;">Automatic Permissions Checker</h1>
Expand All @@ -40,40 +47,44 @@ <h1 style="font-size:2.4em; text-align:center;">Automatic Permissions Checker</h
<div class="col-lg-7 col-sm-6">

<p style="text-align: auto;line-height: 2;">
Knowing what copy of an authors work can be legally put in a repository, with all the correct embargos, statements and metadata can be slow, complex, and expensive. It's yet another barrier to authors depositing or service for libraries to provide. In our new automated permissions checker, backed by Open, machine-readable data, we make it easy for anyone to check hundreds of articles in seconds without any specialized knowledge. The service aims to take into account university, funder, publisher and journal policies, and any permissions an author has negotiated to give a clear picture of what can be shared.<br><br>
Knowing what copy of an authors work can be legally put in a repository, with the correct embargo, statements, and metadata can be a big barrier to authors depositing, or expensive service for libraries to provide. We've built an automated permissions checker, backed by Open machine-readable data, to make it easy to check hundreds of articles in seconds without any specialized knowledge. The service gives a clear picture of what can be shared by taking into account university, funder, publisher, journal policies, and any expections an author has negotiated.

<!--Built as part of the Open Access Button Request System, we're now making it broadly available as a standalone service for librarians everywhere. You're invited to try it, use the data for your own services, and contribute to the datasets with your own knowledge. APIs, and next generation services built using the system coming soon.-->

Built as part of the Open Access Button Request System, we're now making it broadly available as a standalone service for librarians everywhere. You're invited to try it, use the data for your own services, and contribute to the datasets with your own knowledge. APIs, and next generation services built using the system coming soon.
</p>

</div>

<div class="col-lg-5 col-sm-6">

<p style="text-align: center;">
<a href="https://docs.google.com/document/d/1N7ZFHaw58-KVEuibSV544eqMMcdeXj1rj1U-QE3qXpk/edit?usp=sharing" target="_blank">
<button id="permissions_background" class="pinger btn btn-action" style="width:70%;">
Background
<a href="https://docs.google.com/spreadsheets/d/1K6JyYEMtCLxD_mW1UxlYM8gMu1ElXiy20NR3LEQCXUo/copy" target="_blank">
<button id="permissions_app" class="pinger btn btn-action" style="width:70%;">
Try it out<!-- version number, doesn't need to be seen with eye (V0.92)-->
</button>
</a>
</p>
<p style="text-align: center;">
<a href="https://docs.google.com/spreadsheets/u/1/d/1BtJrouGapTKSrlXkMGGqcaYQe_-tUNRH5iYnJ1jdYdE/copy" target="_blank">
<button id="permissions_app" class="pinger btn btn-action" style="width:70%;">
Get it (V0.86)
</button>
</a>
<i>
<a href="https://docs.google.com/document/d/1N7ZFHaw58-KVEuibSV544eqMMcdeXj1rj1U-QE3qXpk/edit?usp=sharing" id="permissions_background">and see how it works</a>
</i>
</p>
<p style="text-align: center;">
<a href="https://docs.google.com/spreadsheets/u/1/d/1XYydXYOv29Omda0aZbpSCQzclFTNk5_f8FrAJoAbnJ4/edit#gid=957176771" target="_blank">
<button id="permissions_ViewData" class="pinger btn btn-action" style="width:70%;">
View Data
Get Raw Data
</button>
</a>
</p>
<i>
<p style="text-align: center;">
<a href="https://docs.google.com/document/d/1v93bJt21rMZUL0K4hFp-7wE-b4WxLJWL8dfomKizqCE/edit?usp=sharing" id="permissions_AddingData">and contribute data</a>
</p>
</i>
<p style="text-align: center;">
<a href="https://docs.google.com/document/d/1v93bJt21rMZUL0K4hFp-7wE-b4WxLJWL8dfomKizqCE/edit?usp=sharing" target="_blank">
<button id="permissions_AddingData" class="pinger btn btn-action" style="width:70%;">
Add Data (Coming Soon)
<a href="" target="_blank">
<button class="pinger btn btn-action" style="width:70%;">
Get Updates
</button>
</a>
</p>
Expand All @@ -92,3 +103,11 @@ <h1 style="font-size:2.4em; text-align:center;">Automatic Permissions Checker</h
</div>

</div>

<!-- Code to pull in alpha release banner -->
<div w3-include-html="/static/alpha.html"></div>
<script src="https://www.w3schools.com/lib/w3.js"></script>

<script>
w3.includeHTML();
</script>
21 changes: 21 additions & 0 deletions noddy/service/oabutton/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ API.add 'service/oab/ill',
opts[o] = this.queryParams[o]
return API.service.oab.ill.start opts

API.add 'service/oab/ill/config',
get:
authRequired: 'openaccessbutton.user'
action: () ->
try
return this.user.service.openaccessbutton.ill.config
catch
return 404
post:
authRequired: 'openaccessbutton.user'
action: () ->
opts = this.request.body ? {}
for o of this.queryParams
opts[o] = this.queryParams[o]
if opts.uid and API.accounts.auth 'root', this.user
user = Users.get opts.uid
delete opts.uid
else
user = this.user
return API.service.oab.ill.config user, opts

API.add 'service/oab/ill/:library',
post: () ->
opts = this.request.body
Expand Down
4 changes: 4 additions & 0 deletions noddy/service/oabutton/find.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ API.service.oab.find = (opts={url:undefined,type:undefined}) ->
meta = API.service.oab.ill.metadata ret.meta.article, opts
for m of meta
ret.meta.article[m] ?= meta[m]
try
if opts.from?
ret.ill ?= {}
ret.ill.redirect = API.service.oab.ill.redirect opts.from, meta

#opts.url = 'https://doi.org/' + ret.meta.article.doi if opts.url.indexOf('http') isnt 0 and ret.meta.article.doi
# so far we are only doing availability checks for articles, so only need to check requests for data types or articles that were not found yet
Expand Down
79 changes: 79 additions & 0 deletions noddy/service/oabutton/ill.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,85 @@ API.service.oab.ill.start = (opts={}) ->
else
return 404

API.service.oab.ill.config = (user, config) ->
# need to set a config on live for the IUPUI user ajrfnwswdr4my8kgd
# the URL params they need are like
# https://ill.ulib.iupui.edu/ILLiad/IUP/illiad.dll?Action=10&Form=30&sid=OABILL&genre=InstantILL&aulast=Sapon-Shevin&aufirst=Mara&issn=10478248&title=Journal+of+Educational+Foundations&atitle=Cooperative+Learning%3A+Liberatory+Praxis+or+Hamburger+Helper&volume=5&part=&issue=3&spage=5&epage=&date=1991-07-01&pmid
# and their openurl config https://docs.google.com/spreadsheets/d/1wGQp7MofLh40JJK32Rp9di7pEkbwOpQ0ioigbqsufU0/edit#gid=806496802
# tested it and set values as below defaults, but also noted that it has year and month boxes, but these do not correspond to year and month params, or date params
if config?
update = {}
for k in ['ill_redirect_base_url','ill_redirect_params','method','title','doi','pmid','pmcid','author','journal','issn','volume','issue','page','published','year']
update[k] = config[k] if config[k]?
if not user.service.openaccessbutton.ill?
Users.update user._id, {'service.openaccessbutton.ill': {config: update}}
else
Users.update user._id, {'service.openaccessbutton.ill.config': update}
return true
else
try
user = Users.get(user) if typeof user is 'string'
return user.service.openaccessbutton.ill.config ? {}
catch
return {}

API.service.oab.ill.redirect = (uid, meta={}) ->
config = API.service.oab.ill.config uid
config ?= {}
# add iupui / openURL defaults to config
defaults =
title: 'atitle' # this is what iupui needs (title is also acceptable, but would clash with using title for journal title, which we set below, as iupui do that
doi: 'rft_id' # don't know yet what this should be
#pmid: 'pmid' # same as iupui ill url format
pmcid: 'pmcid' # don't know yet what this should be
#aufirst: 'aufirst' # this is what iupui needs
#aulast: 'aulast' # this is what iupui needs
author: 'aulast' # author should actually be au, but aulast works even if contains the whole author, using aufirst just concatenates
journal: 'title' # this is what iupui needs
#issn: 'issn' # same as iupui ill url format
#volume: 'volume' # same as iupui ill url format
#issue: 'issue' # same as iupui ill url format
#spage: 'spage' # this is what iupui needs
#epage: 'epage' # this is what iupui needs
page: 'pages' # iupui uses the spage and epage for start and end pages, but pages is allowed in openurl, check if this will work for iupui
published: 'date' # this is what iupui needs, but in format 1991-07-01 - date format may be a problem
year: 'rft.year' # this is what IUPUI uses
# IUPUI also has a month field, but there is nothing to match to that
for d of defaults
config[d] = defaults[d] if not config[d]
if not config?.ill_redirect_base_url?
return ''
else
url = config.ill_redirect_base_url
url += if url.indexOf('?') is -1 then '?' else '&'
url += config.ill_redirect_params.replace('?','') + '&' if config.ill_redirect_params
for k of meta
v = false
if k is 'author'
# need to check if config has aufirst and aulast or something similar, then need to use those instead,
# if we have author name parts
try
if typeof meta.author is 'string'
v = meta.author
else if _.isArray meta.author
v = ''
for author in meta.author
v += ', ' if v.length
if typeof author is 'string'
v += author
else if author.family
v += author.family + if author.given then ', ' + author.given else ''
else
if meta.author.family
v = meta.author.family + if meta.author.given then ', ' + meta.author.given else ''
else
v = JSON.stringify meta.author
else if k not in ['started','ended','took']
v = meta[k]
if v
url += (if config[k] then config[k] else k) + '=' + v + '&'
return url

API.service.oab.ill.metadata = (metadata={}, opts={}) ->
metadata.started ?= Date.now()
# metadata is whatever we already happened to find when doing availability or other checks
Expand Down
4 changes: 2 additions & 2 deletions noddy/service/oabutton/scrape.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ API.service.oab.crossref = (cr) ->
try res.author = cr.author
try res.journal = cr['container-title'][0]
try res.issue = cr.issue
try meta.volume = cr.volume
try meta.page = cr.page.toString()
try res.volume = cr.volume
try res.page = cr.page.toString()
try res.issn = cr.ISSN[0]
try res.subject = cr.subject # not sure if this is present in crossref... check anyway
try res.publisher = cr.publisher
Expand Down
Loading

0 comments on commit af60008

Please sign in to comment.