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 35: Regel 35:


p.set = function(frame)
p.set = function(frame)
local page = frame.args.fullpagename or nil
local page = frame.args.page or nil
local slot = frame.args.slot or "ws-page-props"
local slot = frame.args.slot or "ws-page-props"


Regel 64: Regel 64:
local initial = p.getUppercaseInitial( titleBiblioFlattened )
local initial = p.getUppercaseInitial( titleBiblioFlattened )


-- author name string
local authors = {}
local authorNameStr = p.buildAuthorNameString( SchrijverNr )
if SchrijverNr ~= nil then
authors = mw.text.split( SchrijverNr, "," )
end
local authorNameTbl = p.buildAuthorNameTbl( authors )
local authorNameStr = p.formatAuthorNameStr( #authors, authorNameTbl )


-- set
-- set
Regel 94: Regel 98:


--[[
--[[
Create table with names for no more than two authors
@SchrijverNr string|nil - table of author pages
@SchrijverNr string|nil - table of author pages
@return string
@return table
]]--
]]--
p.buildAuthorNameString = function( SchrijverNr )
p.buildAuthorNameTbl = function( authors )
if SchrijverNr == nil then
if authors == nil or #authors == 0 then
return ""
return {}
end
end
local authors = mw.text.split( SchrijverNr, "," )
 
local firstAuthor = authors[1]
local res = {}
local firstAuthorNaamGew = p.getValueFromTemplateParam( firstAuthor, "Person", "NaamGew" )
res[1] = {
local firstAuthorNaamBiblio = p.getValueFromTemplateParam( firstAuthor, "Person", "NaamBiblio" )
["page"] = authors[1],
local secondAuthor = nil
["NaamGew"] = p.getValueFromTemplateParam( authors[1], "Person", "NaamGew" ) or "",
["NaamBiblio"] = p.getValueFromTemplateParam( authors[1], "Person", "NaamBiblio" ) or ""
}
if authors[2] ~= nil then
if authors[2] ~= nil then
secondAuthor = authors[2];
res[2] = {
secondAuthorNaamGew = p.getValueFromTemplateParam( secondAuthor, "Person", "NaamGew" )
["page"] = authors[2],
secondAuthorNaamBiblio = p.getValueFromTemplateParam( secondAuthor, "Person", "NaamBiblio" )
["NaamGew"] = p.getValueFromTemplateParam( authors[2], "Person", "NaamGew" ) or "",
["NaamBiblio"] = p.getValueFromTemplateParam( authors[2], "Person", "NaamBiblio" ) or ""
}
end
end
return res
end
--[[
@authorCount int - total number of authors
@authors table - one or two authors
]]--
p.formatAuthorNameString = function( authorCount, authors )
local authorNameStr = ""
local authorNameStr = ""
if ( #authors == 1 ) then
if ( authorCount == 0 ) then
authorNameStr = firstAuthorNaamGew
return ""
elseif ( #authors == 2 ) then
elseif ( authorCount == 1 ) then
authorNameStr = firstAuthorNaamGew .. " & " .. secondAuthorNaamGew
authorNameStr = authors[1]["NaamGew"]
elseif ( #authors > 2 ) then
elseif ( authorCount == 2 ) then
authorNameStr = firstAuthorNaamGew .. " & " .. secondAuthorNaamGew .. ", e.a."
authorNameStr = authors[1]["NaamGew"] .. " & " .. authors[2]["NaamGew"]
elseif ( authorCount > 2 ) then
authorNameStr = authors[1]["NaamGew"] .. " & " .. authors[2]["NaamGew"] .. ", e.a."
end
end
return authorNameStr
return authorNameStr
end
--[[
titleBiblioFlattened
@title 'flattened' title
]]--
p.getSortkeyByTitleAndAuthor = function( title, firstAuthorName )
local firstAuthorName = ""
local str = title .. " - " .. firstAuthorName
-- {{lc:{{#var:@titelbiblio}} - {{#var:@naamgew}} }}
-- string.lowercase( )
end
end



Versie van 30 jul 2025 13:20

Documentatie voor deze module kan aangemaakt worden op de volgende pagina: Module:Title/SMW/doc

--[[

Module for taking and processing parameters for set in Template:Title
Work in progress

{{#invoke:Title/SMW |set
|page={{FULLPAGENAME}}
|slot=ws-page-props

|ID={{{ID|}}}
|TitelBiblio={{{TitelBiblio|}}}
|TitelGew={{{TitelGew|}}}
|OrigTitel={{{OrigTitel|}}}
|SchrijverNr={{{SchrijverNr|}}}
|Type={{{Type|}}}
|Titelreeks={{{Titelreeks|}}}
|Reeks={{{Reeks|}}}
|ReeksNr={{{ReeksNr|}}}
|Behoord={{{Behoord|}}}
|Soort={{{Soort|}}}
|Wereld={{{Wereld|}}}
|Medium vorm={{{Medium vorm|}}}
|ZieOokBij={{{ZieOokBij|}}}
|subcategorie={{{subcategorie|}}}
|KInhoud={{{KInhoud|}}}
|GUID={{{GUID|}}}
|Verwijderd={{{Verwijderd|}}}
|Opmerking={{{Opmerking|}}}
|Aantekening={{{Aantekening|}}}
}}

]]--

local p = {}

p.set = function(frame)
	local page = frame.args.page or nil
	local slot = frame.args.slot or "ws-page-props"

	-- Wiki template argumentsa
	local ID = frame.args.ID or nil
	local TitelBiblio = frame.args.TitelBiblio or nil
	local TitelGew = frame.args.TitelGew or nil
	local OrigTitel = frame.args.OrigTitel or nil
	local SchrijverNr = frame.args.SchrijverNr or nil
	local Type = frame.args.Type or nil
	local Titelreeks = frame.args.Titelreeks or nil
	local Reeks = frame.args.Reeks or nil
	local ReeksNr = frame.args.ReeksNr or nil
	local Behoord = frame.args.Behoord or nil
	local Soort = frame.args.Soort or nil
	local Wereld = frame.args.Wereld or nil
	local Mediumvorm = frame.args["Medium vorm"] or nil
	local ZieOokBij = frame.args.ZieOokBij or nil
	local subcategorie = frame.args.subcategorie or nil
	local KInhoud = frame.args.KInhoud or nil
	local GUID = frame.args.GUID or nil
	local Verwijderd = frame.args.Verwijderd or nil
	local Opmerking = frame.args.Opmerking or nil
	local Aantekening = frame.args.Aantekening or nil

	-- processing
	local titleBiblioFlattened = p.flattenBibliographicTitle( TitelBiblio )
	local initial = p.getUppercaseInitial( titleBiblioFlattened )

	local authors = {}
	if SchrijverNr ~= nil then 
		authors = mw.text.split( SchrijverNr, "," )
	end
	local authorNameTbl = p.buildAuthorNameTbl( authors )
	local authorNameStr = p.formatAuthorNameStr( #authors, authorNameTbl )

	-- set
	local set = {}
	-- Dutch-language label
	set["Klasse"] = "Titel"
	set["Has ID"] = ID
	set["Title"] = TitelGew .. " - ..."

	if mw.smw then
		local setResult = mw.smw.set( set )
	end
end

p.flattenBibliographicTitle = function( titelBiblio )
	-- {{Strip title for sorting|{{#sub:{{{TitelBiblio|}}}|0|75}} }}
	-- {{#sub:{{{TitelBiblio|}}}|0|75}} 
	local subbed = string.sub( titelBiblio, 1, 75 )
	-- todo use Format for sorting module instead
	local stripped = frame:expandTemplate{ title = 'Strip title for sorting', args = { subbed } }
	return stripped
end

p.getUppercaseInitial = function( str )
	local initial = string.sub( str, 1, 1 )
	return string.upper(initial)
end

--[[
Create table with names for no more than two authors
@SchrijverNr string|nil - table of author pages
@return table
]]--
p.buildAuthorNameTbl = function( authors )
	if authors == nil  or #authors == 0 then
		return {}
	end

	local res = {}
	res[1] = {
		["page"] = authors[1],
		["NaamGew"] = p.getValueFromTemplateParam( authors[1], "Person", "NaamGew" ) or "",
		["NaamBiblio"] = p.getValueFromTemplateParam( authors[1], "Person", "NaamBiblio" ) or ""
	}
	
	if authors[2] ~= nil then
		res[2] = {
			["page"] = authors[2],
			["NaamGew"] = p.getValueFromTemplateParam( authors[2], "Person", "NaamGew" ) or "",
			["NaamBiblio"] = p.getValueFromTemplateParam( authors[2], "Person", "NaamBiblio" ) or ""
		}
	end

	return res
end

--[[
@authorCount int - total number of authors
@authors table - one or two authors
]]--
p.formatAuthorNameString = function( authorCount, authors ) 
	local authorNameStr = ""
	if ( authorCount == 0 ) then
		return ""
	elseif ( authorCount == 1 ) then
		authorNameStr = authors[1]["NaamGew"]
	elseif ( authorCount == 2 ) then
		authorNameStr =  authors[1]["NaamGew"] .. " & " .. authors[2]["NaamGew"]
	elseif ( authorCount > 2 ) then
		authorNameStr =  authors[1]["NaamGew"] .. " & " ..  authors[2]["NaamGew"] .. ", e.a."
	end
	return authorNameStr
end

--[[
titleBiblioFlattened
@title 'flattened' title
]]--
p.getSortkeyByTitleAndAuthor = function( title, firstAuthorName )
	local firstAuthorName = ""
	local str = title .. " - " .. firstAuthorName
	-- {{lc:{{#var:@titelbiblio}} - {{#var:@naamgew}} }} 
	-- string.lowercase( )
end

p.getValueFromTemplateParam = function( pagename, templateName, templateParam )
	local slotContent = p.getSlotContent( pagename, "ws-page-props", templateName )
	if slotContent == nil or slotContent[1] == nil or slotContent[1][templateParam] == nil then
		mw.log( "No value retrieved from page. Template param: " .. templateParam )
		return ""
	end
	return slotContent[1][templateParam]
end

return p