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
 
(16 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
local p = {}
local p = {}
local mSlot = require('Module:Slot')


--[[
--[[
Regel 18: Regel 19:
Stores each instance in a subobject
Stores each instance in a subobject
]]--
]]--
local function store_award_as_subobject( frame, args, awardCategory, awardEvent, award )
local function store_award_as_subobject( frame, args, award, awardCategory, awardEvent, awardEventCategory )
--local frame = mw.getCurrentFrame()
if mw.smw then
if mw.smw then
local recipient = args["Title"] or args["Book"] or args["Person"] or ""
local recipient = args["Title"] or args["Book"] or args["Person"] or ""
Regel 24: Regel 26:
["Class"] = "Award recognition",
["Class"] = "Award recognition",
["Belongs to award"] = award or "",
["Belongs to award"] = award or "",
["Belongs to award category"] = awardCategory or "",
["Belongs to award event"] = awardEvent or "",
["Belongs to award event"] = awardEvent or "",
["Belongs to award category"] = awardCategory or "",
["Has position"] = args["Rank"] or "",
["Has position"] = args["Rank"] or "",
["Has recognition type"] = args["Type"] or "",
["Has recognition type"] = args["Type"] or "",
["Has category"] = args["Categorie"] or "",
-- ["Has category"] = args["Categorie"] or "",
["Has recipient"] = mw.text.split( recipient, ',', true ) or "",
["Has recipient"] = mw.text.split( recipient, ',', true ) or "",
["Has description"] = args["Description"] or ""
["Has description"] = args["Description"] or ""
Regel 48: Regel 50:


]]--
]]--
function p.store( frame )
 
p.store = function( frame )
local page = frame.args["page"] or nil
local page = frame.args["page"] or nil
if page == nil or page == "" then return end
if page == nil or page == "" then return end
local slot = frame.args["slot"] or "ws-data"
local slot = frame.args["slot"] or "ws-data"
local id = frame.args["id"] or "" -- are we still using this?
local id = frame.args["id"] or ""


local jsonstr = mw.slots.slotContent( slot, page )
local jsonstr = mw.slots.slotContent( slot, page )
Regel 60: Regel 63:
if type(json) ~= "table" then return end
if type(json) ~= "table" then return end


local awardCategory = json["Award category"] or ""
local awardEvent = json["Award event"] or ""
local awardEvent = json["Award event"] or ""
mw.log( "awardEvent: " .. awardEvent )
-- @todo query award
-- @todo query award
local award = mSlot.getValueFromTemplateData( "ws-page-props", awardEvent, "Award event", "Prijs" ) or ""
mw.log( "award: " .. award )
-- p.getSlotValue( page, slot, "Award" )


-- @todo derive name from category + event?
-- @todo derive name from category + event?
Regel 73: Regel 82:
["Klasse"] = "Prijscategorie op evenement",
["Klasse"] = "Prijscategorie op evenement",
["Has ID"] = id,
["Has ID"] = id,
--["Belongs to award"] = json["Award"] or ""
["Belongs to award"] = award,
["Belongs to award event"] = json["Award event"] or "",
["Belongs to award category"] = awardCategory,
["Belongs to award category"] = json["Award category"] or "",
["Belongs to award event"] = awardEvent
--["Belongs to award event category"] = page,
--["Title"] = json["Name"] or "",
--["Title"] = json["Name"] or "",
--["Has name"] = json["Name"] or "",
--["Has name"] = json["Name"] or "",
Regel 85: Regel 95:


-- #subobjects
-- #subobjects
local awardInstances = json["Awards"] or nil
local awardInstances = json["Persons"] or json["Titles"] or json["Books"] or json["Series"] or nil
local awardInstancesForTitle = json["Titles"] or nil


if awardInstances ~= nil then
if awardInstances ~= nil then
local awardCategory = page
local awardEventCategory = page
for i, v in ipairs( awardInstances ) do
for i, v in ipairs( awardInstances ) do
local subobjectStore = store_award_as_subobject( frame, v, awardCategory, awardEvent, award )
local subobjectStore = store_award_as_subobject(  
frame, v, award, awardCategory, awardEvent, awardEventCategory
)
end
end
end
end
Regel 97: Regel 108:
--ternary
--ternary
--local sign = if x < 0 then 'negative' else 'non-negative' end
--local sign = if x < 0 then 'negative' else 'non-negative' end
return "test"
return
 
end
end


Regel 113: Regel 125:
--[[
--[[
]]--
]]--
function p.show_award_recognitions( frame )
p.show_award_recognitions = function( frame )
local jsonstr = frame.args["json"] or nil
local page = frame.args["page"] or page
local page = frame.args["page"] or page
local slot = frame.args["slot"] or "ws-data"
local template = frame.args["template"] or nil
local template = frame.args["template"] or nil
 
local jsonstr = mw.slots.slotContent( slot, page )
if jsonstr == nil or jsonstr == "" then return "" end
-- jsontree
local json = mw.text.jsonDecode( jsonstr )
if type(json) ~= "table" then return "" end
 
