Skip to content

Commit

Permalink
Update Scribunto module(s) (#184)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub <[email protected]>
  • Loading branch information
github-actions[bot] and web-flow authored Jan 1, 2024
1 parent e6480b1 commit 78f829f
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 42 deletions.
17 changes: 4 additions & 13 deletions lua/en/Hatnote%20list
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,9 @@ local forSeeDefaultOptions = {
forSeeForm = 'For %s, see %s.',
}

--Collapses duplicate punctuation
--Collapses duplicate punctuation at end of string, ignoring italics and links
local function punctuationCollapse (text)
local replacements = {
["%.%.$"] = ".",
["%?%.$"] = "?",
["%!%.$"] = "!",
["%.%]%]%.$"] = ".]]",
["%?%]%]%.$"] = "?]]",
["%!%]%]%.$"] = "!]]"
}
for k, v in pairs(replacements) do text = string.gsub(text, k, v) end
return text
return text:match("[.?!]('?)%1(%]?)%2%.$") and text:sub(1, -2) or text
end

-- Structures arguments into a table for stringification, & options
Expand Down Expand Up @@ -153,7 +144,7 @@ function p.forSeeArgsToTable (args, from, options)
-- If the param after next is "and", do inner loop to collect params
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}
while args[i + 2] == options.andKeyword do
if args[i + 3] then
if args[i + 3] then
table.insert(forRow.pages, args[i + 3])
end
-- Increment to next "and"
Expand All @@ -164,7 +155,7 @@ function p.forSeeArgsToTable (args, from, options)
-- Append the row
table.insert(forTable, forRow)
until terminated or i > maxArg

return forTable
end

Expand Down
4 changes: 2 additions & 2 deletions lua/en/Navbar
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ local function make_list(title_text, has_brackets, displayed_links, is_mini, fon
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = title:fullUrl('action=edit'), ['url'] = true },
['link'] = 'Special:EditPage/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = title:fullUrl('action=history'), ['url'] = true },
['link'] = 'Special:PageHistory/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
Expand Down
2 changes: 1 addition & 1 deletion lua/en/String
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ OR

Parameters
s: The string to return a subset of
i: The fist index of the substring to return, defaults to 1.
i: The first index of the substring to return, defaults to 1.
j: The last index of the string to return, defaults to the last character.

The first character of the string is assigned an index of 1. If either i or j
Expand Down
15 changes: 8 additions & 7 deletions lua/en/Wd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ p.flags = {
p.args = {
eid = "eid",
page = "page",
date = "date"
date = "date",
globalSiteId = "globalSiteId"
}

local aliasesP = {
Expand Down Expand Up @@ -1820,7 +1821,7 @@ function State:getReference(statement)
local additionalRefProperties = {} -- will hold properties of the reference which are not in statement.snaks, namely backup title from "subject named as" and URL from an external ID
local wikidataPropertiesOfSource -- will contain "Wikidata property" properties of the item in stated in, if any

local version = 4 -- increment this each time the below logic is changed to avoid conflict errors
local version = 5 -- increment this each time the below logic is changed to avoid conflict errors

if statement.snaks then
-- don't include "imported from", which is added by a bot
Expand Down Expand Up @@ -2007,7 +2008,7 @@ function State:getReference(statement)

-- (3) if the citation couldn't be displayed using Cite web or Cite Q, but has properties other than the removed ones, throw an error
elseif not referenceEmpty then
value = "<span style=\"color: crimson\">" .. errorText("malformed-reference") .. "</span>"
value = "<span style=\"color:#dd3333\">" .. errorText("malformed-reference") .. "</span>"
end

if value ~= "" then
Expand Down Expand Up @@ -2204,7 +2205,7 @@ function State:iterate(statements, hooks, matchHook)
return self:out()
end

local function getEntityId(arg, eid, page, allowOmitPropPrefix)
local function getEntityId(arg, eid, page, allowOmitPropPrefix, globalSiteId)
local id = nil
local prop = nil

Expand Down Expand Up @@ -2235,7 +2236,7 @@ local function getEntityId(arg, eid, page, allowOmitPropPrefix)
page = mw.text.trim(page:sub(2))
end

id = mw.wikibase.getEntityIdForTitle(page) or ""
id = mw.wikibase.getEntityIdForTitle(page, globalSiteId) or ""
end

if not id then
Expand Down Expand Up @@ -2282,7 +2283,7 @@ local function claimCommand(args, funcName)
until not cfg:processFlagOrCommand(lastArg)

-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page])
cfg.entityID, cfg.propertyID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], false, args[p.args.globalSiteId])

if cfg.entityID == "" then
return "" -- we cannot continue without a valid entity ID
Expand Down Expand Up @@ -2454,7 +2455,7 @@ local function generalCommand(args, funcName)
until not cfg:processFlag(lastArg)

-- get the entity ID from either the positional argument, the eid argument or the page argument
cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true)
cfg.entityID = getEntityId(lastArg, args[p.args.eid], args[p.args.page], true, args[p.args.globalSiteId])

if cfg.entityID == "" or not mw.wikibase.entityExists(cfg.entityID) then
return "" -- we cannot continue without an entity
Expand Down
4 changes: 2 additions & 2 deletions lua/ko/Citation%2FCS1
Original file line number Diff line number Diff line change
Expand Up @@ -2300,8 +2300,8 @@ local Encyclopedia = A['Encyclopedia'];

if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL, -- a crude list of parameters that are not supported by cite arxiv
ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['NAID'], ID_list['OCLC'], ID_list['OL'],
ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['S2CID'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } ); -- add error message

