Module:Ref: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 39: Line 39:
Constructs a standard format reference using the given parameters, with the
Constructs a standard format reference using the given parameters, with the
provided content. Content table supports unlimited numeric arguments, in
provided content. Content table supports unlimited numeric arguments, in
addition to Section, Detail, Quote, Quotee and Suffix arguments.
addition to Subheading, Detail, Quote, Quotee and Suffix arguments.


@param frame - object - The current parser frame
@param frame - object - The current parser frame
Line 56: Line 56:
Generates the text content of a standard format reference from the provided
Generates the text content of a standard format reference from the provided
arguments. Content table supports unlimited numeric arguments, in
arguments. Content table supports unlimited numeric arguments, in
addition to section, detail, quote, quotee and suffix arguments.
addition to subheading, detail, quote, quotee and suffix arguments.


@param content - table - The content of the reference
@param content - table - The content of the reference
Line 64: Line 64:
function makeRefText( content )
function makeRefText( content )
local text = "''" .. tostring( content[ 1 ] or '' ) .. "''"
local text = "''" .. tostring( content[ 1 ] or '' ) .. "''"
if not utils.empty( content.section ) then
if not utils.empty( content.subheading ) then
text = text .. ': ' .. tostring( content.subheading )
text = text .. ': ' .. tostring( content.subheading )
end
end
Line 79: Line 79:
end
end
if not utils.empty( content.quote ) then
if not utils.empty( content.quote ) then
text = text .. ' ' .. tostring( content.quote )
text = text .. " ''\"" .. tostring( content.quote ) .. "\"''"
if not utils.empty( content.quotee ) then
if not utils.empty( content.quotee ) then
text = text .. ' - '
text = text .. ' - '
text = uniqueLinkIfExists( content.quotee, content.quoteetext, 'ref' )
text = text .. uniqueLinkIfExists( content.quotee, content.quoteetext, 'ref' )
end
end
end
end
Line 217: Line 217:
[ 'valid' ] = { 'id', 'subheading', 3, 4, 5, 6, 7, 'detail', 'quote',
[ 'valid' ] = { 'id', 'subheading', 3, 4, 5, 6, 7, 'detail', 'quote',
'quotee', 'quoteelinktext', 'suffix' },
'quotee', 'quoteelinktext', 'suffix' },
[ 'aliases' ] = { [ 1 ] = 'heading', [ 'section' ] = 'subheading' },
[ 'aliases' ] = { [ 1 ] = 'heading' }
[ 'invalid' ] = { 'section' }
} )
} )
local content = {
local content = {
Line 242: Line 241:
[ 'required' ] = { 'game' },
[ 'required' ] = { 'game' },
[ 'recommended' ] = { 'what' },
[ 'recommended' ] = { 'what' },
[ 'valid' ] = { 'whattext', 'id', 'part', 'detail', 'quote',
[ 'valid' ] = { 'whattext', 'id', 'part', 'parttext', 'detail', 'quote',
'quotee', 'quoteetext', 'suffix' },
'quotee', 'quoteetext', 'suffix' },
[ 'aliases' ] = { [ 1 ] = 'game', [ 2 ] = 'what',
[ 'deprecated' ] = { 'gamelinktext', 'whatlinktext', 'partlinktext',
[ 'whatlink' ] = 'what', [ 3 ] = 'whattext',
'quoteelinktext' },
[ 'whatlinktext' ] = 'whattext', [ 'expansion' ] = 'part',
[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
[ 'dlc' ] = 'part', [ 'edition' ] = 'part' }
[ 2 ] = 'what', [ 'whatlink' ] = 'what', [ 3 ] = 'whattext',
[ 'whatlinktext' ] = 'whattext', [ 'partlink' ] = 'part',
[ 'expansion' ] = 'part',
[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
[ 'editionlink' ] = 'part',
[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
[ 'quoteelinktext' ] = 'quoteetext' }
} )
} )


Line 257: Line 264:
local part
local part
if not utils.empty( part ) then
if not utils.empty( args.part ) then
local part = uniqueLinkIfExists(
part = uniqueLinkIfExists(
args.part,
args.part,
args.parttext or args.partlinktext or args.part
args.parttext or args.part,
'ref'
'ref'
)
)
end
end
local what = uniqueLinkIfExists(
local what
args.what,
if not utils.empty( args.what ) then
args.whattext or args.whatlinktext or args.what,
what = uniqueLinkIfExists(
args.what,
args.whattext or args.what,
'ref'
)
end
local content = {
game, what,
[ 'subheading' ] = part or args.part,
[ 'detail' ] = args.detail,
[ 'quote' ] = args.quote,
[ 'quotee' ] = args.quotee,
[ 'quoteetext' ] = args.quoteetext or args.quotee,
[ 'suffix' ] = args.suffix
}
return out .. makeStandardRef( frame, args.id, nil, content)
end
 
--[[[
Invocation entry point for Template:Ref/File.
 
@param frame - object - The current parser frame
 
@return wikitext - the constructed reference
]]
function ref.file( frame )
local args, out = arguments.preprocess( frame, {
[ 'required' ] = { 'game', 'file' },
[ 'valid' ] = { 'gametext', 'excerpt', 'id', 'part', 'parttext',
'detail', 'quote', 'quotee', 'quoteetext', 'suffix' },
[ 'deprecated' ] = { 'gamelinktext' },
[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
[ 2 ] = 'file', [ 3 ] = 'excerpt',
[ 'gamelinktext' ] = 'gametext', [ 'partlink' ] = 'part',
[ 'expansion' ] = 'part',
[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
[ 'editionlink' ] = 'part',
[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
[ 'quoteelinktext' ] = 'quoteetext' }
} )
 
local game = uniqueLinkIfExists(
acronym( 'game', args.game, 'page', args.game ),
args.gameLinkText or acronym( 'game', args.game, 'title', args.game ),
'ref'
'ref'
)
)
 
local part
if not utils.empty( args.part ) then
part = uniqueLinkIfExists(
args.part,
args.parttext or args.part,
'ref'
)
end
local file = args.file or 'unspecified file'
file = 'game file <code>' .. file .. '</code>'
local excerpt = args.excerpt
if not utils.empty( excerpt ) then
excerpt = 'excerpt <code>' .. excerpt .. '</code>'
end
local content = {
local content = {
game, what,
game, file, excerpt,
[ 'subheading' ] = part or args.part,
[ 'subheading' ] = part or args.part,
[ 'detail' ] = args.detail,
[ 'detail' ] = args.detail,