Content deleted Content added
localise snippet project values and add a default projectLong value |
use maybeLoadModule to simplify some code and to make some of the dependent modules optional |
||
Line 13:
local mShared = require('Module:UserLinks/shared')
local raiseError = mShared.raiseError
local maybeLoadModule = mShared.maybeLoadModule
local makeWikitextError = mShared.makeWikitextError
local makeWikilink = mShared.makeWikilink
Line 322 ⟶ 323:
-- Define functions for shared code in the metatable.
local function validateCode(code)
-- Checks whether code is a valid link code - i.e. checks that it is a
-- string and that it is not the blank string. Returns the code if
-- the check passes, and nil if not.
if type(code) == 'string' and code ~= '' then
return code
else
return nil
end▼
end▼
if mExtra == nil then▼
success, module = pcall(require, 'Module:UserLinks/extra')▼
else▼
end▼
end
end
local function getExtraLinkFunctions()
-- Loads the table of extra link functions from the /extra module.
-- If there is a problem with loading it, return false. We use the
-- distinction between false and nil to record whether we have already
-- tried to load it.
if extraLinkFunctions ~= nil then
return extraLinkFunctions
end
▲ if mExtra == nil then
-- If loading the module fails, maybeLoadModule returns false.
-- Here we use the distinction between false and nil to record
-- whether we have already tried to load the /extra module.
▲ end
if type(mExtra) == 'table'
and type(mExtra.linkFunctions) == 'table'
Line 676 ⟶ 677:
-- Gets the link codes from the arguments. The codes aren't validated
-- at this point.
mTableTools =
local codes
if mTableTools then codes = mTableTools.compressSparseArray(args) codes = {}
for i, code in ipairs(args) do
codes[i] = code
▲ end
return codes
end
|