יחידה:תבנית מידע/אתר

< יחידה:תבנית מידע
ווערסיע פון 17:48, 29 מאי 2024 דורך תנא קמא (שמועס | ביישטייערונגען) (צופאסונג)
(חילוק) → עלטערע ווערסיע | איצטיגע ווערסיע (חילוק) | נייערע ווערסיע ← (חילוק)

מען קען שאפן דאקומענטאציע פאר דעם מאדול ביי יחידה:תבנית מידע/אתר/דאק

function site(frame)
	local templateArgs = frame.args

	if templateArgs[1] =='-' then return '' end
	
	if templateArgs[1]~= '' and  templateArgs[1]~= nil then
		return templateArgs[1]
	end
	local entityId = nil
	if entityId == nil then return '' end
	local sites = mw.wikibase.getBestStatements(entityId, 'P856')
	if #sites == 0 then return '' end

	-- TODO: consider to use qualifier to pick a different site. for simplification currently pick the first
	local siteForFormat = sites[1] and sites[1].mainsnak and sites[1].mainsnak.datavalue.value
	if siteForFormat==nil or siteForFormat=='' then return '' end
	
	local urlModule = require('Module:URL')
	if #siteForFormat<35 then
		return urlModule.url(frame:newChild{ title = title, args = { siteForFormat	} } )
	end
	return '[' .. siteForFormat ..' אתר רשמי]'
end

return 	{
	['אתר']=site,
	site=site
}