Module:Shortcut: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(Implement merger code by Pppery) |
(from sandbox) |
||
Line 24: | Line 24: | ||
frame = frame or mw.getCurrentFrame() |
frame = frame or mw.getCurrentFrame() |
||
cfg = cfg or mw.loadData(CONFIG_MODULE) |
cfg = cfg or mw.loadData(CONFIG_MODULE) |
||
local templateMode = yesno(options.template) |
|||
local floatLeft = options.float and options.float:lower() == 'left' |
|||
local isCategorized = yesno(options.category) ~= false |
local isCategorized = yesno(options.category) ~= false |
||
Line 37: | Line 39: | ||
local listItems = {} |
local listItems = {} |
||
for i, shortcut in ipairs(shortcuts) do |
for i, shortcut in ipairs(shortcuts) do |
||
local templatePath |
|||
⚫ | |||
if templateMode then |
|||
⚫ | |||
-- Namespace detection |
|||
local titleObj = mw.title.new(shortcut, 10) |
|||
if titleObj.namespace == 10 then |
|||
templatePath = titleObj.fullText |
|||
else |
|||
templatePath = shortcut |
|||
end |
|||
end |
|||
⚫ | |||
listItems[i] = templateMode |
|||
and string.format("{{[[%s|%s]]}}", templatePath, shortcut) |
|||
⚫ | |||
else |
else |
||
listItems[i] = frame:expandTemplate{ |
listItems[i] = frame:expandTemplate{ |
||
title = 'No redirect', |
title = 'No redirect', |
||
args = {shortcut} |
args = templateMode and {templatePath, shortcut} or {shortcut} |
||
} |
} |
||
if templateMode then |
|||
listItems[i] = string.format("{{%s}}", listItems[i]) |
|||
end |
|||
end |
end |
||
end |
end |
||
Line 85: | Line 102: | ||
:addClass('module-shortcutboxplain plainlist noprint') |
:addClass('module-shortcutboxplain plainlist noprint') |
||
:attr('role', 'note') |
:attr('role', 'note') |
||
if floatLeft then |
|||
shortcutList:addClass('module-shortcutboxleft') |
|||
end |
|||
if shortcutHeading then |
if shortcutHeading then |
||
shortcutList |
shortcutList |