模块:Uses Wikidata:修订间差异
fix capitalization of Wikidata and Wikipedia in query output |
小 已保护“Module:Uses Wikidata”:高風險模板:515引用<!-- 機器人3 -->([编辑=仅允许自动确认用户](无限期)[移动=仅允许自动确认用户](无限期)) |
||
| 第2行: | 第2行: | ||
function p.usesProperty(frame) | function p.usesProperty(frame) | ||
local | local parent = frame.getParent(frame) | ||
local result = '' | |||
local result = ' | |||
local ii = 1 | local ii = 1 | ||
while true do | while true do | ||
local p_num = | local p_num = parent.args[ii] or '' | ||
if p_num ~= '' then | if p_num ~= '' then | ||
local label = mw.wikibase. | local label = mw.wikibase.label(p_num) or "NO LABEL" | ||
result = result .. "<li> | result = result .. "<li><b>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</b>​([[d:Special:WhatLinksHere/Property:" .. p_num .. "|使用情况]])</li>" | ||
ii = ii + 1 | ii = ii + 1 | ||
else break | else break | ||
end | end | ||
end | end | ||
return result | return result | ||
end | end | ||
--混和模板 | |||
function p. | function p.Tracks_Wikidata(frame) | ||
local parent = frame.getParent(frame) | local parent = frame.getParent(frame) | ||
local result = ' | local result = '' | ||
local ii = 1 | local ii = 1 | ||
while true do | while true do | ||
local p_num = | local p_num = parent.args[ii] or '' | ||
if p_num ~= '' then | if p_num ~= '' then | ||
local label = mw.wikibase. | local label = mw.wikibase.label(p_num) or "NO LABEL" | ||
result = result .. "<li> | result = result .. "<li><b>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</b>​([[d:Special:WhatLinksHere/Property:" .. p_num .. "|使用情况]])</li>" | ||
ii = ii + 1 | ii = ii + 1 | ||
else break | else break | ||
end | end | ||
end | end | ||
local template = frame:expandTemplate{ | |||
return | title = "Sister project", | ||
args = {"image=" .. frame:expandTemplate{ | |||
title = "Sister project", | |||
args = {"base = Wikidata-logo.svg", | |||
"base_width = 40px", | |||
"base_link = Wikipedia:Wikidata", | |||
"float = Magnifying glass icon mgx2.svg", | |||
"float_link = Wikipedia:Wikidata", | |||
"float_width = 28px", | |||
"x = 12", | |||
"y = 0" | |||
}},"position = " .. (parent.args["position"] or ""), | |||
"text = 本" .. frame:expandTemplate{title = "NS1/Wikidata"} .. "[[:Category:" .. ( parent.args["cat"] or "维基数据跟踪分类") .. "|跟踪]]" .. ( parent.args["section"] and " 一个或多个[[维基数据]]属性。更多細節請參見 [[#" .. parent.args["section"] .."|§ " .. parent.args["section"] .. "]]" or "[[维基数据]]属性:" .. (result or "")) | |||
}} | |||
return template | |||
end | end | ||
return p | return p | ||
2022年7月14日 (四) 17:57的版本
<templatestyles src="Module:Message box/ombox.css"></templatestyles>
| 文件:Mergefrom.svg | It has been suggested that Module:Tracks and uses Wikidata be merged into this page. (Discuss) |
This module is used by {{Uses Wikidata}}, {{Tracks Wikidata}}, {{Tracks and uses Wikidata}} and {{Wikidata property}}.
Usage
{{#invoke:Uses Wikidata|usesProperty}}
local p = {}
function p.usesProperty(frame)
local parent = frame.getParent(frame)
local result = ''
local ii = 1
while true do
local p_num = parent.args[ii] or ''
if p_num ~= '' then
local label = mw.wikibase.label(p_num) or "NO LABEL"
result = result .. "<li><b>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</b>​([[d:Special:WhatLinksHere/Property:" .. p_num .. "|使用情况]])</li>"
ii = ii + 1
else break
end
end
return result
end
--混和模板
function p.Tracks_Wikidata(frame)
local parent = frame.getParent(frame)
local result = ''
local ii = 1
while true do
local p_num = parent.args[ii] or ''
if p_num ~= '' then
local label = mw.wikibase.label(p_num) or "NO LABEL"
result = result .. "<li><b>[[d:Property:" .. p_num .. "|" .. label .. " <small>(" .. string.upper(p_num) .. ")</small>]]</b>​([[d:Special:WhatLinksHere/Property:" .. p_num .. "|使用情况]])</li>"
ii = ii + 1
else break
end
end
local template = frame:expandTemplate{
title = "Sister project",
args = {"image=" .. frame:expandTemplate{
title = "Sister project",
args = {"base = Wikidata-logo.svg",
"base_width = 40px",
"base_link = Wikipedia:Wikidata",
"float = Magnifying glass icon mgx2.svg",
"float_link = Wikipedia:Wikidata",
"float_width = 28px",
"x = 12",
"y = 0"
}},"position = " .. (parent.args["position"] or ""),
"text = 本" .. frame:expandTemplate{title = "NS1/Wikidata"} .. "[[:Category:" .. ( parent.args["cat"] or "维基数据跟踪分类") .. "|跟踪]]" .. ( parent.args["section"] and " 一个或多个[[维基数据]]属性。更多細節請參見 [[#" .. parent.args["section"] .."|§ " .. parent.args["section"] .. "]]" or "[[维基数据]]属性:" .. (result or ""))
}}
return template
end
return p