Module:UkrWlxId

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

Code

local str = {}
 
function str.isCorrect(frame)
	id = frame.args[1]
    _, _, a, b, c = mw.ustring.find(id, "^(%d%d)-(%d%d%d)-(%d%d%d%d)$")

	if (a==nil) or (b==nil) or (c==nil) then
		return "<div style='color:red'>wrong Id:" .. id .. "</div> [[Category:Natural heritage sites in Ukraine with wrong IDs]]"
	else
		return "[https://wle.toolforge.org/?id="..id.." "..id.."]"
	end
end

function str.isCorrectWLM(frame)
	id = frame.args[1]
    _, _, a, b, c = mw.ustring.find(id, "^(%d%d)-(%d%d%d)-(%d%d%d%d)$")

	if (a==nil) or (b==nil) or (c==nil) then
		return "<div style='color:red'>wrong Id:" .. id .. "</div> [[Category:Cultural heritage monuments in Ukraine with incorrect IDs]]"
	else
		return "[https://tools.wmflabs.org/heritage/api/api.php?action=search&srid="..id.."&format=html&srcountry=ua&srlang=uk&props=image%7Cname%7Caddress%7Cmunicipality%7Clat%7Clon%7Cid%7Ccountry%7Csource%7Cmonument_article%7Cregistrant_url "..id.."]" 	end
end

return str