Module:Video game wikidata: Difference between revisions

Content deleted Content added
Add archiveurl and archivedate to buildCite
Implement pulling authors in buildCite
Line 15:
local systemFormat = "colon";
local updateLinkStyle = nil;
local entities = {};
 
-- Translation table for converting numeric-IDs to shorthand aliases.
Line 92 ⟶ 93:
local reviewerAliases = {
[591573] = 'FAM',
[207708] = 'IGN'
}
 
-- List of accepted reviewer arguments and their related QID.
local reviewerIDs = {
['FAM'] = 591573,
['IGN'] = 207708
}
 
Line 136 ⟶ 139:
local archiveUrl = nil;
local archiveDate = nil;
local authors = {};
 
if(reference['snaks']['P577'] ~= nil and reference['snaks']['P577'][1] ~= nil) then
Line 157 ⟶ 161:
if(reference['snaks']['P2960'] ~= nil and reference['snaks']['P2960'][1] ~= nil) then
archiveDate = reference['snaks']['P2960'][1]['datavalue']['value']['time'];
end;
if(reference['snaks']['P50'] ~= nil and #reference['snaks']['P50'] > 0) then
 
for i,authorDat in pairs(reference['snaks']['P50']) do
local authorQid = 'Q'..authorDat['datavalue']['value']['numeric-id'];
if(entities[authorQid] == nil) then
entity entities[authorQid] = mw.wikibase.getEntity(iGameauthorQid);
end;
local author = {};
author['fullname'] = mw.wikibase.label(authorQid); -- Default to label
author['first'] = nil;
author['last'] = nil;
if(entities[authorQid]['claims']['P735'] ~= nil and entities[authorQid]['claims']['P735'][1] ~= nil) then
author['first'] = mw.wikibase.label('Q'..entities[authorQid]['claims']['P735'][1]['mainsnak']['datavalue']['value']['numeric-id']);
end;
if(entities[authorQid]['claims']['P734'] ~= nil and entities[authorQid]['claims']['P734'][1] ~= nil) then
author['last'] = mw.wikibase.label('Q'..entities[authorQid]['claims']['P734'][1]['mainsnak']['datavalue']['value']['numeric-id']);
end;
table.insert(authors, author);
end;
end;
if(title ~= nil and title ~= "") then
cite = cite .. "|title="..title;
Line 183 ⟶ 209:
cite = cite .. "|archivedate="..archivedateText;
end;
if(#authors > 0) then
for i,author in pairs(authors) do
if(author['first'] ~= nil and author['last'] ~= nil and author['first'] ~= "" and author['last'] ~= "") then
if(#authors == 1) then
cite = cite .."|last="..author['last'].."|first="..author['first'];
else
cite = cite .."|last"..i.."="..author['last'].."|first"..i.."="..author['first'];
end;
else
if(#authors == 1) then
cite = cite .."|author="..author['fullname'];
else
cite = cite .."|author"..i.."="..author['fullname'];
end;
end;
end;
end;
cite = cite..'}}';
Line 304 ⟶ 348:
-- Check for a game parameter. If missing, default to current article.
if(iGame ~= nil and iGame ~= "") then
if(entities[iGame] == nil) then
entity = mw.wikibase.getEntity(iGame);
entities[iGame] = mw.wikibase.getEntity(iGame);
end;
entity = entities[iGame]
else
-- Need to research if we can determine the entity's ID before retrieving it.
entity = mw.wikibase.getEntity();
entities[entity['id']] = entity;
end;