Module:NooSFere/Bac à sable

 Documentation[voir] [modifier] [historique] [purger]

Fonctionnement général modifier

Toutes les fonctions ont les mêmes paramètres, lorsqu'ils sont utiles à celui-ci, soit :

  • Pour tous :
    • id ou args[1] (sauf p.GPI qui prend année ou args[1])
    • nom, titre ou args[2] (sauf p.GPI qui prend catégorie ou args[2]), sinon le titre de la page courante est utilisé
    • texte
    • consulté le
    • sur
    • lien ou sans crochet
  • Suivant les modèles :
    • auteur ou args[3]
    • page
    • date ou année
    • publication
    • sous-page ou niveau
    • tri
    • éditeur
    • ancre
    • catégorie
    • prefix
  • Pour les modèles ayant une propriété wikidata et si le paramètre id n'est pas précisé, certaines données sont récupérées depuis wikidata via le paramètre entity ou pour la page courante (si ce paramètre n'est pas précisé explicitement) :

Utilisation modifier

Fonctions exportables :

Autres fonctions :

  • getId(args, property) – récupère l'identifiant à mettre dans l'url, depuis le paramètre id, args[1], ou wikidata via le paramètre property. Dans ce dernier cas la catégorie adéquate est ajouté.
  • isFromWikidata(args) – test si l'identifiant est récupéré depuis wikidata.
  • getNomTitre(args, fromwikidata) – récupère le nom ou le titre de l'url depuis les paramètres nom, titre, args[2], le label wikidata en fonction de fromwikidata, ou le titre de la page.
  • formatConsulteLe(consultele) – formate la date de consultation, si besoin avec Module:Wikidata.modeleDate.
  • getEditeur(args) – récupère l'éditeur depuis le paramètre éditeur ou depuis wikidata P123 (« publié par ») en fonction de fromwikidata (uniquement pour les instances de Q3331189 (« version, édition ou traduction »)).
  • getDate(args) – récupère la date de publication depuis les paramètres date, année ou depuis wikidata P577 (« date de publication ») en fonction de fromwikidata (uniquement pour les instances du paramètre instanceOf). formate si besoin la date avec Module:Wikidata.modeleDate.
  • getAuteur(args) – récupère l'auteur depuis les paramètres auteur, args[3] ou depuis wikidata P50 (« auteur ou autrice ») en fonction de fromwikidata (uniquement pour les instances du paramètre instanceOf). les résultats sont triés en fonction de P1545 (« rang dans la série »).

Modules externes et autres éléments dont ce module a besoin pour fonctionner :

  • Module:Wikidata.getClaims.
  • Module:Wikidata.getLabel.
  • Module:Wikidata.isInstance.
  • Module:Wikidata.formatStatements.
  • Module:Date.modeleDate.
  • mw.title.getCurrentTitle().text.
  • mw.wikibase.getEntityIdForCurrentPage().

Exemples modifier

Pour des exemples, voir les pages les différents modèles ci-dessus.

local p = {}

local wd = require 'Module:Wikidata/Bac à sable'
local mdate = require 'Module:Date/Bac à sable'
local urlNoosfere = "https://www.noosfere.org"
local defaultSur = "sur le site ''[[NooSFere]]''"

function validArg(args, arg1, arg2, arg3)
	if arg1 then
		if args[arg1] and args[arg1] ~= '' then
			return args[arg1]
		end
		if arg2 then
			if args[arg2] and args[arg2] ~= '' then
				return args[arg2]
			end
			if arg3 and args[arg3] and args[arg3] ~= '' then
				return args[arg3]
			end
		end
	end
	return nil
end

local function getId(args, property)
	local id = validArg(args, 'id', 1)
	
	if not id and property then
		local claims = wd.getClaims{entity = args.entity, property = property, numval = 1}
		
		if claims then
			for i, j in pairs(claims) do
				if j.mainsnak and j.mainsnak.snaktype == 'value' and j.mainsnak.datavalue then
					id = j.mainsnak.datavalue.value
					if mw.title.getCurrentTitle().namespace == 0 then
						id = id  .. '[[Catégorie:Page utilisant ' .. property .. ']]'
					end
				end
			end
		end
	end
	return id
end

local function isFromWikidata(args)
	if validArg(args, 'id', 1) then
		return false
	end
	return true
end

