Module:Forumlink
Documentation [edit]
This page is a stub - it only covers the very basics of its subject. More information should be added to make the page informative and useful. If no more information is available, the page should be considered for a merge, redirect, or deletion.
Details: documentation to be written
If you can correct the issue, please edit the page to do so, then remove this notice.
Please see Template:Forumlink for usage information. Use the template rather than invoking the module.Details: documentation to be written
If you can correct the issue, please edit the page to do so, then remove this notice.
The above documentation is transcluded from Module:Forumlink/doc.
local p = {}
local largs
local presets = {
npo = { domain = 'npowned.net', type = 'ips' }
}
local types = {
ips = {
sep = '-',
announcement = 'announcement/%s/',
forum = 'forums/forum/%s/',
news = 'news/community/%s/',
profile = 'profile/%s/',
topic = 'forums/topic/%s/',
default = 'forums/'
}
}
local function argDefault(arg, default)
if mw.text.trim(largs[arg] or '') == '' then
return default
else
return largs[arg]
end
end
local function finalize(url, arg, ftype)
paths = types[ftype]
if arg == 'default' then
return url .. paths[arg]
end
local text = mw.ustring.lower(largs[arg])
if paths.sep ~= ' ' then
text = mw.ustring.gsub(text, '%s', paths.sep)
end
return url .. mw.ustring.format(paths[arg], text)
end
function p.main(frame)
return p.call(frame:getParent().args)
end
function p.call(args)
largs = args
local ftype, url, domain
if argDefault('http') then
url = 'http://'
else
url = 'https://'
end
local preset = presets[mw.ustring.lower(argDefault(1, ''))]
if not preset then
domain = argDefault('site', '{{{site}}}')
ftype = argDefault('type')
else
domain = preset.domain
ftype = preset.type
end
if not ftype then
return '<span class="error">missing type</span>'
end
url = url .. domain .. '/'
if argDefault('topic') then
return finalize(url, 'topic', ftype)
elseif argDefault('profile') then
return finalize(url, 'profile', ftype)
elseif argDefault('forum') then
return finalize(url, 'forum', ftype)
elseif argDefault('news') then
return finalize(url, 'news', ftype)
elseif argDefault('announcement') then
return finalize(url, 'announcement', ftype)
else
return finalize(url, 'default', ftype)
end
end
return p