Tweak CS1 config load (once per page)
This commit is contained in:
parent
881047f7e9
commit
2c0b7f935f
1 changed files with 4 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ local followQid = wdib._followQid
|
||||||
local cite_cfg = mw.loadData ('Module:Cite/config')
|
local cite_cfg = mw.loadData ('Module:Cite/config')
|
||||||
local cfg = mw.loadData ('Module:Cite_Q/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_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
|
-- 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
|
-- check DOI registrant is known free, using CS1 config
|
||||||
-- TODO: this should also be modelled in Wikidata
|
-- TODO: this should also be modelled in Wikidata
|
||||||
if identifier == 'doi' then
|
if identifier == 'doi' then
|
||||||
local cs1 = require(cs1_cfg)
|
|
||||||
local registrant, suffix = mw.ustring.match(args.doi:lower(), '^10%.([^/]+)/([^%s–]+)$');
|
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'
|
return 'free'
|
||||||
elseif registrant and suffix and cs1.extended_registrants_t[registrant] then
|
elseif registrant and suffix and cs1_cfg.extended_registrants_t[registrant] then
|
||||||
for _, incipit in ipairs(cs1.extended_registrants_t[registrant]) do
|
for _, incipit in ipairs(cs1_cfg.extended_registrants_t[registrant]) do
|
||||||
if mw.ustring.find (suffix, '^' .. incipit:lower()) then
|
if mw.ustring.find (suffix, '^' .. incipit:lower()) then
|
||||||
return 'free'
|
return 'free'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue