Module:Shortcut box

local export = {}

function export.show(frame) local output = {} -- Hacky way to allow function to be called from other modules. local args = (frame.getParent and frame:getParent.args) or frame local demo = false

local FULLPAGENAME = mw.title.getCurrentTitle.fullText local BASEPAGENAME, SUBPAGENAME = FULLPAGENAME:match("^(.-)/([^/]-)$") -- BASEPAGENAME = BASEPAGENAME or FULLPAGENAME if frame.getParent and FULLPAGENAME == frame:getParent:getTitle then demo = true end output[#output + 1] = ' '

if args.temp then output[#output + 1] = "Temporary shortcut" .. (args[2] and 's' or '') .. ": " else output[#output + 1] = "Shortcut" .. (args[2] and 's' or '') .. ": " end local attn = false

for i, shortcut in ipairs(args) do		local title = mw.title.new(shortcut) if not title then output[#output + 1] = '  ' attn = true else local iattn = false

local item

if not title.exists then attn = true local query = 'action=edit&redlink=1&preloadtext=' .. mw.uri.encode('#REDIRECT ' .. FULLPAGENAME .. '') if title.nsText == "Template" then item = ' ' else item = '[' .. tostring(mw.uri.fullUrl(shortcut, query)) .. ' ' .. shortcut .. ' ]'				end else if title.nsText == "Template" then item = ' ' else item = '[' .. tostring(mw.uri.fullUrl(shortcut, 'redirect=no')) .. ' ' .. shortcut .. ']'				end if not demo then local redirectTarget = title.redirectTarget if redirectTarget then redirectTarget.fragment = '' -- remove fragment, if present local targetText = redirectTarget.fullText if title.nsText == "Template" then if SUBPAGENAME == 'documentation' then iattn = (targetText ~= BASEPAGENAME) else iattn = (targetText ~= FULLPAGENAME) end else if SUBPAGENAME == 'documentation' then iattn = not (targetText == BASEPAGENAME									or targetText == FULLPAGENAME) else iattn = not (targetText == FULLPAGENAME									or targetText == FULLPAGENAME .. '/documentation') end end end if not (redirectTarget and redirectTarget.exists) then iattn = true end end end

if iattn then item = ' ' .. item .. ' '			end

output[#output + 1] = item .. ' '			attn = attn or iattn end end

if not args.nocat then if attn then output[#output + 1] = '' end if SUBPAGENAME ~= 'documentation' then output[#output + 1] = '' end end

output[#output + 1] = ' ' return table.concat(output) end

return export