Tweak CS1 config load (once per page)

This commit is contained in:
Jonathan Harker 2026-09-21 09:40:19 +12:00
parent 881047f7e9
commit 2c0b7f935f

View file

@ -8,7 +8,7 @@ local followQid = wdib._followQid
local cite_cfg = mw.loadData ('Module:Cite/config')
local cfg = mw.loadData ('Module:Cite_Q/config')
local cs1_module = 'Module:Citation/CS1' -- don't load the module yet, may not be needed
local cs1_cfg = 'Module:Citation/CS1/Configuration'
local cs1_cfg = mw.loadData('Module:Citation/CS1/Configuration')
--------------------------------------------------------------------------------
-- makeOrdinal needs to be internationalised along with cfg.i18n_t
@ -349,12 +349,11 @@ local function getIdentifierAccess(qid, args, identifier)
-- check DOI registrant is known free, using CS1 config
-- TODO: this should also be modelled in Wikidata
if identifier == 'doi' then
local cs1 = require(cs1_cfg)
local registrant, suffix = mw.ustring.match(args.doi:lower(), '^10%.([^/]+)/([^%s]+)$');
if registrant and suffix and cs1.known_free_doi_registrants_t[registrant] then
if registrant and suffix and cs1_cfg.known_free_doi_registrants_t[registrant] then
return 'free'
elseif registrant and suffix and cs1.extended_registrants_t[registrant] then
for _, incipit in ipairs(cs1.extended_registrants_t[registrant]) do
elseif registrant and suffix and cs1_cfg.extended_registrants_t[registrant] then
for _, incipit in ipairs(cs1_cfg.extended_registrants_t[registrant]) do
if mw.ustring.find (suffix, '^' .. incipit:lower()) then
return 'free'
end