Aller au contenu

Module:Codjowoe/saye

Èn årtike di Wiccionaire.
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}
local builder = require("Module:Builder")

function p.saye(frame)
	croejhete = frame.args[1]
	local fitchi_sayes = "Codjowoe/"..croejhete.."/saye"
	sayes = builder.load_data(fitchi_sayes)
	if not sayes then
		builder.error("gn a pont d’ fitchî d’ saye po <code>"..croejhete.."</code>")
		return builder.get_content()
	end
	local fitchi_croejhete = mw.title.new( "Codjowoe/"..croejhete, "Module" )
	if not fitchi_croejhete.exists then
		builder.error("li croejhete <code>"..croejhete.."</code> n’ est nén ricnoxhowe")
		return builder.get_content()
	end
	local html = mw.html.create()
	html:node(mw.html.create("h2"):wikitext("Sayes"))
	html:node(mw.html.create("p"):wikitext("Sayes otomatijheyes avou les dnêyes ki sont dins l’ fitchî ''[[Module:"..fitchi_sayes.."]]''"))
	croejhete = require(fitchi_croejhete.fullText);
	for i,saye in ipairs(sayes) do
		local e = 0
		local ecoleur = "#00af8a"
		local edrovri = "neni"
		local etxt = "aroke"
		local X = saye.INF
		local A = saye.bodje_A
		local B = A
		local C = A
		if saye["bodje_B"] ~= nil then B = saye.bodje_B end
		if saye["bodje_C"] ~= nil then C = saye.bodje_C end
		codjowas = croejhete.tavlea_codjowas(saye.troke, A, B, C, X)
		out = {}
		for t,v in pairs(saye) do
			local tmp1 = ""
			if codjowas[t] ~= nil then
				if type(v) == "table" then
					local tmp = {}
					for d,c in ipairs(v) do
						-- table.concat(c, '/') n' rote nén ?
						if type(c) == "table" then c = table.concat({c[1],c[2],c[3],c[4],c[5]}, '/') end 
						if type(codjowas[t][d]) == "table" then codjowas[t][d] = table.concat(codjowas[t][d], '/') end 
						if c == "" then tmp1 = '-' else tmp1 = c end
						if c ~= codjowas[t][d] then 
							if codjowas[t][d] == "" then tmp1 = "-" else tmp1 = codjowas[t][d] end
							tmp1 = '<span style="color:#d33;">'..tmp1..'</span> ('..c..')' 
							e = e +1
						end
						table.insert(tmp, tmp1)
					end
					out[t] = table.concat(tmp, ", ")
				elseif type(v) == "string" then
					if type(codjowas[t]) == "table" then codjowas[t] = table.concat(codjowas[t], '/') end
					if v == "" then v = '-' end
					tmp1 = v
					if v ~= codjowas[t] then 
						if codjowas[t][d] == "" then tmp1 = "-" else tmp1 = codjowas[t] end
						tmp1 = '<span style="color:#d33;">'..tmp1..'</span> ('..v..')'
						e = e +1
					end
					out[t] = tmp1
				end
			
			end
		end
		
		local pre = mw.html.create("pre"):css("background", "#111"):css("color", "#fff"):css("font-size", ".9em")
		pre:wikitext("'''A'''="..A.." ; '''B'''="..B.." ; '''C'''="..C.."\n")
		if out["INF"] == nil then out["INF"] = "?" end
		if out["PP"] == nil then out["PP"] = "?" end
		if out["PE"] == nil then out["PE"] = "?" end
		if out["PEf"] == nil then out["PEf"] = "?" end
		if out["IP"] == nil then out["IP"] = "?" end
		if out["DIE"] == nil then out["DIE"] = "?" end
		if out["IE"] == nil then out["IE"] = "?" end
		if out["IF"] == nil then out["IF"] = "?" end
		if out["SP"] == nil then out["SP"] = "?" end
		if out["DSE"] == nil then out["DSE"] = "?" end
		if out["C"] == nil then out["C"] = "?" end
		if out["K"] == nil then out["K"] = "?" end
		pre:wikitext("INF : "..out["INF"].." ; PP : "..out["PP"].." ; PE : "..out["PE"].."; PEf : "..out["PEf"].."\n")
		pre:wikitext("IP : "..out["IP"].."\n")
		pre:wikitext("DIE : "..out["DIE"].."\n")
		pre:wikitext("IE : "..out["IE"].."\n")
		pre:wikitext("IF : "..out["IF"].."\n")
		pre:wikitext("SP : "..out["SP"].."\n")
		pre:wikitext("DSE : "..out["DSE"].."\n")
		pre:wikitext("C : "..out["C"].."\n")
		pre:wikitext("K : "..out["K"].."\n")
		
		if e > 0 then ecoleur = "#d33" ; edrovri = "oyi" end
		if e > 1 then etxt = etxt.."s" end
		local aroke = mw.html.create("span")
		            :css("background", ecoleur)
		            :css("color", "#fff")
		            :css("border-radius", "3px")
		            :css("padding", "1px 5px")
		            :css("font-family", "mono")
		            :css("font-weight", "normal")
		            :css("font-size", ".9em")
		            :wikitext(e.." "..etxt)
		local tite_boesse = " Saye #"..i..", troke " ..saye.troke.." : " ..saye.INF.." "..tostring(aroke)
		local info = ""
		if saye.info ~= nil then 
			info = frame:expandTemplate{ title = "Bindea", args={sore="info",saye.info} }
		end
		html:node(frame:expandTemplate{ title = "Boesse", args={tite=tite_boesse, drovri = edrovri, (tostring(info) .. tostring(pre))} })
	end
	return html
end

return p