Module:Musician Infobox: Difference between revisions

From NOISZ Wiki
(Created page with "local capiunto = require 'capiunto' local p = {} function p.main(frame) local args = frame:getParent().args local infobox = capiunto.create( { title = tostring(mw.title.getCurrentTitle()) } ) if args.image1 then infobox:addImage('200px', args.caption ) end local attributes = { { 'Website', args. website }, { 'Pronouns', args.pronouns }, { 'Active from', args.active_from } } local music = { { 'Spotify', args.spot...")
 
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
local args = frame:getParent().args
local args = frame:getParent().args
local infobox = capiunto.create( {
local infobox = capiunto.create( {
title = tostring(mw.title.getCurrentTitle())
title = string.gsub(tostring(mw.title.getCurrentTitle()),"Category:Songs featuring","")
     } )
     } )
if args.image1 then
if args.image1 then
Line 51: Line 51:
for _, row in ipairs(attributes) do
for _, row in ipairs(attributes) do
local label, value = row[1], row[2]
local label, value = row[1], row[2]
if value then
if value and value ~= '' then
           infobox:addRow(label, value)
           infobox:addRow(label, value)
end
end
Line 60: Line 60:
for _, row in ipairs(music) do
for _, row in ipairs(music) do
local label, value = row[1], row[2]
local label, value = row[1], row[2]
if value then
if value and value ~= '' then
           infobox:addRow(label, value)
           infobox:addRow(label, value)
end
end
Line 69: Line 69:
for _, row in ipairs(socials) do
for _, row in ipairs(socials) do
local label, value = row[1], row[2]
local label, value = row[1], row[2]
if value then
if value and value ~= '' then
           infobox:addRow(label, value)
           infobox:addRow(label, value)
end
end
Line 78: Line 78:
for _, row in ipairs(stores) do
for _, row in ipairs(stores) do
local label, value = row[1], row[2]
local label, value = row[1], row[2]
if value then
if value and value ~= '' then
           infobox:addRow(label, value)
           infobox:addRow(label, value)
end
end

Latest revision as of 10:41, 13 June 2025

Documentation for this module may be created at Module:Musician Infobox/doc

local capiunto = require 'capiunto'
local p = {}
function p.main(frame) 
	local args = frame:getParent().args
	local infobox = capiunto.create( {
		title = string.gsub(tostring(mw.title.getCurrentTitle()),"Category:Songs featuring","")
    	} )
	if args.image1 then
		infobox:addImage('[[File:' .. args.image1 .. '|200px]]', args.caption )
	end
	local attributes = 
	{
		{ 'Website', args. website },
		{ 'Pronouns', args.pronouns },
		{ 'Active from', args.active_from }
	}
	local music = 
	{
		{ 'Spotify', args.spotify },
		{ 'YouTube', args.youtube },
		{ 'Bandcamp', args.bandcamp },
		{ 'Soundcloud', args.soundcloud },
		{ 'Apple Music', args.apple_music },
		{ 'iTunes', args.itunes },
		{ 'Niconico', args.niconico }
	}
	local socials = 
	{
		{ 'Twitter', args.twitter},
		{ 'Bluesky', args.bluesky },
		{ 'Instagram', args.instagram },
		{ 'Facebook', args.facebook },
		{ 'Threads', args.threads },
		{ 'Twitch', args.twitch },
		{ 'TikTok', args.tiktok },
		{ 'Mastodon', args.mastodon },
		{ 'Tumblr', args.tumblr },
		{ 'Ameblo', args.ameblo },
		{ 'Newgrounds', args.newgrounds },
		{ 'about.me', args.aboutme },
		{ 'Blogspot', args.blogspot },
		{ 'Other', args.other }
	}
	local stores = 
	{
		{ 'Booth', args.booth },
		{ 'Fanbox', args.fanbox },
		{ 'Pixiv', args.pixiv }
	}
	if args.website or args.pronouns or args.active_from then
		for _, row in ipairs(attributes) do
			local label, value = row[1], row[2]
			if value and value ~= '' then
           		infobox:addRow(label, value)
			end
		end
	end
	if args.spotify or args.bandcamp or args.youtube or args.itunes or args.apple_music or args.niconico or args.soundcloud then
		infobox:addHeader( 'Music' )
		for _, row in ipairs(music) do
			local label, value = row[1], row[2]
			if value and value ~= '' then
           		infobox:addRow(label, value)
			end
		end
	end
	if args.twiter or args.bluesky or args.instagram or args.facebook or args.threads or args.twitch or args.tiktok or args.mastodon or args.tumblr or args.ameblo or args.newgrounds or args.aboutme or args.blogspot or args.other then
		infobox:addHeader( 'Socials' )
		for _, row in ipairs(socials) do
			local label, value = row[1], row[2]
			if value  and value ~= '' then
           		infobox:addRow(label, value)
			end
		end
	end
	if args.booth or args.fanbox or args.pixiv then
		infobox:addHeader( 'Stores' )
		for _, row in ipairs(stores) do
			local label, value = row[1], row[2]
			if value and value ~= '' then
           		infobox:addRow(label, value)
			end
		end
	end
	
    return infobox
end

return p