Module:Shortcut: Difference between revisions

167 bytes added ,  10 years ago
use redirect=no
(create replacement for Template:Shortcut)
 
(use redirect=no)
Line 29: Line 29:
local anchorEncode = mw.uri.anchorEncode
local anchorEncode = mw.uri.anchorEncode
local format = string.format
local format = string.format
local fullUrl = mw.uri.fullUrl


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 81: Line 82:
listArgs[#listArgs + 1] = link
listArgs[#listArgs + 1] = link
end
end
listArgs.class = 'plainlinks'
return mList.makeList('bulleted', listArgs)
return mList.makeList('bulleted', listArgs)
end
end


function p.makeShortcutLink(s)
function p.makeShortcutLink(s)
return format('[[%s]]', s)
local uriObj = fullUrl(s, {redirect = 'no'})
local url = tostring(uriObj)
return format('[%s %s]', url, s)
end
end


Line 101: Line 105:
function p.export(anchors, nShortcuts, shortcutList, errorCategories)
function p.export(anchors, nShortcuts, shortcutList, errorCategories)
local root = mw.html.create('')
local root = mw.html.create('')
root:tag('div')
root
:css{position = 'relative', top = '-3em'}
:tag('div')
:wikitext(anchors)
:css{position = 'relative', top = '-3em'}
:done()
:wikitext(anchors)
:tag('table')
root
:addClass('shortcutbox noprint')
:tag('table')
:css{
:addClass('shortcutbox noprint')
float = 'right',
:css{
border = '1px solid #aaa',
float = 'right',
background = '#fff',
border = '1px solid #aaa',
margin = '.3em .3em .3em 1em',
background = '#fff',
padding = '3px',
margin = '.3em .3em .3em 1em',
['text-align'] = 'center'
padding = '3px',
}
['text-align'] = 'center'
:tag('tr')
}
:tag('th')
:tag('tr')
:addClass('plainlist')
:tag('th')
:css{border = 'none', background = 'transparent'}
:addClass('plainlist')
:tag('small')
:css{border = 'none', background = 'transparent'}
:wikitext(
:tag('small')
nShortcuts <= 1  
:wikitext(
and cfg.shortcutHeaderSingular
nShortcuts <= 1  
or cfg.shortcutHeaderPlural
and cfg.shortcutHeaderSingular
)
or cfg.shortcutHeaderPlural
:newline()
)
:wikitext(shortcutList)
:newline()
:wikitext(shortcutList)
root:wikitext(errorCategories)
root:wikitext(errorCategories)
return tostring(root)
return tostring(root)