Module:JpgibertTest

 Documentation[créer] [purger]
-- Test Lua module for my own developments
-- author: jpgibert
local p = {}

function p.isNotEmpty(text)
	if text == nil then
		return false
	end
	return mw.text.trim(text) ~= ""
end

-- fonction permettant de générer un texte standardisé pour l'affichage
-- de la description d'un clip dans la vidéographie d'un artiste
-- paramètres :
-- * année (obligatoire)     : année de publication du clip
-- * titre (obligatoire)     : nom de la chanson
-- * album (optionnel)       : nom de l'album ou single... dont est tiré la chanson
-- * realisateur (optionnel) : nom du réalisateur du clip
-- * commentaire (optionnel) : informations complémentaires
function p.clip(frame)
	local year = frame.args[1]
	local title = frame.args[2]
	local album = frame.args[3]
	local director = frame.args[4]
	local comment = frame.args[5]
	
    local result = "* "
    if p.isNotEmpty(year) then
    	result = result .. string.format("[[%s en musique|%s]]", year, year)
    else
    	result = result .. "<'''année manquante'''>"
    end
    if p.isNotEmpty(title) then
    	result = result .. string.format(" : ''%s''", title)
    else
    	result = result .. " <'''titre manquant'''>";
    end
    if p.isNotEmpty(album) then
    	result = result .. string.format(", tiré de ''%s''", album)
    end
    if p.isNotEmpty(director) then
    	result = result .. string.format(", réalisé par [[%s]]", director)
    end
    if p.isNotEmpty(comment) then
	    result = result .. string.format(", %s", comment)
	end
    return result
end

return p