local function getNomTitre(args, fromwikidata)
	local nom = validArg(args, 'nom', 'titre', 2)
	
	if not nom and fromwikidata then
		local entity = args.entity
		if not entity then
           		entity = mw.wikibase.getEntityIdForCurrentPage()
      		end
		nom = wd.getLabel(entity)
	end
	return nom or mw.title.getCurrentTitle().text
end

local function formatConsulteLe(consultele)
	if consultele then
		if string.sub(consultele, 1, 5) ~= '<time' then
			consultele = mdate.modeleDate{consultele, nolinks=1}
		end
		return '<small style="line-height:1em;"> (consulté le ' .. consultele .. ')</small>'
	end
	return ''
end

local function getEditeur(args, fromwikidata)
	local editeur = validArg(args, "éditeur")

	if not editeur and fromwikidata then
		if wd.isInstance("Q3331189", {id=args.entity}, 2) then
			editeur = wd.formatStatements{entity = args.entity, property = 'P123', linkback = args.linkback == nil or args.linkback == "true"}
		end
	elseif editeur == "-" then
		editeur = nil
	end
	return editeur
end

local function getDate(args, fromwikidata, instanceOf)
	local date = validArg(args, "date", "année")

	if not date and fromwikidata and instanceOf then

		if wd.isInstance(instanceOf, {id=args.entity}, 3) then
			date = wd.formatStatements{entity = args.entity, property = 'P577', linkback = args.linkback == nil or args.linkback == "true"}
		end
	elseif date == "-" then
		date = nil
	elseif date and string.sub(date, 1, 5) ~= '<time' then
		date = mdate.modeleDate{date, nolinks=1}
	end
	return date
end

local function getAuteur(args, fromwikidata, instanceOf)
	local auteur = validArg(args, 'auteur', 3)

	if not auteur and fromwikidata and instanceOf then
		if wd.isInstance(instanceOf, {id=args.entity}, 3) then
			auteur = wd.formatStatements{entity = args.entity, property = 'P50', sorttype = 'P1545', linkback = args.linkback == nil or args.linkback == "true"}
		end
	elseif auteur == "-" then
		auteur = nil
	end
	return auteur
end

