Changes

Jump to navigation Jump to search
m
1 revision imported
}
-- Don't convert blank category to nilremove whitespaces from beginning and end of args
local function valueFunc(key, val)
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' and key ~= 'category' and key ~= 'embed' then
return nil
end
for k in pairs(namespaceCategories) do
if args[k .. ' category'] then
return string.format("'''[[:Category:%s|%s]]''':" .. , args[k .. ' category'] .. "|" .. , args.name .. "]]''': ")
end
end
return string.format("'''" .. args.name .. "%s''': ", args.name)
end
function p.coremain(frame, args) if not args then local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Redirect template/core', valueFunc = valueFunc}) end
local namespace = mw.title.getCurrentTitle().namespace
local otherCategory = args['other category'] and (args.category or string.format('[[Category:%s]]', args['other category']))
local embedPossible = args.embed == nil or args.embed == 'yes'
--- XXX: this is a HORRIBLE HACK. kill it with fire as soon as https://bugzilla.wikimedia.org/show_bug.cgi?id=12974 is fixed
local beCompatibleWithBug12974 = args.info and (args.info:find('^[:;#*]', 1) == 1 or args.info:find('{|', 1, true) == 1) and '\n' or ' '
local retval content = string.format('\n<div class="rcat %s">\n*%sThis is a redirect%s%s.%s%s</div>', args.class or '', embedPossible and args.name and getPrettyName(args) or '',
args.from and (' from ' .. args.from) or '',
args.to and (' to ' .. args.to) or '',
args.info or ''
)
for k,v in pairs(namespaceCategories) do
if args[k .. ' category'] then
if type(v[1]) == 'function' and v[1](namespace) or v[1] == namespace then
retval content = retval content .. (args.category or string.format('[[Category:%s]]', args[k .. ' category']))
elseif args['other category'] then
retval content = retval content .. otherCategorystring.format('[[Category:%s]]', args['other category'])
else
retval content = retval content .. frame:expandTemplate{title = 'Incorrect redirect template', args = {v[2]}}
end
end
end
return retval
end
function p.main(frame) if namespace == 0 then local args yesno = require('Module:ArgumentsYesno').getArgs(frame, {wrappers = 'Template:Redirect template', valueFunc = valueFunc}) local retval = p.core(frame, args) if mw.title.getCurrentTitleyesno().namespace == 0 then if args.printworthy ) == 'yes' true then return retval content .. (args.category or '[[Category:Printworthy redirects]]') elseif yesno(args.printworthy ) == 'no' false then return retval content .. (args.category or '[[Category:Unprintworthy redirects]]')
end
end
return retvalcontent
end
return p

Navigation menu