13,398
edits
No edit summary |
Tag: Rollback |
||
Line 26: | Line 26: | ||
end | end | ||
end | end | ||
-- Finds whether a Wikidata property is qualified as being in English. | |||
local function isEnglish(prop) | |||
local ret = quickPcall(function () | |||
for i, lang in ipairs(prop.qualifiers.P407) do | |||
if lang.datavalue.value['numeric-id'] == 1860 then | |||
return true | |||
end | |||
end | |||
return false | |||
end) | |||
return ret == true | |||
end | |||
-- Fetches the official website URL from Wikidata. | |||
local fetchWikidataUrl | |||
fetchWikidataUrl = function() | |||
-- Get objects for all official sites on Wikidata. | |||
local websites = quickPcall(function () | |||
return mw.wikibase.getEntityObject().claims.P856 | |||
end) | |||
-- Clone the objects in case other code needs them in their original order. | -- Clone the objects in case other code needs them in their original order. | ||
websites = websites and mw.clone(websites) or {} | websites = websites and mw.clone(websites) or {} | ||
Line 59: | Line 81: | ||
return url | return url | ||
end | end | ||
return url | |||
end | |||
-- Render the tracking category. | -- Render the tracking category. | ||
local function renderTrackingCategory(url, wikidataurl) | local function renderTrackingCategory(url, wikidataurl) | ||
Line 81: | Line 106: | ||
function p._main(args) | function p._main(args) | ||
local url = args[1] or args.URL or args.url | local url = args[1] or args.URL or args.url | ||
return formattedUrl .. renderTrackingCategory(url) | local wikidataurl = fetchWikidataUrl() | ||
return formattedUrl .. renderTrackingCategory(url, wikidataurl) | |||
end | end | ||
edits