Module:Redirect template: Difference between revisions

Undid revision 876443655 by MSGJ (talk) undoing this change as it seems to break the formatting of the rcat text if multiple rcat templates are used and contains wiki text with at least one example of multiple consecutive asterisks/bullets (see Template:Redirect template/testcases#Test The Honeycombs (album)), making the second line appear too far out and following rcat templates with uncontrollable indenting - User:SD0001
(Undid revision 876520202 by Steel1943 (talk) turns out that I made this undo without properly substituting examples - temp revert of self)
(Undid revision 876443655 by MSGJ (talk) undoing this change as it seems to break the formatting of the rcat text if multiple rcat templates are used and contains wiki text with at least one example of multiple consecutive asterisks/bullets (see Template:Redirect template/testcases#Test The Honeycombs (album)), making the second line appear too far out and following rcat templates with uncontrollable indenting - User:SD0001)
Line 22:
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' and key ~= 'category' and key ~= 'embed' then
return nil
end
Line 32:
for k in pairs(namespaceCategories) do
if args[k .. ' category'] then
return string.format( "<b>'''[[:Category:%s|%s]]</b>: ", .. args[k .. ' category'], .. "|" .. args.name) .. "]]''': "
end
end
return string.format("<b>%s</b>'''", .. args.name) .. "''': "
end
 
function p.maincore(frame, args)
if namespacenot == 0args then
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Redirect template/core', valueFunc = valueFunc})
end
local namespace = mw.title.getCurrentTitle().namespace
content local otherCategory = contentargs['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 contentretval = string.format('<ul class="rcat %s"><li>*%sThis is a redirect%s%s.%s%s</li></ul>',
embedPossible and args.classname and getPrettyName(args) or '',
args.name and getPrettyName(args) or '',
args.from and (' from ' .. args.from) or '',
args.to and (' to ' .. args.to) or '',
Line 53 ⟶ 56:
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
contentretval = contentretval .. (args.category or string.format('[[Category:%s]]', args[k .. ' category']))
elseif args['other category'] then
retval = retval .. otherCategory
content = content .. string.format('[[Category:%s]]', args['other category'])
else
contentretval = contentretval .. frame:expandTemplate{title = 'Incorrect redirect template', args = {v[2]}}
end
end
end
return retval
end
 
function p.main(frame)
if namespace == 0 then
local yesnoargs = require('Module:YesnoArguments').getArgs(frame, {wrappers = 'Template:Redirect template', valueFunc = valueFunc})
local retval = p.core(frame, args)
if yesno(args.printworthy) == true then
if mw.title.getCurrentTitle().namespace == 0 then
return content .. '[[Category:Printworthy redirects]]'
elseifif yesno(args.printworthy) == false'yes' then
return contentretval .. (args.category or '[[Category:UnprintworthyPrintworthy redirects]]')
ifelseif yesno(args.printworthy) == true'no' then
return contentretval .. (args.category or '[[Category:PrintworthyUnprintworthy redirects]]')
end
end
return contentretval
end
 
Anonymous user