11.314
suntingan
dw>Izno (use module:list for plainlist, move templatestyles to module space) |
(←Membuat halaman berisi '-- This module implements {{shortcut}}. -- Set constants local CONFIG_MODULE = 'Module:Shortcut/config' -- Load required modules local checkType = require('libraryUtil').checkType local yesno = require('Module:Yesno') local p = {} local function message(msg, ...) return mw.message.newRawMessage(msg, ...):plain() end local function makeCategoryLink(cat) return string.format('%s:%s', mw.site.namespaces[14].name, cat) end function p._main(shortcuts, opti...') |
||
| Baris 24: | Baris 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 isCategorized = yesno(options.category) ~= false | |||
local isCategorized = | |||
-- Validate shortcuts | -- Validate shortcuts | ||
| Baris 39: | Baris 37: | ||
local listItems = {} | local listItems = {} | ||
for i, shortcut in ipairs(shortcuts) do | for i, shortcut in ipairs(shortcuts) do | ||
listItems[i] = frame:expandTemplate{ | |||
title = 'No redirect', | |||
args = {shortcut} | |||
} | |||
end | end | ||
table.insert(listItems, options.msg) | table.insert(listItems, options.msg) | ||
| Baris 77: | Baris 55: | ||
local root = mw.html.create() | local root = mw.html.create() | ||
root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = ' | root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = 'Shortcut/styles.css'} }) | ||
-- Anchors | -- Anchors | ||
local anchorDiv = root | local anchorDiv = root | ||
| Baris 92: | Baris 70: | ||
local nShortcuts = #shortcuts | local nShortcuts = #shortcuts | ||
if nShortcuts > 0 then | if nShortcuts > 0 then | ||
shortcutHeading = message(cfg['shortcut-heading'], nShortcuts) | |||
shortcutHeading = frame:preprocess(shortcutHeading) | shortcutHeading = frame:preprocess(shortcutHeading) | ||
end | end | ||
| Baris 103: | Baris 78: | ||
local shortcutList = root | local shortcutList = root | ||
:tag('div') | :tag('div') | ||
:addClass('module-shortcutboxplain noprint') | :addClass('module-shortcutboxplain plainlist noprint') | ||
:attr('role', 'note') | :attr('role', 'note') | ||
if shortcutHeading then | if shortcutHeading then | ||
shortcutList | shortcutList | ||
| Baris 117: | Baris 86: | ||
:wikitext(shortcutHeading) | :wikitext(shortcutHeading) | ||
end | end | ||
local list = shortcutList:tag('ul') | |||
local | for i, item in ipairs(listItems) do | ||
list:tag('li'):wikitext(item) | |||
end | |||
return tostring(root) | return tostring(root) | ||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
local args = require('Module:Arguments').getArgs(frame) | local args = require('Module:Arguments').getArgs(frame, { | ||
wrappers = 'Template:Shortcut' | |||
}) | |||
-- Separate shortcuts from options | -- Separate shortcuts from options | ||