Info Istruzioni per l'uso
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Pagebanner/man (modifica · cronologia)
Sandbox: Modulo:Pagebanner/sandbox (modifica · cronologia) · Test: Modulo:Pagebanner/test (modifica · cronologia · Esegui)

Vedi anche


--[[ 	Source script:	https://it.wikivoyage.org/wiki/Modulo:Pagebanner 	Maintainer:		Andyrom75  	Lazy loads: 	require('Modulo:Approvata').approvata ]] local countryData = require( 'Module:CountryData' )._countryData2HTML local gpx = require( 'Module:Indicatore GPX' ).gpx local WDBannerFunc = require( 'Module:Wikibase' ).banner  local function _isDefined(s) 	return s ~= '' and s end  local function _initMontlyDest( destAnno, page, frame) 	--preparo il percorso della pagina in ogni caso 	local path = tostring(page) .. '/' .. tostring(destAnno) 	--se l'anno non è definito ritorno nil, altrimenti la pagina specifica qualora l'anno è quello corrente o meno 	return _isDefined( destAnno ) and ( 		--Destinazione dell'anno in corso 		(destAnno == os.date( "%Y" )) and page or 		--Destinazione dell'anno "destAnno" 		(mw.title.new( path ).exists == true) and path 		) or nil end  local function _pagebanner(frame) 	local args = frame.args 	local PBargs={} 	local WDBanner = _isDefined( WDBannerFunc() ) 	local TplBanner = _isDefined( args[1] ) 	PBargs[1] = TplBanner or WDBanner or 'Pagebanner default.jpg' 	PBargs.tooltip = _isDefined( args.descrizione ) or _isDefined( args.caption ) or nil 	PBargs.pgname = _isDefined( args.pgname ) or nil 	PBargs.origin = _isDefined( args.origin ) or nil 	PBargs["icon-unesco"] = _isDefined( args.unesco ) and (mw.ustring.lower( args.unesco ) == 'sì') and "Patrimoni mondiali dell'umanità" or nil 	PBargs["icon-star"] = _isDefined( args.vetrina ) and (mw.ustring.lower( args.vetrina ) == 'sì') and 'Wikivoyage:Vetrina' or nil 	PBargs["icon-otbp"] = _initMontlyDest( args.fsb, 'Wikivoyage:Destinazione fuori dal sentiero battuto', frame) 	PBargs["icon-dotm"] = _initMontlyDest( args.ddm, 'Wikivoyage:Destinazione del mese', frame) --[[ icon-ftt=Previous_Featured_travel_topics - NON IMPLEMENTATO 	PBargs["icon-ftt"] = _initMontlyDest( args.ftt, 'Wikivoyage:XXX', frame) ]] 	local disambigPage = mw.title.getCurrentTitle().text .. ' (disambigua)' 	PBargs["icon-disambig"] = _isDefined( args.disambig ) or --Per altri luoghi con lo stesso nome, si veda args.disambig 		--Per altri luoghi con lo stesso nome, si veda disambigPage 		( (mw.title.new( disambigPage ).exists == true) and disambigPage ) or nil 	PBargs.toc = ( tostring(args.notoc) == 'true') and 'no' or 'yes' 	 	local output = (countryData() or '') .. (gpx() or '') 	if TplBanner then 		if mw.title.getCurrentTitle().namespace == 0 then 			output = output .. '[[Categoria:Articoli con banner]]' 		else 			output = output .. '[[Categoria:Pagine con banner]]' 		end 		local WDBannerAnchor = WDBanner and mw.uri.anchorEncode( WDBanner ) 		local TplBannerAnchor = TplBanner and mw.uri.anchorEncode( TplBanner ) 		local acceptedDifferentBanner = { 			['none'] = 1, -- esplicita richiesta di assenza di banner 			['Disambiguation banner1.jpg'] = 1, --banner delle disambigue 			['Welcome banner.jpg'] = 1, --banner dei frasari 			['Generic flying banner.jpg'] = 1, --banner delle liste di aeroporti nazionali 			['UNESCO page banner.jpg'] = 1, --banner delle liste di patrimoni UNESCO 		}  		if (TplBannerAnchor ~= WDBannerAnchor) and (not acceptedDifferentBanner[TplBanner]) and (mw.title.getCurrentTitle().namespace == 0) then 			output = output .. '[[Categoria:Banner diversi da Wikidata]]' 		end 	else 		if mw.title.getCurrentTitle().namespace ~= 2 then 			output = output .. '[[Categoria:Banner senza immagine]]' 		end 		if WDBanner then 			output = output .. '[[Categoria:Banner da Wikidata]]' 		end 	end 	if (args.ddm and (mw.ustring.lower( args.ddm ) == 'approvata')) or (args.fsb and (mw.ustring.lower( args.fsb ) == 'approvata')) then 		output = output .. require('Modulo:Approvata').approvata{args={ddm=args.ddm, fsb=args.fsb}} 	end 	output = output .. frame:callParserFunction( 'PAGEBANNER', PBargs )     return output end  --Interfacce del modulo local p = {}  function p.pagebannerTemplate(frame) 	return _pagebanner(frame:getParent()) end  function p.pagebannerInvoke(frame) 	return _pagebanner(frame) end  function p.pagebannerModule(frame) 	Cframe = mw.getCurrentFrame() 	Cframe.args = frame.args 	return _pagebanner(Cframe) end  --Ricordisamoa function that given an article name, it returns the file name of its banner  function p.from_page(frame)     return select( 3, string.find( mw.title.new( frame.args.title or frame.args[1] ):getContent(), '|%s*[Bb]anner%s*=%s*([^\n]*%S)%s*\n' ) ) end  --Winm b test function that given an article name, it returns the file name of its banner without extension function p.nome(frame)     return select( 3, string.find( mw.title.new( frame.args.title or frame.args[1] ):getContent(), '|%s*[Bb]anner%s*=%s*([^\n]*(%a*))%p%a*%s*\n' ) ) end  return p