res = ""
res = ""
if jsonstr ~= nil then
local awards = json["Persons"] or json["Titles"] or json["Books"] or json["Series"] or nil
local json = mw.text.jsonDecode( jsonstr )
if awards == nil then return "" end
local awards = json["Awards"] or nil
for i,v in ipairs(awards) do
if awards == nil then return "" end
res = res .. send_to_template( frame, template, v )
for i,v in ipairs(awards) do
res = res .. send_to_template( frame, template, v )
end
--
--etc
end
end
--
--etc
return res
return res
end
end
Regel 134: Regel 150:
--[[ @todo maybe - naming has changed so this won't work ]]--
--[[ @todo maybe - naming has changed so this won't work ]]--
p.getAwardEventFromPageName = function( page )  
p.getAwardEventFromPageName = function( page )  
local page = frame.args["page"] or nil
if page == nil or page == "" then return end
local slot = frame.args["slot"] or "ws-data"
local awardEvent = nil
local awardEvent = nil
-- get awardEvent on the basis of the page name
-- get awardEvent on the basis of the page name

Huidige versie van 18 sep 2025 19:47

Module:Award event category




local p = {}
local mSlot = require('Module:Slot')

--[[
Ignore - generic 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, awardCategory, awardEvent, awardEventCategory )
	--local frame = mw.getCurrentFrame()
	if mw.smw then
		local recipient = args["Title"] or args["Book"] or args["Person"] or ""
		local subobject = {
			["Class"] = "Award recognition",
			["Belongs to award"] = award or "",
			["Belongs to award category"] = awardCategory 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( recipient, ',', true ) 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 event category|store
|page={{FULLPAGENAME}} 
|slot=ws-data
|id=
}}

]]--

p.store = function( frame )
	local page = frame.args["page"] or nil
	if page == nil or page == "" then return end
	local slot = frame.args["slot"] or "ws-data"
	local id = frame.args["id"] or ""

	local jsonstr = mw.slots.slotContent( slot, page )
	if jsonstr == nil or jsonstr == "" then return end
	-- jsontree
	local json = mw.text.jsonDecode( jsonstr )
	if type(json) ~= "table" then return end

	local awardCategory = json["Award category"] or ""
	local awardEvent = json["Award event"] or ""
	mw.log( "awardEvent: " .. awardEvent )
	-- @todo query award
	local award = mSlot.getValueFromTemplateData( "ws-page-props", awardEvent, "Award event", "Prijs" ) or ""
	mw.log( "award: " .. award )

	-- p.getSlotValue( page, slot, "Award" )

	-- @todo derive name from category + event?
	local name = json["Name"] or ""
	
	-- #set:
	local setResult = nil
	if mw.smw then
		local setTable = {
			-- Dutch-language label
			["Klasse"] = "Prijscategorie op evenement",
			["Has ID"] = id,
			["Belongs to award"] = award,
			["Belongs to award category"] = awardCategory,
			["Belongs to award event"] = awardEvent
			--["Belongs to award event category"] = page,
			--["Title"] = json["Name"] or "",
			--["Has name"] = json["Name"] or "",
			--["Has description"] = json["Description"] or "",
			--["Has category"] = json["Category"] or ""
		}
		setResult = mw.smw.set( setTable )
	end

	-- #subobjects
	local awardInstances = json["Persons"] or json["Titles"] or json["Books"] or json["Series"] or nil

	if awardInstances ~= nil then
		local awardEventCategory = page
		for i, v in ipairs( awardInstances ) do
			local subobjectStore = store_award_as_subobject( 
				frame, v, award, awardCategory, awardEvent, awardEventCategory
			)
		end
	end

	--ternary
	--local sign = if x < 0 then 'negative' else 'non-negative' end
	return

end

--[[
use a template to format a (Lua) table
]]--
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

--[[
]]--
p.show_award_recognitions = function( frame )
	local page = frame.args["page"] or page
	local slot = frame.args["slot"] or "ws-data"
	local template = frame.args["template"] or nil

	local jsonstr = mw.slots.slotContent( slot, page )
	if jsonstr == nil or jsonstr == "" then return "" end
	-- jsontree
	local json = mw.text.jsonDecode( jsonstr )
	if type(json) ~= "table" then return "" end

	res = ""
	local awards = json["Persons"] or json["Titles"] or json["Books"] or json["Series"] or nil
	if awards == nil then return "" end
	for i,v in ipairs(awards) do
		res = res .. send_to_template( frame, template, v )
	end
	-- 
	--etc
	
	return res
end

--[[ @todo maybe - naming has changed so this won't work ]]--
p.getAwardEventFromPageName = function( page ) 
	local page = frame.args["page"] or nil
	if page == nil or page == "" then return end
	local slot = frame.args["slot"] or "ws-data"
	

	local awardEvent = nil
	-- get awardEvent on the basis of the page name
	if page ~= nil then
		local pageParts = mw.text.split( page, "/" )
		-- ??? remove last part ??
		table.remove( pageParts );
		--- ??
		awardEvent = table.concat( pageParts, "/" )
	end
	return awardEvent
end

return p