Jump to content

Module:Uses Wikidata: Difference between revisions

From Humanipedia
hp>Cewbot
m Maintain {{WPBS}}: 1 WikiProject template. Create {{WPBS}}.
m 1 revision imported
Line 1: Line 1:
{{WikiProject banner shell|
local p = {}
{{WikiProject Wikidata}}
}}
== Unbalanced ul tags ==


[https://en.wikipedia.org/w/index.php?title=Module:Uses_Wikidata&curid=46920381&diff=1064017392&oldid=1051978961 This edit] appears to have resulted in an extra closing {{tag|ul|c}} tag, which appears to be visible as an extra bullet on pages including {{tl|Tracks and uses Wikidata}}. Pinging {{U|Graham87}}, who will probably know which one to remove. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 20:46, 6 January 2022 (UTC)
function p.usesProperty(frame)
:{{replyto|Jonesey95}} I've removed the unicode bullet and the non-breaking spaces, along with fixing the unordered list, in the second function. Maybe the formatting could be improved for sighted people but if so, please use decorative images with no alt text or something like that, not fancy Unicode/spacing. '''[[User:Graham87|Graham]]'''[[User talk:Graham87|<span style="color: green;">87</span>]] 02:25, 7 January 2022 (UTC)
local args = frame.getParent(frame).args or nil
::Nah, thinking about it, the previous Unicode bullet was fine; I've [https://en.wikipedia.org/w/index.php?title=Module:Uses_Wikidata&diff=1064190218&oldid=1064188562 put it back] and fixed the HTML markup. '''[[User:Graham87|Graham]]'''[[User talk:Graham87|<span style="color: green;">87</span>]] 02:36, 7 January 2022 (UTC)
if mw.text.trim(args[1] or '') == '' then
:::The double bullet is gone now, as are the mismatched tags. If it "looks" OK to you, it's OK with me. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 02:48, 7 January 2022 (UTC)
args = frame.args
end
local result = '<ul>'
local ii = 1
while true do
local p_num = mw.text.trim(args[ii] or '')
if p_num ~= '' then
local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
result = result .. "<li>[[File:Disc Plain blue dark.svg|middle|4px|link=|alt=]] <b><i>[[d:Property talk:" .. p_num .. "|" .. label .. " (" .. string.upper(p_num) .. ")]]</i></b> (see <span class='plainlinks'>[https://query.wikidata.org/embed.html#SELECT%20%3FWikidata_item_%20%3FWikidata_item_Label%20%3Fvalue%20%3FvalueLabel%20%3FEnglish_Wikipedia_article%20%23Show%20data%20in%20this%20order%0A%7B%0A%09%3FWikidata_item_%20wdt%3A" .. p_num .. "%20%3Fvalue%20.%20%23Collecting%20all%20items%20which%20have%20" .. p_num .. "%20data%2C%20from%20whole%20Wikidata%20item%20pages%0A%09OPTIONAL%20%7B%3FEnglish_Wikipedia_article%20schema%3Aabout%20%3FWikidata_item_%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wikipedia.org%2F%3E%20.%7D%20%23If%20collected%20item%20has%20link%20to%20English%20Wikipedia%2C%20show%20that%0A%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%20%7D%20%23Show%20label%20in%20this%20language.%20%22en%22%20is%20English.%20%20%20%0A%7D%0ALIMIT%201000 uses]</span>)</li>"
ii = ii + 1
else break
end
end
result = result.."</ul>"
return result
end
 
function p.tuProperty(frame)
local parent = frame.getParent(frame)
local result = '<ul>'
local ii = 1
while true do
local p_num = mw.text.trim(parent.args[ii] or '')
if p_num ~= '' then
local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
result = result .. "<li><span style='font-size:90%;line-height:1;'></span>&nbsp;&nbsp;<b>[[d:Property:" .. p_num .. "|" .. label .. "]]</b> <span style='font-size:90%;'>([[d:Property talk:" .. string.upper(p_num) .. "|" .. p_num .. "]])</span></li>"
ii = ii + 1
else break
end
end
result = result.."</ul>"
return result
end
 
return p

Revision as of 14:01, 3 February 2025

Lua error in package.lua at line 80: module 'Module:Yesno' not found. Script error: No such module "High-use". 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 args = frame.getParent(frame).args or nil
	if mw.text.trim(args[1] or '') == '' then
		args = frame.args
	end
	local result = '<ul>'
	local ii = 1
	while true do
		local p_num = mw.text.trim(args[ii] or '')
		if p_num ~= '' then
			local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
			result = result .. "<li>[[File:Disc Plain blue dark.svg|middle|4px|link=|alt=]] <b><i>[[d:Property talk:" .. p_num .. "|" .. label .. " (" .. string.upper(p_num) .. ")]]</i></b> (see <span class='plainlinks'>[https://query.wikidata.org/embed.html#SELECT%20%3FWikidata_item_%20%3FWikidata_item_Label%20%3Fvalue%20%3FvalueLabel%20%3FEnglish_Wikipedia_article%20%23Show%20data%20in%20this%20order%0A%7B%0A%09%3FWikidata_item_%20wdt%3A" .. p_num .. "%20%3Fvalue%20.%20%23Collecting%20all%20items%20which%20have%20" .. p_num .. "%20data%2C%20from%20whole%20Wikidata%20item%20pages%0A%09OPTIONAL%20%7B%3FEnglish_Wikipedia_article%20schema%3Aabout%20%3FWikidata_item_%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wikipedia.org%2F%3E%20.%7D%20%23If%20collected%20item%20has%20link%20to%20English%20Wikipedia%2C%20show%20that%0A%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%20%7D%20%23Show%20label%20in%20this%20language.%20%22en%22%20is%20English.%20%20%20%0A%7D%0ALIMIT%201000 uses]</span>)</li>"
			ii = ii + 1
		else break
		end
	end
	result = result.."</ul>"
	return result
end

function p.tuProperty(frame)
	local parent = frame.getParent(frame)
	local result = '<ul>'
	local ii = 1
	while true do
		local p_num = mw.text.trim(parent.args[ii] or '')
		if p_num ~= '' then
			local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
			result = result .. "<li><span style='font-size:90%;line-height:1;'>●</span>&nbsp;&nbsp;<b>[[d:Property:" .. p_num .. "|" .. label .. "]]</b> <span style='font-size:90%;'>([[d:Property talk:" .. string.upper(p_num) .. "|" .. p_num .. "]])</span></li>"
			ii = ii + 1
		else break
		end
	end
	result = result.."</ul>"
	return result
end

return p