Open main menu

Changes

Module:Shortcut

1,150 bytes added, 18:23, 6 December 2021
m
1 revision imported
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = options.template and yesno(options.template) local redirectMode = options.redirect and yesno(options.redirect) local isCategorized = not options.category or yesno(options.category) ~= false
-- Validate shortcuts
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
local templatePath, prefix if templateMode then -- Namespace detection local titleObj = mw.title.new(shortcut, 10) if titleObj.namespace == 10 then templatePath = titleObj.fullText else templatePath = shortcut end prefix = options['pre' .. i] or options.pre or '' end if options.target and yesno(options.target) then listItems[i] = templateMode and string.format("{{%s[[%s|%s]]}}", prefix, templatePath, shortcut) or string.format("[[%s]]", shortcut) else listItems[i] = frame:expandTemplate{ title = 'No redirect', args = templateMode and {templatePath, shortcut} or {shortcut, shortcut} } if templateMode then listItems[i] = string.format("{{%s%s}}", prefix, listItems[i]) end }end
end
table.insert(listItems, options.msg)
local nShortcuts = #shortcuts
if nShortcuts > 0 then
shortcutHeading local headingMsg = message(options['shortcut-heading'] or redirectMode and cfg['redirect-heading'] or cfg['shortcut-heading'] shortcutHeading = message(headingMsg, nShortcuts)
shortcutHeading = frame:preprocess(shortcutHeading)
end
:addClass('module-shortcutboxplain plainlist noprint')
:attr('role', 'note')
if options.float and options.float:lower() == 'left' then
shortcutList:addClass('module-shortcutboxleft')
end
if options.clear and options.clear ~= '' then
shortcutList:css('clear', options.clear)
end
if shortcutHeading then
shortcutList
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, { wrappers = 'Template:Shortcut' })
-- Separate shortcuts from options