
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Quickfooter/man (modifica · cronologia)
Sandbox: Modulo:Quickfooter/sandbox (modifica · cronologia) · Test: Modulo:Quickfooter/test (modifica · cronologia · Esegui)
Vedi anche
- Template:Quickfooter
- Module:Wikibase
- Modulo:Interprogetto
- Modulo:Indicatore GPX
- Modulo:NS0Cat
- Modulo:Livello
--[[ Source script: https://it.wikivoyage.org/wiki/Modulo:Quickfooter Maintainers: Andyrom75, Nastoshka Lazy loads: require( 'Module:Indicatore GPX' ).gpx ]] local Wikibase = require( 'Modulo:Wikibase' ) local interprogetto = require( 'Modulo:Interprogetto' ).interprogetto local NS0Cat = require( 'Modulo:NS0Cat' ).NS0CatVal local livello = require( 'Modulo:Livello' ).livello local IsInArticle = '' local function _isDefined(s) return s ~= '' and s end local function _has_value (tab, val) for index, value in ipairs(tab) do if value == val then return true end end return false end local function _initTable (tab) local tab2 = {} for key, value in pairs(tab) do tab2[key] = _isDefined( value and mw.text.trim( value) ) end return tab2 end -- Controlla l'esistenza degli articoli in NS:0 per costruire il breadcrumb local function _ExistIsInCatVal (value, NoCat) if value and (mw.title.new( value ).exists == true) then IsInArticle = value return NS0Cat( value ) else return NoCat and '' or NS0Cat( value ) end end -- Controlla l'esistenza di specifiche categorie per aggiungerle all'articolo -- **NOTA** Attualmente non usata: può essere cancellata local function _ExistCatVal (value) if value and (mw.title.new( 'Categoria:'..value ).exists == true) then return NS0Cat( value ) end return '' end local function _IsInVal (value) if value then IsInArticle = value end return '' end local function _IsInCatVal (value) if value then IsInArticle = value return NS0Cat( value ) end return '' end local function _Quickfooter(frame) local args = _initTable( frame.args ) local output = '' --Creo la sezione altri progetti con i parametri presi da Wikidata o passati dall'articolo local IPargs = { nobarra = 's', w = _isDefined( args.w ) or _isDefined( Wikibase.itwikilink() ) or nil, s = _isDefined( args.s ) or _isDefined( Wikibase.itwikisourcelink() ) or nil, q = _isDefined( args.q ) or _isDefined( Wikibase.itwikiquotelink() ) or nil, n = _isDefined( args.n ) or _isDefined( Wikibase.itwikinewslink() ) or nil, b = _isDefined( args.b ) or _isDefined( Wikibase.itwikibookslink() ) or nil, commons = _isDefined( args.commons ) or _isDefined( Wikibase.commonslink() ) or nil } if IPargs.w or IPargs.s or IPargs.q or IPargs.n or IPargs.b or IPargs.commons then output = output .. '== Altri progetti ==\n<div class="interprogetto">' .. interprogetto(IPargs) .. '</div>' else output = output .. '<br />' end --Inserisco il cassetto delle nazioni negli articoli continentali if args[1] == 'Continente' then if mw.title.new( 'Template:' .. mw.title.getCurrentTitle().text ).exists == true then output = output .. '<br style="clear: both;" />' .. frame:expandTemplate{ title=mw.title.getCurrentTitle().text } end output = output .. NS0Cat('Continente') --Gestisco le poche casistiche delle sotto-regioni continentali elseif args[1] == 'Regione continentale' then output = output .. _IsInCatVal(args['Continente']) .. _IsInCatVal(args['Continente2']) .. _IsInCatVal(args['Regione continentale']) .. NS0Cat('Regione continentale') .. NS0Cat('Regione') --Gestisco gli articoli di tipo Stato elseif args[1] == 'Stato' then output = output .. '<br style="clear: both;" />' if args.Continente then output = output .. ((mw.title.new( 'Template:' .. args.Continente ).exists == true) and frame:expandTemplate{ title=args.Continente } or '') .. _IsInCatVal( args.Continente ) end if args.Continente2 then output = output .. ((mw.title.new( 'Template:' .. args.Continente2 ).exists == true) and frame:expandTemplate{ title=args.Continente2 } or '') .. _IsInCatVal( args.Continente2 ) end output = output .. _IsInCatVal(args['Regione continentale']) .. _IsInCatVal(args['Regione continentale2']) .. _IsInCatVal(args['Regione continentale3']) .. NS0Cat('Stato') --Gestisco gli articoli di tipo Regione nazionale elseif args[1] == 'Regione nazionale' then output = output .. _IsInVal(args['Regione continentale']) .. _IsInVal(args['Regione continentale2']) .. _IsInVal(args['Regione continentale3']) .. _IsInVal(args.Stato) .. _IsInVal(args.Stato2) .. _IsInVal(args.Stato3) .. _ExistIsInCatVal(args['Regione nazionale']) .. _ExistIsInCatVal(args['Regione nazionale2']) .. _ExistIsInCatVal(args['Regione nazionale3']) .. _ExistIsInCatVal(args['Regione nazionale4']) .. _ExistIsInCatVal(args['Regione nazionale5']) .. _ExistIsInCatVal(args['Regione nazionale6']) .. _ExistIsInCatVal(args['Regione nazionale7']) .. NS0Cat('Regione nazionale') .. NS0Cat('Regione') .. ((args.Stato and NS0Cat(args.Stato .. ' - le sue regioni')) or '') .. ((args.Stato2 and NS0Cat(args.Stato2 .. ' - le sue regioni')) or '') .. ((args.Stato3 and NS0Cat(args.Stato3 .. ' - le sue regioni')) or '') --Gestisco gli articoli di tipo Città elseif args[1] == 'Città' then output = output .. _IsInVal(args.Stato) .. _IsInVal(args.Stato2) .. _IsInVal(args.Stato3) .. _ExistIsInCatVal(args['Regione nazionale']) .. _ExistIsInCatVal(args['Regione nazionale2']) .. _ExistIsInCatVal(args['Regione nazionale3']) .. _ExistIsInCatVal(args['Regione nazionale4']) .. _ExistIsInCatVal(args['Regione nazionale5']) .. _ExistIsInCatVal(args['Regione nazionale6']) .. _ExistIsInCatVal(args['Regione nazionale7']) .. NS0Cat('Città') .. ((args.Stato and NS0Cat(args.Stato .. ' - le sue città')) or '') .. ((args.Stato2 and NS0Cat(args.Stato2 .. ' - le sue città')) or '') .. ((args.Stato3 and NS0Cat(args.Stato3 .. ' - le sue città')) or '') .. ((args['Regione nazionale'] and NS0Cat(args['Regione nazionale'] .. ' - le sue città')) or '') .. ((args['Regione nazionale2'] and NS0Cat(args['Regione nazionale2'] .. ' - le sue città')) or '') .. ((args['Regione nazionale3'] and NS0Cat(args['Regione nazionale3'] .. ' - le sue città')) or '') .. ((args['Regione nazionale4'] and NS0Cat(args['Regione nazionale4'] .. ' - le sue città')) or '') .. ((args['Regione nazionale5'] and NS0Cat(args['Regione nazionale5'] .. ' - le sue città')) or '') .. ((args['Regione nazionale6'] and NS0Cat(args['Regione nazionale6'] .. ' - le sue città')) or '') .. ((args['Regione nazionale7'] and NS0Cat(args['Regione nazionale7'] .. ' - le sue città')) or '') --Gestisco gli articoli di tipo Distretto elseif args[1] == 'Distretto' then output = output .. _ExistIsInCatVal(args['Città']) .. _ExistIsInCatVal(args.Distretto, true) .. _ExistIsInCatVal(args.Distretto2, true) .. NS0Cat('Distretto') .. ((args['Città'] and NS0Cat(args['Città'] .. ' - i suoi distretti')) or '') -- Gestisco articoli di tipo Aeroporto elseif args[1] == 'Aeroporto' then output = output .. NS0Cat('Aeroporto') .. _IsInVal(args['Continente']) .. _IsInVal(args['Continente2']) .. _IsInVal(args.Stato) .. _IsInVal(args.Stato2) .. _IsInVal(args.Stato3) .. _IsInVal(args['Città']) .. _ExistCatVal(args['Città']) .. ((args.Stato and NS0Cat(args.Stato .. ' - i suoi aeroporti')) or '') .. ((args.Stato2 and NS0Cat(args.Stato2 .. ' - i suoi aeroporti')) or '') .. ((args.Stato3 and NS0Cat(args.Stato3 .. ' - i suoi aeroporti')) or '') end --Limito le categorie a territori geograficamente più pertinenti if _has_value({'Mare', 'Lago', 'Insenatura', 'Monte', 'Sito archeologico', 'Parco', 'Itinerario', 'Sentiero'}, args[1]) then if not _isDefined(args.Stato) then --Le categorie sovranazionali vengono applicate solo se non è presente il parametro Stato output = output .. _IsInCatVal(args['Continente']) .. _IsInCatVal(args['Continente2']) .. _IsInCatVal(args['Regione continentale']) .. _IsInCatVal(args['Regione continentale2']) .. _IsInCatVal(args['Regione continentale3']) elseif not _isDefined(args['Città']) then --Le categorie sovraurbane vengono applicate solo se non è presente il parametro Città output = output .. _IsInCatVal(args.Stato) .. _IsInCatVal(args.Stato2) .. _IsInCatVal(args.Stato3) .. _ExistIsInCatVal(args['Regione nazionale']) .. _ExistIsInCatVal(args['Regione nazionale2']) .. _ExistIsInCatVal(args['Regione nazionale3']) .. _ExistIsInCatVal(args['Regione nazionale4']) .. _ExistIsInCatVal(args['Regione nazionale5']) .. _ExistIsInCatVal(args['Regione nazionale6']) .. _ExistIsInCatVal(args['Regione nazionale7']) else output = output .. _ExistIsInCatVal(args['Città']) end end -- Categorizza nella categoria omonima al primo parametro (tipo di Quickfooter) if _has_value({'Monte', 'Sito archeologico', 'Parco', 'Itinerario', 'Sentiero'}, args[1]) then output = output .. NS0Cat(args[1]) end if args[1] == 'Tematica' then if mw.title.getCurrentTitle().text ~= 'Tematiche turistiche' then IsInArticle = 'Tematiche turistiche' end if args.Tema == 'Parchi' or args.Tema == nil then output = output .. _IsInCatVal(args['Continente']) .. _IsInCatVal(args['Continente2']) .. _IsInCatVal(args.Stato) .. _IsInCatVal(args.Stato2) .. _IsInCatVal(args.Stato3) .. _ExistIsInCatVal(args['Regione nazionale'], true) .. _ExistIsInCatVal(args['Regione nazionale2'], true) .. _ExistIsInCatVal(args['Regione nazionale3'], true) .. _ExistIsInCatVal(args['Regione nazionale4'], true) .. _ExistIsInCatVal(args['Regione nazionale5'], true) .. _ExistIsInCatVal(args['Regione nazionale6'], true) .. _ExistIsInCatVal(args['Regione nazionale7'], true) .. _ExistIsInCatVal(args['Città']) elseif args.Tema == 'Aeroporto' then output = output .. NS0Cat('Tematica Aeroporto') -- Temporary, ci servirà per far girare qualche bot e riempire i Quickbar / Quickfooter prima di cancellarla -- Vecchia categorizzazione if args.Stato then output = output .. _IsInCatVal( args.Stato ) --Genero il template solo negli articoli nazionali, ossia quelli in cui è specificato lo Stato if args.Continente and (mw.title.new( "Template:Aeroporti dell'" .. args.Continente ).exists == true) then output = output .. frame:expandTemplate{ title="Aeroporti dell'" .. args.Continente } end if args.Continente2 and (mw.title.new( "Template:Aeroporti dell'" .. args.Continente2 ).exists == true) then output = output .. frame:expandTemplate{ title="Aeroporti dell'" .. args.Continente2 } end else --Creo categoria e breadcrumb continentale solo quando non è specificato lo Stato output = output .. _IsInCatVal(args['Continente']) .. _IsInCatVal(args['Continente2']) end output = output .. _ExistIsInCatVal(args['Città']) else output = output .. frame:expandTemplate{ title='Tematiche' } end end --Aggiungo ad ogni articolo delle categorie supplementari ad esso associate in accordo alla sua tipologia if args[1] == 'Itinerario' then output = output .. NS0Cat('Itinerario') .. ((args.Continente and NS0Cat(args.Continente .. ' - i suoi itinerari')) or '') .. ((args.Continente2 and NS0Cat(args.Continente2 .. ' - i suoi itinerari')) or '') .. ((args.Stato and NS0Cat(args.Stato .. ' - i suoi itinerari')) or '') .. ((args.Stato2 and NS0Cat(args.Stato2 .. ' - i suoi itinerari')) or '') .. ((args.Stato3 and NS0Cat(args.Stato3 .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale'] and NS0Cat(args['Regione nazionale'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale2'] and NS0Cat(args['Regione nazionale2'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale3'] and NS0Cat(args['Regione nazionale3'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale4'] and NS0Cat(args['Regione nazionale4'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale5'] and NS0Cat(args['Regione nazionale5'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale6'] and NS0Cat(args['Regione nazionale6'] .. ' - i suoi itinerari')) or '') .. ((args['Regione nazionale7'] and NS0Cat(args['Regione nazionale7'] .. ' - i suoi itinerari')) or '') .. ((args['Città'] and NS0Cat(args['Città'] .. ' - i suoi itinerari')) or '') .. ((args.Distretto and NS0Cat(args.Distretto .. ' - i suoi itinerari')) or '') elseif args[1] == 'Sentiero' then output = output .. NS0Cat('Sentiero') .. ((args.Continente and NS0Cat(args.Continente .. ' - i suoi sentieri')) or '') .. ((args.Continente2 and NS0Cat(args.Continente2 .. ' - i suoi sentieri')) or '') .. ((args.Stato and NS0Cat(args.Stato .. ' - i suoi sentieri')) or '') .. ((args.Stato2 and NS0Cat(args.Stato2 .. ' - i suoi sentieri')) or '') .. ((args.Stato3 and NS0Cat(args.Stato3 .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale'] and NS0Cat(args['Regione nazionale'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale2'] and NS0Cat(args['Regione nazionale2'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale3'] and NS0Cat(args['Regione nazionale3'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale4'] and NS0Cat(args['Regione nazionale4'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale5'] and NS0Cat(args['Regione nazionale5'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale6'] and NS0Cat(args['Regione nazionale6'] .. ' - i suoi sentieri')) or '') .. ((args['Regione nazionale7'] and NS0Cat(args['Regione nazionale7'] .. ' - i suoi sentieri')) or '') elseif args[1] == 'Sito archeologico' then if args.Stato then output = output .. NS0Cat(args.Stato .. ' - i suoi siti archeologici') end elseif args[1] == 'Tematica' then output = output .. NS0Cat('Tematiche turistiche') if args.Tema == 'Parchi' then output = output .. NS0Cat('Lista di parchi') elseif args.Tema == 'Aeroporto' then -- non far nulla, li sposteremo usando il Quickfooter Aeroporto invece che tematica elseif args.Tema then output = output .. NS0Cat('Quickfooter tematico con tema errato') end end --Aggiungo Template livello quando il parametro è presente per i gruppi di articoli già discussi --Per gli altri mostro solo la categoria delle bozze if _has_value({'Continente', 'Regione continentale', 'Stato', 'Regione nazionale', 'Città', 'Distretto', 'Parco', 'Sito archeologico', 'Massa d\'acqua', 'Monte', 'Itinerario', 'Sentiero', 'Frasario', 'Tematica'}, args[1]) then output = output .. livello( args.Livello, args[1] ) elseif _has_value({'Oceano', 'Mare', 'Lago', 'Insenatura'}, args[1]) then output = output .. livello( args.Livello, 'Massa d\'acqua' ) elseif args[1] == 'UNESCO' then --A questi articoli non è associato un livello else if args.Livello == 1 then output = output .. livello( args.Livello, args[1] ) end end --Aggiungo la categoria dell'articolo quando necessaria o in alcuni casi quando già esistente e alimento la categoria --che mette in evidenzia gli articoli col parametro tipo compilato in modo errato o con valori non ancora gestiti if _has_value({'Continente', 'Regione continentale', 'Stato', 'Regione nazionale'}, args[1]) then --Queste tipologie hanno sempre una categoria output = output .. NS0Cat(mw.title.getCurrentTitle().text) elseif _has_value({'Città', 'Distretto', 'Monte', 'Oceano', 'Mare', 'Lago', 'Insenatura'}, args[1]) then --Queste tipologie vengono categorizzate solo se la categoria già esiste if mw.title.new( 'Categoria:' .. mw.title.getCurrentTitle().text ).exists == true then output = output .. NS0Cat(mw.title.getCurrentTitle().text) end elseif _has_value({'Parco', 'Sito archeologico', 'Frasario', 'UNESCO', 'Tematica', 'Itinerario', 'Sentiero', 'Aeroporto'}, args[1]) then --Queste tipologie non sono mai categorizzate else output = output .. NS0Cat('Quickfooter con tipo errato') end --Chiamata ridondante quando è presente un pagebanner quindi escludo tutti quei casi in cui è obbligatorio da modello if not _has_value({'Continente', 'Regione continentale', 'Stato', 'Regione nazionale', 'Città', 'Distretto', 'Monte', 'Oceano', 'Mare', 'Lago', 'Insenatura', 'Parco', 'Sito archeologico', 'Frasario', 'UNESCO', 'Itinerario', 'Sentiero'}, args[1]) then output = output .. require( 'Module:Indicatore GPX' ).gpx() end frame:callParserFunction( '#IsIn', { IsInArticle } ) return output end --Interfacce del modulo local p = {} function p.QuickfooterTemplate(frame) return _Quickfooter(frame:getParent()) end function p.QuickfooterInvoke(frame) return _Quickfooter(frame) end function p.QuickfooterModule(frame) local args = frame.args frame = mw.getCurrentFrame() frame.args = args return _Quickfooter(frame) end return p