Module:Shortcut: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(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)
local uriObj = fullUrl(s, {redirect = 'no'})
return format('[[%s]]', s)
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
:tag('div')
:css{position = 'relative', top = '-3em'}
:css{position = 'relative', top = '-3em'}
:wikitext(anchors)
:done()
:wikitext(anchors)
root
:tag('table')
:addClass('shortcutbox noprint')
:tag('table')
:addClass('shortcutbox noprint')
:css{
:css{
float = 'right',
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')
:addClass('plainlist')
:css{border = 'none', background = 'transparent'}
:css{border = 'none', background = 'transparent'}
:tag('small')
:wikitext(
:tag('small')
nShortcuts <= 1
:wikitext(
nShortcuts <= 1
and cfg.shortcutHeaderSingular
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)