请输入您要查询的百科知识:

 

词条 Module:SportsReference/sandbox
释义

local function linktext(s1,s2,s3)

if (s3 == nil) or (s3 == "") then

return "[https://www.sports-reference.com/olympics/athletes/" .. s1 .. ".html " .. s2 .. "] at Sports Reference"

else

return "[https://www.sports-reference.com/olympics/athletes/" .. s1 .. ".html " .. s2 .. "] at Sports Reference ([https://web.archive.org/web/" .. s3 .. "/https://www.sports-reference.com/olympics/athletes/" .. s1 .. ".html archive])"

end

end

local function category(s)

if mw.title.getCurrentTitle().namespace ~= 0 then

return ""

end

return ""

end

local p = {}

function p.link(frame)

-- Optional first parameter contains ID portion of Sports-Reference URL.

-- Trim any leading or trailing spaces. If it contains ".html", remove it.

local id = string.gsub((mw.text.trim(frame.args[1]) or ""), ".html", "")

-- Optional second parameter contains name for link. Trim leading or trailing spaces.

-- If name is not provided, use article name without disambiguation.

local name = mw.text.trim(frame.args[2])

if (name == nil) or (name == "") then

name = string.gsub(mw.title.getCurrentTitle().text, "%s+%b()$", "", 1)

end

-- Optional third parameter contains date/time portion of Archive.org URL.

local archive = mw.text.trim(frame.args[3])

-- For instance where mw.wikibase not available:

-- if ID not provided, return error text

-- if ID is provided, return link

if not mw.wikibase then

if (id == nil) or (id == "") then

return "Sports-Reference template missing ID."

else

return linktext(id,name,archive)

end

end

-- For articles without Wikidata property:

-- if ID not provided, return error text and tracking category

-- if ID is provided, return link and tracking category

local entity = mw.wikibase.getEntityObject() or {}

local claims = entity.claims or {}

local hasProp = claims["P1447"]

if not hasProp then

if (id == nil) or (id == "") then

return "Sports-Reference template missing ID and not present in Wikidata. How do I fix this?" .. category("missing ID and not in Wikidata")

else

return linktext(id,name,archive) .. category("with ID not in Wikidata")

end

end

-- For articles with Wikidata property:

-- if ID not provided, return link (using Wikidata) and tracking category

-- if ID is provided, return link (using ID) and one of two tracking categories

local propValue = hasProp[1].mainsnak.datavalue.value

if (id == nil) or (id == "") then

return linktext(propValue,name,archive) .. " " .. category("using Wikidata")

end

if id == propValue then

return linktext(id,name,archive) .. category("with ID same as Wikidata")

else

return linktext(id,name,archive) .. category("with ID different from Wikidata")

end

end

return p

1 : Sports-Reference template " .. s .. "

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/14 5:00:47