Module:Sister project
The above documentation is transcluded from Module:Sister project/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
-------------------------------------------------------------------------------
--
-- Module:Sister project
--
-- This module implements Template:Sister
-------------------------------------------------------------------------------
local c = {}
c.projects = {
poe2wiki = {
param = 'poe2wiki',
interwiki = 'poe2wiki',
name = 'Path of Exile 2 Wiki',
},
}
c.display_order = {'poe2wiki'}
-- ----------------------------------------------------------------------------
-- Main functions
-- ----------------------------------------------------------------------------
local function _sister(args)
local pagename = mw.title.getCurrentTitle().fullText
local params = {}
local selected = {}
for k, v in pairs(c.projects) do
params[v.param] = true
if args[v.param] and not selected[k] then
selected[k] = args[v.param]
end
end
for _, v in ipairs(args) do
if params[v] and not selected[v] then
selected[v] = pagename
end
end
local html = mw.html.create('div')
html
:addClass('noexcerpt noprint nomobile navigation-not-searchable js-sister-data')
:css('display', 'none')
for _, v in ipairs(c.display_order) do
if selected[v] then
local span = html:tag('span')
span:attr({
['data-project'] = c.projects[v].name,
['data-interwiki'] = c.projects[v].interwiki,
['data-page'] = selected[v],
})
end
end
return tostring(html)
end
-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------
local p = {}
function p.sister(frame)
local args
if type(frame.args) == 'table' then
-- Called via #invoke, so use the parent args (those that were passed
-- into the template. Ignore args passed to #invoke.
args = frame:getParent().args
else
-- Called from another module or from the debug console, so assume args
-- are passed in directly.
args = frame
end
return _sister(args)
end
return p