Module:Ref: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
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 243: Line 243:
[ 'valid' ] = { 'whattext', 'id', 'part', 'parttext', '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',
[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext' }
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
[ 'quoteelinktext' ] = 'quoteetext' }
} )
} )


Line 259: Line 265:
local part
local part
if not utils.empty( args.part ) then
if not utils.empty( args.part ) then
local part = uniqueLinkIfExists(
part = uniqueLinkIfExists(
args.part,
args.part,
args.parttext 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.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,