Module:WikidataIB: Difference between revisions

m
1 revision imported
m (1 revision imported from wikipedia:Module:WikidataIB)
m (1 revision imported)
 
(One intermediate revision by one other user not shown)
Line 1:
-- Version: 20212023-0207-0610
-- 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
Line 11:
-- whitelist is passed in named parameter |fetchwikidata (or |fwd)
 
require("strict")
local p = {}
 
Line 18 ⟶ 19:
-- Module:ISOdate
-- Module:DateI18n
-- Module:No globals
-- Module:I18n/complex date
-- Module:Ordinal
Line 160:
langobj = mw.language.new( langcode )
else
langcode = mw.getCurrentFrame():preprocesscallParserFunction('int', {'{{int:lang'}}' )
if mw.language.isKnownLanguageTag(langcode) then
langobj = mw.language.new( langcode )
Line 586:
local postfix = (args.postfix or ""):gsub('"', '')
local dtxt = args.dtxt
local shortname = args.shortname or args.sn
local lang = args.lang or "en" -- fallback to default if missing
local uselbl = args.uselabel or args.uselbl
Line 3,067:
-------------------------------------------------------------------------------
p.siteID = function(frame)
local txtlang = frame:preprocesscallParserFunction('int', "{{int:'lang'}}" ) or ""
-- This deals with specific exceptions: be-tarask -> be-x-old
if txtlang == "be-tarask" then
Line 3,091:
-------------------------------------------------------------------------------
p.projID = function(frame)
local txtlang = frame:preprocesscallParserFunction('int', "{{int:'lang'}}" ) or ""
-- This deals with specific exceptions: be-tarask -> be-x-old
if txtlang == "be-tarask" then
Line 3,250:
local url = frame.args.url or ""
if url:upper() == "NONE" then return nil end
local urls = {}
 
local quals = {}
local qid = frame.args.qid or ""
if url =and url ~= "" then
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
urls[1] = url
if not qid then return nil end
else
if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end
if not qid then return nil end
 
local urls = {}
local quals = {}
if url == "" then
local prop856 = mw.wikibase.getBestStatements(qid, "P856")
for k, v in pairs(prop856) do
Line 3,271 ⟶ 3,272:
end -- test for website having a value
end -- loop through website(s)
else
urls[1] = url
end
if #urls == 0 then return nil end