Semantic MediaWikiDit bericht verdwijnt nadat alle relevante taken zijn afgerond.

Er is één onvoltooide of openstaande taak, die nodig is om het installeren van Semantic MediaWiki te voltooien. Een beheerder of gebruiker met voldoende rechten kan deze uitvoeren. Dit moet worden gedaan voordat nieuwe gegevens worden toegevoegd om tegenstrijdigheden te voorkomen.

Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 23: Regel 23:
return error("No JSON string found")
return error("No JSON string found")
end
end
local resultTemplateName = frame.args['template'] or nil
local jsondata = mw.text.jsonDecode( jsonstr )
local jsondata = mw.text.jsonDecode( jsonstr )
local awardsTitle = jsondata["Title"]
local awardsTitle = jsondata["Title"]
Regel 48: Regel 49:
--presentation through template
--presentation through template
local templateArgsTable = { Name = name, Rank = rank }
local templateArgsTable = { Name = name, Rank = rank }
output = output .. send_to_template( frame, "Show winner", templateArgsTable )
output = output .. send_to_template( frame, resultTemplateName, templateArgsTable )
end
end

Versie van 2 jun 2023 12:08

Module:Read award recognition




-- @param string jsonstr
-- @todo: use new Lua function that comes with WSSlots (available since Feb)

local p = {}

function p.main ( frame )
	local jsonstr = frame.args['jsonstr']
	local output = jsonstr
	return output
end

local function send_to_template( frame, templateName, argsTable ) 
	if templateName ~= nil and  argsTable ~= nil then
		return frame:expandTemplate{ title = templateName, args = argsTable }
	else
		return ""
	end
end

function p.show_in_list( frame )
	local jsonstr = frame.args['jsonstr'] or nil
	if jsonstr == nil or jsonstr == "" then
		return error("No JSON string found")
	end
	local resultTemplateName = frame.args['template'] or nil
	local jsondata = mw.text.jsonDecode( jsonstr )
	local awardsTitle = jsondata["Title"]
	local firstWinner = jsondata["Awards"][1]["winner"]
	local winners = jsondata["Awards"]
	
	local output = ""
	for i, v in ipairs( winners ) do
		local item = v -- array { "name"="Stephen", "rank"="" }
		local name = v["winner"] or ""
		local nameArr = mw.text.split( name, ',', plain )
		local rank = v["rank"] or ""
		--function here - set for SMW or show on page
		--local win = "<div>" .. rank .. ". " .. name .. "</div>"
		--output = output .. win
		
		--subobject
		if mw.smw then
			local subobjectTable = {}
			subobjectTable['Has name'] = nameArr
			subobjectTable['Has rank'] = rank
			local subobjectStore = mw.smw.subobject( subobjectTable )
		end
		
		--presentation through template
		local templateArgsTable = { Name = name, Rank = rank }
		output = output .. send_to_template( frame, resultTemplateName, templateArgsTable )
	end
	
	--local datatype = awardsTitle .. "<br>" .. firstWinner
	return output
	
end

return p