http://wiki.worldsamba.org/index.php?title=Module:Shortcut&feed=atom&action=history
Module:Shortcut - Revision history
2024-03-28T12:18:36Z
Revision history for this page on the wiki
MediaWiki 1.28.0
http://wiki.worldsamba.org/index.php?title=Module:Shortcut&diff=363&oldid=prev
Admin: 1 revision imported
2017-03-04T18:17:44Z
<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style='vertical-align: top;' lang='en'>
<td colspan='1' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='1' style="background-color: white; color:black; text-align: center;">Revision as of 18:17, 4 March 2017</td>
</tr><tr><td colspan='2' style='text-align: center;' lang='en'><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Admin
http://wiki.worldsamba.org/index.php?title=Module:Shortcut&diff=362&oldid=prev
Mr. Stradivarius: remove the first parameter error category per Template talk:Shortcut#The cleanup category should be removed
2016-08-31T23:23:44Z
<p>remove the first parameter error category per <a href="/index.php?title=Template_talk:Shortcut&action=edit&redlink=1" class="new" title="Template talk:Shortcut (page does not exist)">Template talk:Shortcut#The cleanup category should be removed</a></p>
<p><b>New page</b></p><div>-- This module implements {{shortcut}}.<br />
<br />
-- Set constants<br />
local CONFIG_MODULE = 'Module:Shortcut/config'<br />
<br />
-- Load required modules<br />
local checkType = require('libraryUtil').checkType<br />
local yesno = require('Module:Yesno')<br />
<br />
local p = {}<br />
<br />
local function message(msg, ...)<br />
return mw.message.newRawMessage(msg, ...):plain()<br />
end<br />
<br />
local function makeCategoryLink(cat)<br />
return string.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)<br />
end<br />
<br />
function p._main(shortcuts, options, frame, cfg)<br />
checkType('_main', 1, shortcuts, 'table')<br />
checkType('_main', 2, options, 'table', true)<br />
options = options or {}<br />
frame = frame or mw.getCurrentFrame()<br />
cfg = cfg or mw.loadData(CONFIG_MODULE)<br />
local isCategorized = yesno(options.category) ~= false<br />
<br />
-- Validate shortcuts<br />
for i, shortcut in ipairs(shortcuts) do<br />
if type(shortcut) ~= 'string' or #shortcut < 1 then<br />
error(message(cfg['invalid-shortcut-error'], i), 2)<br />
end<br />
end<br />
<br />
-- Make the list items. These are the shortcuts plus any extra lines such<br />
-- as options.msg.<br />
local listItems = {}<br />
for i, shortcut in ipairs(shortcuts) do<br />
listItems[i] = string.format('[[%s]]', shortcut)<br />
end<br />
table.insert(listItems, options.msg)<br />
<br />
-- Return an error if we have nothing to display<br />
if #listItems < 1 then<br />
local msg = cfg['no-content-error']<br />
msg = string.format('<strong class="error">%s</strong>', msg)<br />
if isCategorized and cfg['no-content-error-category'] then<br />
msg = msg .. makeCategoryLink(cfg['no-content-error-category'])<br />
end<br />
return msg<br />
end<br />
<br />
local root = mw.html.create()<br />
<br />
-- Anchors<br />
local anchorDiv = root<br />
:tag('div')<br />
:css('position', 'relative')<br />
:css('top', '-3em')<br />
for i, shortcut in ipairs(shortcuts) do<br />
local anchor = mw.uri.anchorEncode(shortcut)<br />
anchorDiv:tag('span'):attr('id', anchor)<br />
end<br />
<br />
root:newline() -- To match the old [[Template:Shortcut]]<br />
<br />
-- Shortcut heading<br />
local shortcutHeading<br />
do<br />
local nShortcuts = #shortcuts<br />
if nShortcuts > 0 then<br />
shortcutHeading = message(cfg['shortcut-heading'], nShortcuts)<br />
shortcutHeading = frame:preprocess(shortcutHeading)<br />
shortcutHeading = shortcutHeading .. '\n'<br />
end<br />
end<br />
<br />
-- Shortcut box<br />
local shortcutList = root<br />
:tag('div')<br />
:addClass('shortcutbox plainlist noprint')<br />
:attr('role', 'note')<br />
:css('float', 'right')<br />
:css('border', '1px solid #aaa')<br />
:css('background', '#fff')<br />
:css('margin', '.3em .3em .3em 1em')<br />
:css('padding', '.4em .6em')<br />
:css('text-align', 'center')<br />
:css('font-size', 'smaller')<br />
:css('line-height', '2em')<br />
:css('font-weight', 'bold')<br />
:wikitext(shortcutHeading)<br />
:tag('ul')<br />
for i, item in ipairs(listItems) do<br />
shortcutList:tag('li'):wikitext(item)<br />
end<br />
<br />
return tostring(root)<br />
end<br />
<br />
function p.main(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {<br />
wrappers = 'Template:Shortcut'<br />
})<br />
<br />
-- Separate shortcuts from options<br />
local shortcuts, options = {}, {}<br />
for k, v in pairs(args) do<br />
if type(k) == 'number' then<br />
shortcuts[k] = v<br />
else<br />
options[k] = v<br />
end<br />
end<br />
<br />
-- Compress the shortcut array, which may contain nils.<br />
local function compressArray(t)<br />
local nums, ret = {}, {}<br />
for k in pairs(t) do<br />
nums[#nums + 1] = k<br />
end<br />
table.sort(nums)<br />
for i, num in ipairs(nums) do<br />
ret[i] = t[num]<br />
end<br />
return ret<br />
end<br />
shortcuts = compressArray(shortcuts)<br />
<br />
return p._main(shortcuts, options, frame)<br />
end<br />
<br />
return p</div>
Mr. Stradivarius