Content deleted Content added
fix indent |
Whatback11 (talk | contribs) No edit summary |
||
(14 intermediate revisions by 4 users not shown) | |||
Line 2:
-- Set constants
local CONFIG_MODULE = 'Module:Shortcut/config
-- Load required modules
Line 24:
frame = frame or mw.getCurrentFrame()
cfg = cfg or mw.loadData(CONFIG_MODULE)
local templateMode = options.template and yesno(options.template)
local
local isCategorized = not options.category or yesno(options.category) ~= false▼
end▼
▲ local isCategorized = yesno(options.category) ~= false
-- Validate shortcuts
Line 38 ⟶ 34:
end
end
-- Make the list items. These are the shortcuts plus any extra lines such
Line 44 ⟶ 39:
local listItems = {}
for i, shortcut in ipairs(shortcuts) do
local templatePath, prefix
if templateMode then
-- Namespace detection
Line 53 ⟶ 48:
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("TM:{{%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("TM:{{%s%s}}", prefix, listItems[i])
end
end
Line 81 ⟶ 77:
local root = mw.html.create()
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'Module:Shortcut/styles.css'} })
-- Anchors
local anchorDiv = root
Line 96 ⟶ 92:
local nShortcuts = #shortcuts
if nShortcuts > 0 then
local headingMsg = options['shortcut-heading'] or
redirectMode and cfg['redirect-heading'] or
cfg['shortcut-heading']
shortcutHeading = message(headingMsg, nShortcuts)
shortcutHeading = frame:preprocess(shortcutHeading)
end
end
Line 120 ⟶ 103:
local shortcutList = root
:tag('div')
:addClass('module-shortcutboxplain
:attr('role', 'note')
if
shortcutList:addClass('module-shortcutboxleft')
if options.clear and options.clear ~= '' then
shortcutList:css('clear', options.clear)
end
if shortcutHeading then
Line 132 ⟶ 117:
:wikitext(shortcutHeading)
end
return tostring(root)
end
|