Module:Link: Difference between revisions
MusikAnimal (talk | contribs) No edit summary |
MusikAnimal (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local str = {} | local str = {} | ||
local function link( content, linkType, linkSubtype ) | local function link( content, title, linkType, linkSubtype ) | ||
for _i, subject in ipairs({ 'Billy Corgan', 'James Iha', "D'arcy Wretzky", 'Jimmy Chamberlin', 'Butch Vig', 'Flood', 'Alan Moulder', 'Kerry Brown' }) do | for _i, subject in ipairs({ 'Billy Corgan', 'James Iha', "D'arcy Wretzky", 'Jimmy Chamberlin', 'Butch Vig', 'Flood', 'Alan Moulder', 'Kerry Brown' }) do | ||
local cat_str = 'Category:' .. linkType .. 's ' .. linkSubtype .. ' by ' .. subject .. '|' | local cat_str = 'Category:' .. linkType .. 's ' .. linkSubtype .. ' by ' .. subject .. '|' | ||
content = mw.ustring.gsub( content, subject, '[[:' .. cat_str .. subject .. ']][[' .. cat_str .. '| | content = mw.ustring.gsub( content, subject, '[[:' .. cat_str .. subject .. ']][[' .. cat_str .. '|' .. title .. ']]' ) | ||
end | end | ||
Line 12: | Line 12: | ||
function str.producer( frame ) | function str.producer( frame ) | ||
local content = frame.args[1] | local content = frame.args[1] | ||
local linkType = frame.args[ | local title = frame.args[2] | ||
local linkType = frame.args[3] | |||
if content == '' then | if content == '' then | ||
return content | return content | ||
end | end | ||
return link(content, linkType, 'produced') | return link(content, title, linkType, 'produced') | ||
end | end | ||
function str.writer( frame ) | function str.writer( frame ) | ||
local content = frame.args[1] | local content = frame.args[1] | ||
local linkType = frame.args[ | local title = frame.args[2] | ||
local linkType = frame.args[3] | |||
if content == '' then | if content == '' then | ||
return content | return content | ||
end | end | ||
return link(content, linkType, 'written') | return link(content, title, linkType, 'written') | ||
end | end | ||
return str | return str |
Revision as of 02:10, 18 April 2020
Documentation for this module may be created at Module:Link/doc
local str = {}
local function link( content, title, linkType, linkSubtype )
for _i, subject in ipairs({ 'Billy Corgan', 'James Iha', "D'arcy Wretzky", 'Jimmy Chamberlin', 'Butch Vig', 'Flood', 'Alan Moulder', 'Kerry Brown' }) do
local cat_str = 'Category:' .. linkType .. 's ' .. linkSubtype .. ' by ' .. subject .. '|'
content = mw.ustring.gsub( content, subject, '[[:' .. cat_str .. subject .. ']][[' .. cat_str .. '|' .. title .. ']]' )
end
return content
end
function str.producer( frame )
local content = frame.args[1]
local title = frame.args[2]
local linkType = frame.args[3]
if content == '' then
return content
end
return link(content, title, linkType, 'produced')
end
function str.writer( frame )
local content = frame.args[1]
local title = frame.args[2]
local linkType = frame.args[3]
if content == '' then
return content
end
return link(content, title, linkType, 'written')
end
return str