Module:Class/Book




Arthur C. Clarke / De verre Aarde / verre Aarde, De / 1990, 2ᵉdruk, A.W. Bruna & Zoon, Utrecht / 2ᵉdruk (1990), A.W. Bruna & Zoon, Utrecht

https://www.fandata.nl/Persoon/1608

Louis de Groof / Tim 2 / Tim 2 / 1975, Standaard Uitgeverij, Antwerpen/Amsterdam / (1975), Standaard Uitgeverij, Antwerpen/Amsterdam

Has publication info = (1975), Standaard Uitgeverij, Antwerpen/Amsterdam +

Has publication year = 1975

Has sort label = Tim 2 louis de groof 1975¶

Has sort label by author = Groof, louis de - tim 2¶


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

p.set = function( frame ) 
	local uitgeverijnr = frame.args.uitgeverijnr or ""
	local boekpubjaar = frame.args.boekpubjaar or ""
	local druk = frame.args.druk or ""
	local titleAddendum = p.createTitleAddendum( boekpubjaar, druk, uitgeverijnr, false )
	local titleAddendumVariant = p.createTitleAddendum( boekpubjaar, druk, uitgeverijnr, true )
	
	local titelnr = frame.args.titelnr or ""
	--TitelGew
	local titelGew = ""
	local titelBiblio = ""
	local schrijverNrs = ""
	local authorNames = ""
	if titelnr ~= "" then
		titelGew = mSlot.getValueFromTemplateData( "ws-page-props", titelnr, "Title", "TitelGew" )
		titelBiblio = mSlot.getValueFromTemplateData( "ws-page-props", titelnr, "Title", "TitelBiblio" )
		if titelBiblio == nil or titelBiblio == "" then titelBiblio = titelGew end
		schrijverNr = mSlot.getValueFromTemplateData( "ws-page-props", titelnr, "Title", "SchrijverNr" )
		mw.log( "schrijverNr: " .. schrijverNr )
		authorNames = p.getAuthorNames( schrijverNr )
		mw.log( "authorNames: " .. authorNames )
		-- + get author names of first two authors
	end


	return authorNames .. " / " .. titelGew .. " / " .. titelBiblio .. " / " .. titleAddendum .. " / " .. titleAddendumVariant
end

p.createTitleAddendum = function( boekpubjaar, druk, uitgeverijnr, variant )
	local str = ""
	local boekpubjaar = boekpubjaar or "?"
	if boekpubjaar == "" then boekpubjaar = "?" end

	local drukWeergave = ""
	if druk ~= "" then
		local drukN = tonumber(druk)
		if drukN == nil then
			drukWeergave =  "druk: " .. druk
		else
			drukWeergave =  druk .. "ᵉ" .. "druk"
		end
	end

	local uitgeverijnaam = ""
	if uitgeverijnr ~= "" then
		--local slotContent = mSlot.getSlotContent( uitgeverijnr, "ws-page-props", "Publisher" )
		uitgeverijnaam = mSlot.getValueFromTemplateData( "ws-page-props", uitgeverijnr, "Publisher", "Naam" )
	end

	-- concat
	if variant ~= "" and variant == true then
		str = drukWeergave .. " (" .. boekpubjaar .. ")"
		if uitgeverijnaam ~= "" then str = str .. ", " .. uitgeverijnaam end
	else
		str = boekpubjaar
		if drukWeergave ~= "" then str = str .. ", " .. drukWeergave end
		if uitgeverijnaam ~= "" then str = str .. ", " .. uitgeverijnaam end
	end

	return str
end

p.getAuthorNames = function( authors )
	if authors == "" or authors == nil then return "" end
	local authorTbl = mw.text.split( authors, "," )
	mw.log( "#authorTbl", #authorTbl )
	local nameTbl = {}
	for i,v in ipairs(authorTbl) do
		-- first two authors only
		if i == 1 or i == 2 then
			local naamGew = mSlot.getValueFromTemplateData( "ws-page-props", mw.text.trim(v), "Person", "NaamGew" )
			mw.log( "naamGew: " .. naamGew )
			table.insert( nameTbl, naamGew )
		end
	end
	return table.concat( nameTbl, ", ")
end

return p