AccessDate= ''; -- set these to empty string; not supported in cite arXiv
Expand Down
32 changes: 32 additions & 0 deletions lua/ko/Citation%2FCS1%2FConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ local error_conditions = {
category = '인용 오류 - MR',
hidden = false
},
bad_naid = {
message = '<code class="cs1-code">&#124;naid=</code> 값 확인 필요',
anchor = 'bad_naid',
category = '인용 오류 - NAID',
hidden = false
},
bad_ol = {
message = '<code style="'..code_style..'">&#124;ol=</code> 값 확인 필요',
anchor = 'bad_ol',
Expand All @@ -999,6 +1005,11 @@ local error_conditions = {
anchor = 'bad_oclc',
category = '인용 오류 - OCLC',
hidden = false },
bad_s2cid = {
message = 'Check <code class="cs1-code">&#124;s2cid=</code> 값 확인 필요',
anchor = 'bad_s2cid',
category = '인용 오류 - S2CID',
hidden = false },
bad_ssrn = {
message = '<code class="cs1-code">&#124;ssrn=</code> 값 확인 필요',
anchor = 'bad_ssrn',
Expand Down Expand Up @@ -1355,6 +1366,16 @@ local id_handlers = {
encode = true,
separator = '&nbsp;',
},
['NAID'] = {
parameters = {'NAID', 'naid'},
link = 'CiNii',
label = 'NAID',
mode = 'external',
prefix = 'https://ci.nii.ac.jp/naid/',
COinS = 'info:naid',
encode = false,
separator = '&nbsp;',
},
['OCLC'] = {
parameters = {'OCLC', 'oclc'},
link = '온라인 컴퓨터 도서관 센터',
Expand Down Expand Up @@ -1416,6 +1437,17 @@ local id_handlers = {
encode = false,
separator = '&nbsp;',
},
['S2CID'] = {
parameters = {'s2cid', 'S2CID'},
link = '시맨틱 스칼라',
redirect = '시맨틱 스칼라',
label = 'S2CID',
mode = 'external',
prefix = 'https://api.semanticscholar.org/CorpusID:',
COinS = 'pre', -- use prefix value
encode = false,
separator = '&nbsp;',
},
['SSRN'] = {
parameters = {'SSRN', 'ssrn'},
link = '사회 과학 연구 네트워크',
Expand Down
61 changes: 61 additions & 0 deletions lua/ko/Citation%2FCS1%2FIdentifiers
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,27 @@ local function mr (id)
end


--[[--------------------------< N A I D >----------------------------------------------------------------------

NAID must be eleven or twelve digits starts with non-zero.

]]

local function naid(id)
local handler = cfg.id_handler;
local matched;
matched = id:match ('^[1-9]%d%d%d%d%d%d%d%d%d%d%d?$');
if not matched then
text = text .. ' ' .. set_message ('bad_naid'); -- set an error message
id.coins_list_t['NAID'] = nil; -- when error, unset so not included in COinS
end

local text = external_link_id({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect, prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});

return text;
end


--[[--------------------------< O C L C >----------------------------------------------------------------------

Validate and format an oclc id. https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
Expand Down Expand Up @@ -920,6 +941,42 @@ local function pmid(id)
end


--[[--------------------------< S 2 C I D >--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up. This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id)
local access = id.access;
local handler = id.handler;
local id_num;
local text;

id_num = id:match ('^[1-9]%d*$'); -- id must be all digits; must not begin with 0; no open access flag

if is_set (id_num) then -- id_num has a value so test it
id_num = tonumber (id_num); -- convert id_num to a number for range testing
if handler.id_limit < id_num then -- if S2CID is outside test limit boundaries
set_message ('bad_s2cid'); -- set an error message
options.coins_list_t['S2CID'] = nil; -- when error, unset so not included in COinS
end
else -- when id format incorrect
set_message ('bad_s2cid'); -- set an error message
options.coins_list_t['S2CID'] = nil; -- when error, unset so not included in COinS
end

text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

return text;
end


--[[--------------------------< S S R N >----------------------------------------------------------------------

Format an ssrn, do simple error checking
Expand Down Expand Up @@ -1070,6 +1127,8 @@ local function build_id_list( id_list, options )
table.insert( new_list, {handler.label, lccn( v ) } );
elseif k == 'MR' then
table.insert( new_list, {handler.label, mr( v ) } );
elseif k == 'NAID' then
table.insert( new_list, {handler.label, naid( v ) } );
elseif k == 'OCLC' then
table.insert( new_list, {handler.label, oclc( v ) } );
elseif k == 'OL' or k == 'OLA' then
Expand All @@ -1078,6 +1137,8 @@ local function build_id_list( id_list, options )
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'PMID' then
table.insert( new_list, {handler.label, pmid( v ) } );
elseif k == 'S2CID' then
table.insert( new_list, {handler.label, s2cid( v ) } );
elseif k == 'SSRN' then
table.insert( new_list, {handler.label, ssrn( v ) } );
elseif k == 'USENETID' then
Expand Down
5 changes: 5 additions & 0 deletions lua/ko/Citation%2FCS1%2FWhitelist
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ local basic_arguments = {
['mode'] = true,
['mr'] = true,
['MR'] = true,
['naid'] = true,
['NAID'] = true,
['name-list-format'] = true,
['network'] = true,
['newsgroup'] = true,
Expand Down Expand Up @@ -346,6 +348,9 @@ local basic_arguments = {
['subject-link'] = true,
['subscription'] = false,
['surname'] = true,
['s2cid'] = true,
['S2CID'] = true,
['s2cid-access'] = true,
['template doc demo'] = true, -- DEPRECATED
['template-doc-demo'] = true,
['time'] = true,
Expand Down
Loading

0 comments on commit 78f829f

Please sign in to comment.