Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//For questions, email Stephen X. Flynn, College of Wooster: sflynn (at) wooster.edu //Updates: //May 2013 - fixed pubpdf() to detect both "failed" and "notfound" ISSN numbers, similar to finaldraft() //March 2013 - new functions for Final Drafts and OA mandates //Instructions: //Watch a quick installation video at http://youtu.be/ZMyKVHM5nOc //(A) Register for an API key at http://www.sherpa.ac.uk/romeo/apiregistry.php then insert the key below in the "Sherpa API key" section of the code. Without an API key, you will be limited to 500 requests per day, per IP address. //(1) Perform an affiliation search in a large bibliographic database, such as Scopus or Web of Knowledge. Include the ISSN metadata in the database export, since the function depends on the ISSN to work. Export this search to a .csv file. //(2) Import the .csv into a Google Spreadsheet with at a minimum, columns for the following: ISSN, pubpdf, finaldraft, embargo, checkOAMandate. Other details like Journal title, Article title, and Author are optional. //(3) CRITICAL: Select the ISSN column, select Format -> Number -> Plain Text. Or else the script won't work! //(4) Go to Script -> Script Editor //(5) Copy and paste all the following into script editor window, and save. //(6) Use the three functions described below in their corresponding columns. For example, =pubpdf(19352735) will lookup the ISSN 1935-2735 (PLoS Neglected Tropical Diseases) in Sherpa/Romeo, and result in the text "Publisher's version/PDF may be used". //TIP: Go to Format -> Conditional formatting... to set up color codes to help visualize your column outputs. //TIP: Beware of excessive use imposed by Google. Currently you are limited to 20,000-50,000 URL lookups per day. See https://docs.google.com/macros/dashboard for UrlFetch specifically. //TIP: To avoid excessive usage, after running a set of ISSNs, copy and paste over the discovered values by going to Edit -> Paste special -> Paste values only //Function: this is the main function that checks if the ISSN is a journal which permits publisher PDF archiving function pubpdf(issn) { var text = getXML(issn); // checks to see if the issn is invalid var failText=text.search("<outcome>failed</outcome>"); var notfound=text.search("<outcome>notFound</outcome>"); // checks to see if the issn is missing if (issn == 00000000 || issn == 0000-0000 || issn == "") { return ("blank ISSN") } else if (failText > 0){ return ("ISSN invalid") } else if (notfound > -1){ return ("not found") } else if (failText == -1) { return permPdfGet(text); } } //checks if the ISSN is a journal which permits archiving final drafts to repositories function finaldraft(issn){ var text = getXML(issn); // checks to see if the issn is invalid var failText=text.search("<outcome>failed</outcome>"); var notfound=text.search("<outcome>notFound</outcome>"); // checks to see if the issn is missing if (issn == 00000000 || issn == 0000-0000 || issn == "") { return ("blank ISSN") } else if (failText > 0){ return ("ISSN invalid") } else if (notfound > -1){ return ("not found") } else if (failText == -1) { return permFinal(text); } } //Function: look for the word "Embargo" in the journal's copyright record function embargo(issn){ var xmlText = getXML(issn); var embargoPDF=xmlText.search("embargo"); if (embargoPDF == "-1") { embargoPDF="no" } else if (embargoPDF > 0 ) { embargoPDF = "Embargo" } return embargoPDF; } //checks if the ISSN is a journal which specifically forbids uploading to Open Access mandate institutional repositories function checkOAmandate(issn){ var text = getXML(issn); // checks to see if the issn is invalid var failText=text.search("<outcome>failed</outcome>"); var notfound=text.search("<outcome>notFound</outcome>"); // checks to see if the issn is missing if (issn == 00000000 || issn == 0000-0000 || issn == "") { return ("blank ISSN") } else if (failText > 0){ return ("ISSN invalid") } else if (notfound > -1){ return ("not found") } else if (failText == -1) { return antiOAmandate(text); } } //Function: use this function if your system deleted the starting zeros of your ISSN numbers. DSpace 1.6 does this on //a metadata export. function fixISSNdoc(issn) { issn = fixissn(issn); if (issn == 00000000 || issn == 0000-0000 || issn == "") { return ("blank ISSN") } else if (issn.length > 9) { return ("invalid issn") } else return issn; } //test function for logging purposes function testSherp() { var result = pubpdf("2041-8205"); Logger.log("test result is '" + result + "'"); } //These are all the "Helper" functions used in the main functions function fixissn(issn){ Logger.log("Old issn " + issn); //if there's a dash in the ISSN, it need 9 characters instead of 8 if (issn.search("-") > -1) { var mis = 9; } else if (issn.search("-") == -1) { var mis = 8; } //if the ISSN is less than 9 or 8 (mis), add zeros to the beginning while (issn.length < mis && issn.length > 0) { //zero added to beginning of ISSN issn = 0 + issn } Logger.log("fixed to new issn " + issn); return issn; } function getXML(issn){ // retrieves XML output from Sherpa API using issn input issn = fixissn(issn); //Google scripts will timeout if you run the script too often. These sleep actions are designed to space out your commands. Comment out the next 6 lines if you're testing and only running small batches (less than 10 at a time). var randnumber = Math.random()*5000; Utilities.sleep(randnumber); Utilities.sleep(randnumber); Utilities.sleep(randnumber); Utilities.sleep(randnumber); Utilities.sleep(randnumber); //Sherpa API key for College of Wooster //register for a key at http://www.sherpa.ac.uk/romeo/apiregistry.php var sherpaAPIkey = ""; //insert your API key inside the quotes var parameters = {method : "get"}; var xmlText = UrlFetchApp.fetch("http://www.sherpa.ac.uk/romeo/api29.php?issn=" + issn + "&versions=all" + "&ak=" + sherpaAPIkey,parameters).getContentText(); return xmlText; } function permPdfGet(txt) { var pdfCan=txt.search("<pdfarchiving>can</pdfarchiving>"); var pdfRestricted=txt.search("<pdfarchiving>restricted</pdfarchiving>") var pdfCannot=txt.search("<pdfarchiving>cannot</pdfarchiving>"); var pdfUnknown=txt.search("<pdfarchiving>unknown</pdfarchiving>"); var oaPub=txt.search("DOAJ says it is an open access journal"); var noIR=txt.search("Cannot post on archival website or institutional repository"); var noIR2=txt.search("cannot deposit on archival website or institutional repository"); //if we find specific negative phrase or if <pdfarchiving> is "cannot" if ((pdfCannot > -1) || (noIR > -1) || (noIR2 > -1)) { var permTxt = "No publisher PDF" } else if (pdfUnknown > -1) { permTxt = "Unknown" // if its an open access journal, but not "pdf may be used" } else if (oaPub > -1 && pdfCan == "-1") { permTxt = "Open access journal, check PDF" } else if (pdfCan > -1) { // if <pdfarchiving> is "can" permTxt = "Publisher's version/PDF may be used" } else if (pdfRestricted > -1) { // if <pdfarchiving> is "restricted" with an embargo permTxt= "Publisher's version/PDF may be used after an embargo period" } return permTxt; } function permFinal(txt) { var finalPerm=txt.search("<postarchiving>restricted</postarchiving>"); var finalPermNO=txt.search("<postarchiving>cannot</postarchiving>"); var finalPermIDK=txt.search("<postarchiving>unknown</postarchiving>"); if (finalPerm == "-1" && finalPermNO == "-1" && finalPermIDK == "-1"){ var finalPerm = "Final draft allowed" }else if (finalPerm > -1) { finalPerm = "Final draft restricted" }else if (finalPermNO > -1) { finalPerm = "NO final draft allowed" } else if (finalPermIDK > -1) { finalPerm = "status unknown" } return finalPerm; } //some publishers like Elsevier single out institutions with open access mandates function antiOAmandate(txt) { var antiOA=txt.search("separate agreement between repository and publisher exists"); if (antiOA > -1) { var antiOAstatus = "Anti OA mandate" } else if (antiOA == "-1") { antiOAstatus = "all good!" } return antiOAstatus; }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
Bash | 7 min ago
ffxi_xinput.ahk
Autohotkey | 9 min ago
BaRoN klipper conf...
INI file | 38 min ago
infini stam
Lua | 1 hour ago
C++K3
C++ | 1 hour ago
gradle log
Java | 1 hour ago
My Log File
HTML 5 | 1 hour ago
Untitled
Lua | 1 hour ago
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!