function p.article( frame )
	local url = urlNoosfere .. "/articles/article.asp?numarticle="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args)
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local titre = getNomTitre(args, false)
	local texte = validArg(args, 'texte')
	local auteur = getAuteur(args, false)
	local consultele = validArg(args, 'consulté le')
	local page = validArg(args, 'page')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	local date = getDate(args, false)
	local publication = validArg(args, 'publication')
	
	url  = url .. id
	if page then
		url = url .. '&numpage=' .. page
	end
	
	if lien then
		return url
	elseif titre == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = '«&nbsp;' .. '[' .. url .. ' ' .. titre .. ']' .. '&nbsp;»'
	end
	
	if auteur then
		rendu = rendu .. ", article de " .. auteur
	end
	
	if publication or date then
		rendu = rendu .. '<small style="line-height:1em;"> ('
		if publication then
			rendu = rendu .. publication
		end
		if date then
			if publication then
				rendu = rendu .. ', '
			end
			rendu = rendu .. date
		end
		rendu = rendu .. ')</small>'
	end
	
	if sur ~= '-' then
		if auteur then
			rendu = rendu .. ","
		end	
		rendu = rendu .. " " .. sur
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.auteur( frame )
	local urlAuteur = urlNoosfere .. "/livres/auteur.asp?numauteur="
	local urlCritiques = urlNoosfere .. "/livres/critsigndetail.asp?numauteur="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args, 'P5570')
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local isFromWikidata = isFromWikidata(args)
	local nom = validArg(args, 'texte') or getNomTitre(args, isFromWikidata)
	local consultele = validArg(args, 'consulté le')
	local souspage = validArg(args, 'sous-page', 'Niveau', 'niveau')
	local tri = validArg(args, 'tri', 'Tri')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	local url
	
	if souspage == 'critiques' then
		url = urlCritiques .. id
		nom = 'Critiques par ' .. nom
	else 
		url  = urlAuteur .. id
		if souspage then
			url = url .. '&Niveau=' .. souspage 
		end
	end
	if tri then
		url = url .. '&tri=' .. tri 
	end
	
	if lien then
		return url
	elseif nom == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu = '[' .. url .. ' ' .. nom .. ']'
	
	if sur ~= '-' then	
		rendu = rendu .. " " .. sur
	end
	
	if (souspage and souspage ~= "critiques") or tri then
		rendu = rendu .. " ''("
		if souspage then
			local cases = {
				livres = "Livres",
				Nouvelles = "Autres fictions",
				revues = "Articles/critiques",
				illus = "Illustrations",
				bio = "Biographie",
				critiques = "",
			}
			local niveau = cases[souspage] or souspage
			rendu = rendu .. niveau
		end
		if tri then
			local cases = {
				alpha = "Titre",
				chronoVF = "Date VF",
				chronoVO = "Date VO",
				editeur = "Éditeur",
				chrono = "Date",
				auteur = "Auteur",
			}
			local lableTri = cases[tri] or tri
			if souspage and souspage ~= "critiques" then
				rendu = rendu .. ', '
			end
			rendu = rendu .. lableTri
		end
		rendu = rendu .. ")''"
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.collection( frame )
	local url = urlNoosfere .. "/livres/collection.asp?numcollection="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args)
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local nom = validArg(args, 'nom', 2) or mw.title.getCurrentTitle().text
	local titre = validArg(args, 'titre', 'texte')
	local prefix = validArg(args, 'prefix') or "Fiche de la collection"
	local souspage = validArg(args, 'sous-page', 'Niveau', 'niveau')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if souspage then
		url = url .. '&Niveau=' .. souspage 
	end
	
	if lien then
		return url
	elseif nom == '-' or titre == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu
	if titre then
		rendu = '[' .. url .. ' ' .. titre .. ']'
	else
		rendu = '«&nbsp;' .. '[' .. url .. ' ' .. nom .. ']' .. '&nbsp;»'
		if prefix ~= '-' then
			rendu = prefix .. ' ' .. rendu
		end
	end

	local editeur = getEditeur(args, isFromWikidata)
	if editeur then
		rendu = rendu .. '<small style="line-height:1em;"> (' .. editeur .. ')</small>'
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	if souspage then
		local cases = {
			collection = "livres",
			autres = "livres et rééditions",
			couv = "couvertures",
		}
		local niveau = cases[souspage]
		if niveau then
			rendu = rendu .. " ''(" .. niveau .. ")''"
		end
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.editeur( frame )
	local url = urlNoosfere .. "/livres/editeur.asp?numediteur="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args)
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local nom = validArg(args, 'nom', 2) or mw.title.getCurrentTitle().text
	local titre = validArg(args, 'titre', 'texte')
	local prefix = validArg(args, 'prefix') or "Fiche de l'éditeur"
	local souspage = validArg(args, 'sous-page', 'Niveau', 'niveau')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if souspage then
		url = url .. '&Niveau=' .. souspage 
	end
	
	if lien then
		return url
	elseif nom == '-' or titre == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu
	if titre then
		rendu = '[' .. url .. ' ' .. titre .. ']'
	else
		rendu = "«&nbsp;" .. '[' .. url .. ' ' .. nom .. ']' .. '&nbsp;»'
		if prefix ~= '-' then
			rendu = prefix .. ' ' .. rendu
		end
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	if souspage then
		local cases = {
			collections = "Collections",
			tout = "Toutes les parutions",
		}
		local niveau = cases[souspage]
		if niveau then
			rendu = rendu .. " ''(" .. niveau .. ")''"
		end
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.edition( frame )
	local url = urlNoosfere .. "/livres/niourf.asp?numlivre="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args, 'P6901')
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local isFromWikidata = isFromWikidata(args)
	local titre = getNomTitre(args, isFromWikidata)
	local texte = validArg(args, 'texte')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	local ancre = validArg(args, 'ancre')
	
	url  = url .. id
	
	if ancre then
		url  = url  .. "#" .. ancre
	end
	
	if lien then
		return url
	elseif titre == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = "«&nbsp;" .. '[' .. url .. ' ' .. titre .. ']' .. '&nbsp;»'
	end
	
	local auteur = getAuteur(args, isFromWikidata, "Q3331189")
	if auteur then
		rendu = auteur .. ", " .. rendu
	end
	
	local editeur = getEditeur(args, isFromWikidata)
	local date = getDate(args, isFromWikidata, "Q3331189")
	if editeur or date then
		rendu = rendu .. '<small style="line-height:1em;"> ('
		if editeur then
			rendu = rendu .. editeur
		end
		if date then
			if editeur then
				rendu = rendu .. ', '
			end
			rendu = rendu .. date
		end
		rendu = rendu .. ')</small>'
	end
	
	if sur ~= '-' then	
		rendu = rendu .. " " .. sur
	end
	
	if ancre then
		local labelAncre 
		if ancre == "Résumes" then
			labelAncre = "Quatrième de couverture"
		elseif ancre == "ListeRef" then
			labelAncre = "Citations thématiques"
		elseif ancre == "CitationListes" then
			labelAncre = "Citations"
		elseif ancre == "Adaptations" then
			labelAncre = "Adaptations"
		elseif ancre == "AutresCritique" then
			labelAncre = "Critiques"
		elseif ancre == "Critique" then
			labelAncre = "Critiques"
		else
			labelAncre = ancre
		end
		rendu = rendu .. " ''(" .. labelAncre .. ")''"
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.GPI( frame )
	local url = "https://gpi.noosfere.org/"
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local annee = validArg(args, "année", 1)
	if annee == '' then
		annee = nil
	end
	local categorie = validArg(args, "catégorie", 2)
	if categorie == '' then
		categorie = nil
	end
	if not categorie and annee then
		local a = tonumber(annee)
		if not a then
			categorie = annee
			annee = nil
		end
	end
	if not annee and not categorie then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	
	local texte = validArg(args, 'texte', 'titre', 'nom')
	local prefix = validArg(args, 'prefix') or "[[Grand prix de l'Imaginaire|GPI]] —"
	local sur = validArg(args, 'sur') or "sur ''gpi.noosfere.org''"
	local consultele = validArg(args, 'consulté le')
	local lien = validArg(args, 'lien', 'sans crochet')
	
	if annee then
		url  = url .. 'gpi-' .. annee .. '/'
	else
		url  = url .. categorie .. '/'
	end
	
	if lien then
		return url
	elseif texte == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		if annee then
			rendu = '[' .. url .. ' Palmarès ' .. annee .. ']'
		else
			local cat
			if categorie == "roman-francophone" then
				cat = "Roman francophone"
			elseif categorie == "roman-etranger" then
				cat = "Roman étranger"
			elseif categorie == "nouvelle-francophone" then
				cat = "Nouvelle francophone"
			elseif categorie == "nouvelle-etrangere" then
				cat = "Nouvelle étrangère"
			elseif categorie == "roman-jeunesse-francophone" then
				cat = "Roman jeunesse francophone"
			elseif categorie == "roman-jeunesse-etranger" then
				cat = "Roman jeunesse étranger"
			elseif categorie == "traduction" then
				cat = "Traduction"
			elseif categorie == "graphisme" then
				cat = "Graphisme"
			elseif categorie == "bd" then
				cat = "BD"
			elseif categorie == "manga" then
				cat = "Manga"
			elseif categorie == "essai" then
				cat = "Essai"
			elseif categorie == "prix-special" then
				cat = "Prix spécial"
			elseif categorie == "prix-europeen" then
				cat = "Prix européen"
			else
				cat = categorie
			end
			rendu = '[' .. url .. ' Palmarès par catégories — ' .. cat.. ']'
		end
	end
	
	if prefix ~= '-' then
		rendu = prefix .. " " .. rendu
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.livre( frame )
	local url = urlNoosfere .. "/livres/EditionsLivre.asp?numitem="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args, 'P5571')
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local isFromWikidata = isFromWikidata(args)
	local titre = getNomTitre(args, isFromWikidata)
	local texte = validArg(args, 'texte')
	local tri = validArg(args, 'tri', 'Tri')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if tri then
		url = url .. '&Tri=' .. tri 
	end
	
	if lien then
		return url
	elseif titre == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = "«&nbsp;" .. '[' .. url .. ' ' .. titre .. ']' .. '&nbsp;»'
	end
	
	local auteur = getAuteur(args, isFromWikidata, "Q47461344")
	if auteur then
		rendu = auteur .. ", " .. rendu
	end
	
	local date = getDate(args, isFromWikidata, "Q47461344")
	if date then
		rendu = rendu .. '<small style="line-height:1em;"> (' .. date .. ')</small>'
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	if tri then
		local lableTri
		if tri == "1" then
			lableTri = "par nom d'éditeur"
		elseif tri == "2" then
			lableTri = "chronologique inversé"
		elseif tri == "3" then
			lableTri = "chronologique"
		else
			lableTri = tri 
		end
		if lableTri then
			rendu = rendu .. " ''(" .. lableTri .. ")''"
		end
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.oeuvre( frame )
	local url = urlNoosfere .. "/livres/EditionsLivre.asp?ID_ItemSommaire="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args, 'P6221')
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local isFromWikidata = isFromWikidata(args)
	local titre = getNomTitre(args, isFromWikidata)
	local texte = validArg(args, 'texte')
	local tri = validArg(args, 'tri', 'Tri')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if tri then
		url = url .. '&Tri=' .. tri 
	end
	
	if lien then
		return url
	elseif titre == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = "«&nbsp;" .. '[' .. url .. ' ' .. titre .. ']' .. '&nbsp;»'
	end
	
	local auteur = getAuteur(args, isFromWikidata, "Q47461344")
	if auteur then
		rendu = auteur .. ", " .. rendu
	end
	
	local date = getDate(args, isFromWikidata, "Q7725634")
	if date then
		rendu = rendu .. '<small style="line-height:1em;"> (' .. date .. ')</small>'
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	if tri then
		local lableTri
		if tri == "1" then
			lableTri = "par nom d'éditeur"
		elseif tri == "2" then
			lableTri = "chronologique inversé"
		elseif tri == "3" then
			lableTri = "chronologique"
		else
			lableTri = tri 
		end
		if lableTri then
			rendu = rendu .. " ''(" .. lableTri .. ")''"
		end
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.prix( frame )
	local url = urlNoosfere .. "/livres/prix.asp?numprix="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args)
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local nom = getNomTitre(args, false)
	local texte = validArg(args, 'texte')
	local annee = validArg(args, 'année')
	local tri = validArg(args, 'tri', 'Tri')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if tri then
		url = url .. '&tri=' .. tri 
	end
	
	if annee then
		url = url .. '#A' .. annee
	end
	
	if lien then
		return url
	elseif nom == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	local rendu
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = "Fiche du prix «&nbsp;" .. '[' .. url .. ' ' .. nom .. ']' .. '&nbsp;»'
	end
	
	if tri or annee  then
		rendu = rendu .. " ''("
		if tri then
			local lableTri
			if tri == "an" then
				lableTri = "par année"
			elseif tri == "cat" then
				lableTri = "par catégorie"
			else
				lableTri = tri 
			end
			rendu = rendu .. lableTri
		end
		if annee then
			if tri then
				rendu = rendu .. ', '
			end
			rendu = rendu .. annee
		end
		rendu = rendu .. ")''"
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

