summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-30 22:12:51 +0000
committerKarl Berry <karl@freefriends.org>2019-11-30 22:12:51 +0000
commit3ab1735000843dbb21b8791fc3f86268353ea0df (patch)
treefcc83aec333a8e0baf7b812369d4fd405270b890 /Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua
parentd21180ffc58ada4628b8ec4438d81cddbae4264a (diff)
biblatex-ext (30nov19)
git-svn-id: svn://tug.org/texlive/trunk@52977 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua')
-rw-r--r--Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua49
1 files changed, 35 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua b/Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua
index 5cd1f7223df..53c80ee3198 100644
--- a/Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua
+++ b/Master/texmf-dist/tex/latex/biblatex-ext/blxextdoiapi.lua
@@ -2,8 +2,8 @@ blxextdoiapi = blxextdoiapi or {}
local blxextdoiapi_module = {
name = "blxextdoiapi",
- version = "v0.8b",
- date = "2019/11/01",
+ version = "v0.8c",
+ date = "2019/11/30",
description = "Obtain open access information from DOI via unpaywall.org",
author = "Moritz Wemheuer",
license = "LPPL v1.3c",
@@ -119,8 +119,13 @@ local function query_json_api(req_url)
return nil, code
end
+-- DISABLED for now :-(
+-- doi.org only serves via HTTPS, but Lua(TeX) has no built-in
+-- support for SLL at the moment, so we can't query the API
+-- as we only get 301 response
+--[[
local function get_doi_info(doi)
- local req_url = "https://doi.org/api/handles/" .. url.escape(doi)
+ local req_url = "http://doi.org/api/handles/" .. url.escape(doi)
local doi_info, code = query_json_api(req_url)
if doi_info then
@@ -143,6 +148,7 @@ local function is_valid_doi(doi)
return get_doi_info(doi)
end
+]]--
-- email is required, error out if not given
-- Unfortunately, this gives a weird Lua dump as well and one has to scroll
@@ -150,16 +156,17 @@ end
-- a usual TeX error instead of the generic LuaTeX error provided by ltluatex.
-- Only makes sense if the DOI is valid.
local function get_unpaywall_info(doi)
- if not is_valid_doi(doi) then
- return nil
- elseif not blxextdoiapi.mail or blxextdoiapi.mail == "" then
+ -- if not is_valid_doi(doi) then
+ -- return nil
+ -- elseif not blxextdoiapi.mail or blxextdoiapi.mail == "" then
+ if not blxextdoiapi.mail or blxextdoiapi.mail == "" then
error("No mail address supplied.\n" ..
"You must give a valid email address\n" ..
"to be able to use the Unpaywall API\n")
return nil
end
- local req_url = "https://api.unpaywall.org/v2/" .. doi
+ local req_url = "http://api.unpaywall.org/v2/" .. doi
.. "?email=" .. blxextdoiapi.mail
local upw_info, code = query_json_api(req_url)
@@ -204,14 +211,17 @@ local function get_openaccess_url(doi)
return get_unpaywall_info(doi)
end
--- returns false if there is no open access URL since the RHS ~= nil
-local function openaccess_url_is_doi(doi)
- return get_openaccess_url(doi) == "https://doi.org/" .. doi
+-- Has \url hard-coded, people probably shouldn't be using this,
+-- but it's documented now
+local function get_openaccess_url_tex(doi)
+ local oa_url = get_openaccess_url(doi)
+ if oa_url then
+ texsprint("\\url{")
+ texwrite(oa_url)
+ texsprint("}")
+ end
end
-local function is_openaccess(doi)
- return get_openaccess_url(doi) ~= nil
-end
-- For TeX. I'd have liked this better in the .sty, but the whole \ escape
-- malarkey made that a pain, so the function is here now.
@@ -224,6 +234,16 @@ local function assign_openaccess_url_to(macro, doi)
end
end
+-- returns false if there is no open access URL since the RHS ~= nil
+local function openaccess_url_is_doi(doi)
+ return get_openaccess_url(doi) == "https://doi.org/" .. doi
+end
+
+local function is_openaccess(doi)
+ return get_openaccess_url(doi) ~= nil
+end
+
+
-- make conditionals usable as \<...>{<true>}{<false>} directly
local function texify_conditional(cond)
if cond then
@@ -237,9 +257,10 @@ end
return {
module = module,
cache_expire = cache_expire,
- is_valid_doi = is_valid_doi,
+ -- is_valid_doi = is_valid_doi,
is_openaccess = is_openaccess,
get_openaccess_url = get_openaccess_url,
+ get_openaccess_url_tex = get_openaccess_url_tex,
assign_openaccess_url_to = assign_openaccess_url_to,
openaccess_url_is_doi = openaccess_url_is_doi,
texify_conditional = texify_conditional,