Module:Favilink: Difference between revisions

Jump to navigation Jump to search
534 bytes added ,  00:22, 25 July 2023
m
no edit summary
mNo edit summary
mNo edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 68: Line 68:
local modifier = modifier or ""
local modifier = modifier or ""
if modifier == 'plural' then
    if modifier == '' then
display = displayname
elseif modifier == 'plural' then
local displayresult = htmlparse.pluralize( {args= {html = displayname} })
local displayresult = htmlparse.pluralize( {args= {html = displayname} })
display=displayresult
display=displayresult
Line 74: Line 76:
local displayresult = htmlparse.make_possessive({ args = {html = displayname} })
local displayresult = htmlparse.make_possessive({ args = {html = displayname} })
display=displayresult
display=displayresult
elseif modifier == '' then
display = displayname
elseif modifier == 'displayname-tooltip-override' then
elseif modifier == 'displayname-tooltip-override' then
display = displayname
display = displayname
displayname_tooltip_override = true
displayname_tooltip_override = true
    elseif string.sub(modifier,1,7) == 'prefix:' then
        modifier = string.sub(modifier,8)
        display = colorparse.parse('&y'..modifier..' ')..displayname
    elseif string.sub(modifier,1,7) == 'suffix:' then
        modifier = string.sub(modifier,8)
        display = displayname..colorparse.parse(' &y'..modifier)
else
else
display = colorparse.parse('&y'..modifier)
display = colorparse.parse('&y'..modifier)
Line 84: Line 90:


local img = displayimg
local img = displayimg
if string.len(displayimg) > 4 then
if displayimg ~= nil then
if string.sub(displayimg, -4) == '.png' then
if string.len(displayimg) > 4 then
    img = '[[File:' .. displayimg.. '|16px|link='..pagelink..']]'
if string.sub(displayimg, -4) == '.png' then
    img = '[[File:' .. displayimg.. '|16px|link='..pagelink..'|alt=]]'
end
end
end
end
end
Line 114: Line 122:


function p.favilinkformat(frame)
function p.favilinkformat(frame)
frame=mw.getCurrentFrame()
return p.format(frame.args['pagelink'],
return p.format(frame.args['pagelink'],
frame.args['displayname'],
frame.args['displayname'],
Line 123: Line 130:


function p.favilinkformatinline(frame)
function p.favilinkformatinline(frame)
local util_text = require('Module:Text Utility')
frame=mw.getCurrentFrame()
frame=mw.getCurrentFrame()
args = frame.args[1]
local argsstr = table.concat(frame.args, '')
return args
local args = util_text.split(argsstr, '%s*;;;%s*')
return p.format(args[1],
args[2],
args[3],
'',
args[4])
end
end
return p
return p

Navigation menu