local export = {}
function export.show(frame)
local output = {}
local args = frame:getParent().args
local demo = false
local FULLPAGENAME = mw.title.getCurrentTitle().fullText
local BASEPAGENAME, SUBPAGENAME = FULLPAGENAME:match("^(.-)/([^/]-)$")
-- BASEPAGENAME = BASEPAGENAME or FULLPAGENAME
if 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, shcut in ipairs(args) do
local title = mw.title.new(shcut)
if not title then
output[#output + 1] = '(' .. mw.text.nowiki(shcut) .. '
)
'
attn = true
else
local iattn = false
local item = '[' .. tostring(mw.uri.fullUrl(shcut, 'redirect=no')) .. ' ' .. shcut .. ']'
if title.namespace == 10 then
item = '{{[' .. tostring(mw.uri.fullUrl(shcut, 'redirect=no')) .. ' ' .. title.text .. ']}}
'
end
if not title.exists then
attn = true
local query = 'action=edit&redlink=1&preloadtext=' .. mw.uri.encode('#REDIRECT ' .. FULLPAGENAME .. '')
if title.namespace == 10 then
item = '{{[' .. tostring(mw.uri.fullUrl(shcut, query)) .. ' ' .. title.text .. ']}}
'
else
item = '[' .. tostring(mw.uri.fullUrl(shcut, query)) .. ' ' .. shcut .. ']'
end
elseif not demo then
local content = title:getContent()
local target = content:match("^#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[%s*:?%s*(.-)[#%]]")
if not target then
iattn = true
else
target = target:gsub("_", " ")
local tns, tpg = target:match("%s*(.-)%s*:%s*(.*)%s*")
if mw.site.namespaces[tns] then
tns = mw.site.namespaces[tns].name
target = tns .. ':' .. tpg
end
if title.namespace == 10 then
if SUBPAGENAME == 'documentation' then
iattn = (target ~= BASEPAGENAME)
else
iattn = (target ~= FULLPAGENAME)
end
else
if SUBPAGENAME == 'documentation' then
iattn = (target ~= BASEPAGENAME) and (target ~= FULLPAGENAME)
else
iattn = (target ~= FULLPAGENAME) and (target ~= (FULLPAGENAME .. '/documentation'))
end
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