function p.serie( frame )
	local url = urlNoosfere .. "/livres/serie.asp?numserie="
	
	local parentFrame = frame:getParent()
	local args = parentFrame.args
	
	local id = getId(args, 'P5792')
	if not id then
		return '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée]]'
	end
	local isFromWikidata = isFromWikidata(args)
	local nom = getNomTitre(args, isFromWikidata)
	local texte = validArg(args, 'texte')
	local souspage = validArg(args, 'sous-page', 'Niveau', 'niveau')
	local consultele = validArg(args, 'consulté le')
	local sur = validArg(args, 'sur') or defaultSur
	local lien = validArg(args, 'lien', 'sans crochet')
	
	url  = url .. id
	
	if souspage then
		url = url .. '&Niveau=' .. souspage
	end
	
	if lien then
		return url
	elseif nom == '-' or texte == '-' then
		return '[' .. url .. ']'
	end
	
	if texte then
		rendu = '[' .. url .. ' ' .. texte .. ']'
	else
		rendu = "«&nbsp;" .. '[' .. url .. ' ' .. nom .. ']' .. '&nbsp;»'
	end
	
	local auteur = getAuteur(args, isFromWikidata, "Q17489659")
	if auteur then
		rendu = auteur .. ", " .. rendu
	end
	
	local date = getDate(args, isFromWikidata, "Q17489659")
	if date then
		rendu = rendu .. '<small style="line-height:1em;"> (' .. date .. ')</small>'
	end
	
	if sur ~= '-' then
		rendu = rendu .. " " .. sur
	end
	
	if souspage then
		local cases = {
			simple = "affichage simple",
			complet = "affichage complet",
		}
		local niveau = cases[souspage]
		if niveau then
			rendu = rendu .. " ''(" .. niveau .. ")''"
		end
	end
	
	rendu = rendu .. formatConsulteLe(consultele)
	
	return rendu
end

return p