Module:Video game wikidata
Appearance
| This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing. |
| This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
| This Lua module is used on approximately 16,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Usage
{{#invoke:Video game wikidata|getSystemAlias|<numeric-id>}}
{{#invoke:Video game wikidata|getSystemID|<alias>}}
{{#invoke:Video game wikidata|getAggregatorAlias|<numeric-id>}}
{{#invoke:Video game wikidata|getAggregatorID|<alias>}}
{{#invoke:Video game wikidata|getReviewerAlias|<numeric-id>}}
{{#invoke:Video game wikidata|getReviewerID|<alias>}}
local Date = require('Module:Date')._Date
local p = {}
-- Translation table for converting numeric-IDs to shorthand aliases.
local systems = {
[13361286] = 'XONE',
[5014725] = 'PS4',
[16338] = 'PC'
}
function p.getSystemAlias(numericId)
return systems[numericId];
end
function p.printReviewRow(frame, reviewscore, df)
local ret = ""
local system = systems[reviewscore['qualifiers']['P400'][1]['datavalue']['value']['numeric-id']];
local score = reviewscore['mainsnak']['datavalue']['value'];
if(not (system == nil or system == "")) then
ret = ret.."("..system..") ";
end;
if(not (score == nil or score == "")) then
ret = ret..score;
end;
local reference = reviewscore['references'][1]['snaks']['P854'][1]['datavalue']['value'];
if(not (reference == nil or reference == "")) then
local cite = "{{cite web|url="..reference;
local timestamp = reviewscore['references'][1]['snaks']['P813'][1]['datavalue']['value']['time'];
local publisher = mw.wikibase.label('Q'..reviewscore['references'][1]['snaks']['P123'][1]['datavalue']['value']['numeric-id']);
local title = reviewscore['references'][1]['snaks']['P1476'][1]['datavalue']['value']['text'];
if(not(title == nil or title == "")) then
cite = cite .. "|title="..title;
end;
if(not(publisher == nil or publisher == "")) then
cite = cite .. "|publisher="..publisher;
end;
--+2016-04-08T00:00:00Z
if(not(timestamp == nil or timestamp == "")) then
local year = string.sub(timestamp,2,5);
local month = string.sub(timestamp,7,8);
local day = string.sub(timestamp,10,11);
local accessdate = Date(year, month, day):text(df);
cite = cite .. "|accessdate="..accessdate;
end;
cite = cite..'}}';
cite = frame:extensionTag{ name = "ref", args = {name=name}, content=cite };
ret = ret..cite;
end;
return ret .. "<br />";
end
return p