Modulis:Filmu ārējās saites/Smilšu kaste

Vikipēdijas lapa
Dokumentācijas ikona Moduļa dokumentācija[izveidot]
--oriģinālavots: no:Modul:Sportslenker
--TODO: ignorēt tās vērtības, kas neatbilst formātam
local entity = mw.wikibase.getEntityObject()
claims = {}
if entity then
	claims = entity.claims
end
local dati = {
	{ "P345", "''IMDb'' profils", "en", "http://www.imdb.com/title/$1/" },
	{ "P1237", "''Box Office Mojo'' profils", "en", "http://boxofficemojo.com/movies/?id=$1.htm" },
	{ "P1258", "''Rotten Tomatoes'' profils", "en", "http://www.rottentomatoes.com/$1" },
	{ "P1562", "''AllMovie'' profils", "en", "http://www.allmovie.com/movie/$1" },
	{ "P1712", "''Metacritic'' profils", "en", "http://www.metacritic.com/$1" }
}

local p = {}

function p.main(frame)
	local saites = {}
	for _,v in pairs(dati) do
		local prop = v[1]
		local text = v[2]
		local lang = v[3]
		local furl = v[4]
		if claims then
			if claims[prop] and claims[prop][1] and claims[prop][1].mainsnak.datavalue then
				if furl then
					saites[#saites+1] = "* [" .. string.gsub(furl, "$1", claims[prop][1].mainsnak.datavalue.value) .. " " .. text .. "] "
								..	frame:expandTemplate{ title="" .. lang .. " ikona" }
								
				end
			end
		end
	end
	if entity then
		if #saites == 0 then
			saites[1+#saites] = '[[Kategorija:Raksti ar tukšu filmu ārējo saišu veidni]]'
		end
	else
		saites[1+#saites] = '[[Kategorija:Raksti ar tukšu filmu ārējo saišu veidni]]'
	end
	return table.concat(saites,"\n")
end

return p