Semantic MediaWikiDit bericht verdwijnt nadat alle relevante taken zijn afgerond.

Er is één onvoltooide of openstaande taak, die nodig is om het bijwerken 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 24: Regel 24:
local subobject = {
local subobject = {
["Class"] = "Award recognition",
["Class"] = "Award recognition",
["Belongs to award"] = award,
["Belongs to award"] = award or "",
["Belongs to award event"] = awardEvent,
["Belongs to award event"] = awardEvent or "",
["Has position"] = args["Rank"] or false,
["Has position"] = args["Rank"] or "",
["Has recognition type"] = args["Type"] or false,
["Has recognition type"] = args["Type"] or "",
["Has category"] = args["Categorie"] or false,
["Has category"] = args["Categorie"] or "",
["Has recipient"] = mw.text.split( args["Title"], ',', plain ) or false,
["Has recipient"] = mw.text.split( args["Title"], ',', plain ) or "",
["Has description"] = args["Description"] or false
["Has description"] = args["Description"] or ""
}
}
 
local subobjectStore = mw.smw.subobject( subobject )
-- remove false ?
local newSubobject = {};
for k,v in ipairs(subobject) do
if v then
newSubobject[k] = v
end
end
 
local subobjectStore = mw.smw.subobject( newSubobject )
end
end
return
return
Regel 64: Regel 55:
local json = mw.text.jsonDecode( jsonstr )
local json = mw.text.jsonDecode( jsonstr )


award = json["Award"] or false
local award = json["Award"] or ""
awardEvent = json["AWard event"] or false
local awardEvent = json["AWard event"] or ""
local test = json["Naam"]
local test = json["Naam"]
Regel 74: Regel 65:
local setTable = {
local setTable = {
["Has name"] = json["Naam"] or false
["Has name"] = json["Naam"] or "",
--["Has description"] = json["Description"] or false,
["Has description"] = json["Description"] or "",
--["Belongs to award"] = award or false,
["Belongs to award"] = award or "",
--["Belongs to award event"] = awardEvent or false
["Belongs to award event"] = awardEvent or ""
}
}
-- Without false entries
local newSet = {};
for i, v in ipairs( setTable ) do
if i ~= false then
newSet[i] = v
end
end
-- #set
-- #set
local setResult = mw.smw.set( newSet )
local setResult = mw.smw.set( setTable )
end
end



Versie van 29 dec 2024 20:43

Module:Award category




local p = {}

--[[
test test
{{#invoke:Award category |main |json={{#slot:ws-data|{{FULLPAGENAME}}}} }}

]]--
function p.main ( frame )
	local json = frame.args["json"]
	if json == nil or json == "" then
		return error("No JSON string found")
	end
	return json
end

--[[
Local helper function for p.store below
Stores each instance in a subobject
]]--
local function store_award_as_subobject( frame, args, award, awardEvent )
	-- local item = args?

	if mw.smw then
		local subobject = {
			["Class"] = "Award recognition",
			["Belongs to award"] = award or "",
			["Belongs to award event"] = awardEvent or "",
			["Has position"] = args["Rank"] or "",
			["Has recognition type"] = args["Type"] or "",
			["Has category"] = args["Categorie"] or "",
			["Has recipient"] = mw.text.split( args["Title"], ',', plain ) or "",
			["Has description"] = args["Description"] or ""
		}
		local subobjectStore = mw.smw.subobject( subobject )
	end
	return
end

--[[
Store in SMW
Consider using Lua version of parser function instead

{{#invoke:Award category
|store
|json={{#slot:ws-data|{{FULLPAGENAME}} }}
}}

]]--
function p.store( frame )
	local jsonstr = frame.args["json"] or nil
	if jsonstr == nil or jsonstr == "" then
		--Fail silently
		return
	end
	local json = mw.text.jsonDecode( jsonstr )

	local award = json["Award"] or ""
	local awardEvent = json["AWard event"] or ""
	
	local test = json["Naam"]
	
	-- #set
	if mw.smw then
		-- only changed locally
		
		local setTable = {
			["Has name"] = json["Naam"] or "",
			["Has description"] = json["Description"] or "",
			["Belongs to award"] = award or "",
			["Belongs to award event"] = awardEvent or ""
		}
		-- #set
		local setResult = mw.smw.set( setTable )
	end

	-- #subobjects
	local awardInstances = json["Awards"] or nil
	if awardInstances ~= nil then
		for i, v in ipairs( awardInstances ) do
			local subobjectStore = store_award_as_subobject( frame, v, award, awardEvent )
		end
	end
	
	--ternary
	--local sign = if x < 0 then 'negative' else 'non-negative' end
	return "test"
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

return p