Module:WikidataIB and Module:WikidataIB/sandbox: Difference between pages
From Vigyanwiki
(Difference between pages)
m (3 revisions imported from alpha:Module:WikidataIB) |
m (1 revision imported) |
||
| Line 1: | Line 1: | ||
-- Version: | -- Version: 2021-02-06 | ||
-- Module to implement use of a blacklist and whitelist for infobox fields | -- Module to implement use of a blacklist and whitelist for infobox fields | ||
-- Can take a named parameter |qid which is the Wikidata ID for the article | -- Can take a named parameter |qid which is the Wikidata ID for the article | ||
| Line 10: | Line 10: | ||
-- blacklist is passed in named parameter |suppressfields (or |spf) | -- blacklist is passed in named parameter |suppressfields (or |spf) | ||
-- whitelist is passed in named parameter |fetchwikidata (or |fwd) | -- whitelist is passed in named parameter |fetchwikidata (or |fwd) | ||
local p = {} | local p = {} | ||
| Line 19: | Line 18: | ||
-- Module:ISOdate | -- Module:ISOdate | ||
-- Module:DateI18n | -- Module:DateI18n | ||
-- Module:No globals | |||
-- Module:I18n/complex date | -- Module:I18n/complex date | ||
-- Module:Ordinal | -- Module:Ordinal | ||
| Line 75: | Line 75: | ||
["NaN"] = "Not a number", | ["NaN"] = "Not a number", | ||
-- set the following to the name of a tracking category, | -- set the following to the name of a tracking category, | ||
-- e.g. "", or "" to disable: | -- e.g. "[[Category:Articles with missing Wikidata information]]", or "" to disable: | ||
["missinginfocat"] = "", | ["missinginfocat"] = "[[Category:Articles with missing Wikidata information]]", | ||
["editonwikidata"] = "Edit this on Wikidata", | ["editonwikidata"] = "Edit this on Wikidata", | ||
["latestdatequalifier"] = function (date) return "before " .. date end, | ["latestdatequalifier"] = function (date) return "before " .. date end, | ||
| Line 160: | Line 160: | ||
langobj = mw.language.new( langcode ) | langobj = mw.language.new( langcode ) | ||
else | else | ||
langcode = mw.getCurrentFrame(): | langcode = mw.getCurrentFrame():preprocess( '{{int:lang}}' ) | ||
if mw.language.isKnownLanguageTag(langcode) then | if mw.language.isKnownLanguageTag(langcode) then | ||
langobj = mw.language.new( langcode ) | langobj = mw.language.new( langcode ) | ||
| Line 586: | Line 586: | ||
local postfix = (args.postfix or ""):gsub('"', '') | local postfix = (args.postfix or ""):gsub('"', '') | ||
local dtxt = args.dtxt | local dtxt = args.dtxt | ||
local shortname = args.shortname | local shortname = args.shortname | ||
local lang = args.lang or "en" -- fallback to default if missing | local lang = args.lang or "en" -- fallback to default if missing | ||
local uselbl = args.uselabel or args.uselbl | local uselbl = args.uselabel or args.uselbl | ||
| Line 670: | Line 670: | ||
else | else | ||
-- no sitelink and no label, so return whatever was returned from labelOrId for now | -- no sitelink and no label, so return whatever was returned from labelOrId for now | ||
-- add tracking category | -- add tracking category [[Category:Articles with missing Wikidata information]] | ||
-- for enwiki, just return the tracking category | -- for enwiki, just return the tracking category | ||
if mw.wikibase.getGlobalSiteId() == "enwiki" then | if mw.wikibase.getGlobalSiteId() == "enwiki" then | ||
| Line 832: | Line 832: | ||
if not entityID or entityID == "" then entityID= mw.wikibase.getEntityIdForCurrentPage() end | if not entityID or entityID == "" then entityID= mw.wikibase.getEntityIdForCurrentPage() end | ||
propertyID = propertyID or "" | propertyID = propertyID or "" | ||
local icon = "& | local icon = " <span class='penicon autoconfirmed-show'>[[" | ||
-- " <span data-bridge-edit-flow='overwrite' class='penicon'>[[" -> enable Wikidata Bridge | -- " <span data-bridge-edit-flow='overwrite' class='penicon'>[[" -> enable Wikidata Bridge | ||
.. i18n["filespace"] | .. i18n["filespace"] | ||
| Line 3,067: | Line 3,067: | ||
------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||
p.siteID = function(frame) | p.siteID = function(frame) | ||
local txtlang = frame: | local txtlang = frame:preprocess( "{{int:lang}}" ) or "" | ||
-- This deals with specific exceptions: be-tarask -> be-x-old | -- This deals with specific exceptions: be-tarask -> be-x-old | ||
if txtlang == "be-tarask" then | if txtlang == "be-tarask" then | ||
| Line 3,091: | Line 3,091: | ||
------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||
p.projID = function(frame) | p.projID = function(frame) | ||
local txtlang = frame: | local txtlang = frame:preprocess( "{{int:lang}}" ) or "" | ||
-- This deals with specific exceptions: be-tarask -> be-x-old | -- This deals with specific exceptions: be-tarask -> be-x-old | ||
if txtlang == "be-tarask" then | if txtlang == "be-tarask" then | ||
| Line 3,250: | Line 3,250: | ||
local url = frame.args.url or "" | local url = frame.args.url or "" | ||
if url:upper() == "NONE" then return nil end | if url:upper() == "NONE" then return nil end | ||
local qid = frame.args.qid or "" | |||
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end | |||
if not qid then return nil end | |||
local urls = {} | local urls = {} | ||
local quals = {} | local quals = {} | ||
if url == "" then | |||
if url | |||
local prop856 = mw.wikibase.getBestStatements(qid, "P856") | local prop856 = mw.wikibase.getBestStatements(qid, "P856") | ||
for k, v in pairs(prop856) do | for k, v in pairs(prop856) do | ||
| Line 3,272: | Line 3,271: | ||
end -- test for website having a value | end -- test for website having a value | ||
end -- loop through website(s) | end -- loop through website(s) | ||
else | |||
urls[1] = url | |||
end | end | ||
if #urls == 0 then return nil end | if #urls == 0 then return nil end | ||