Differenze tra le versioni di "Modulo:PokePrecSucc"

Adding support for subpages *** sovrascritto il testo esistente ***
(Update of GlitchPrecSucc to use the new graphic *** sovrascritto il testo esistente ***)
(Adding support for subpages *** sovrascritto il testo esistente ***)
--[[
 
Navigation bar with previous and next Pokémon in dex order.
La barra per scorrere sequenzialmente in ordine di dex
 
nazionale in cima ed in fondo ad ogni pagina dei Pokémon
It is also possible to use this module to add a PrevNext to a subpage of a
Pokémon page. This is the default behaviour when used in a subpage: it takes
the name of the root page and links to the corresponding subpages. This
behaviour can be suppressed giving the parameter "nosubpage", or using
the parameter "subpage" to specify the title of the subpage to link.
 
Usage:
 
{{#invoke: PokePrecSucc | PokePrecSucc | <Pokémon name> | other args }}
 
- 1: (optional) is the name of a Pokémon. In a Pokémon page or subpage
the suggested value for this is "{{ROOTPAGENAME}}", that evaluates to
the page name that (often) is the Pokémon name desired. If not given,
it takes the root page title.
- nosubpage: (optional) if this parameter is "yes" it suppress the link to
subpages, linking the root page instead.
- subpage: (optional) if given, it is used to determine the subpage to
link instead of using the current page subpage title. It should be the
name of the subpage to link without the leading /.
 
--]]
local data = mw.loadData('Modulo:Wikilib/data')
local pokes = mw.loadData('Modulo:Poké/data')
 
--[[
 
This function computes the subpage suffix to append to links.
 
It's only parameter is the frame.args given to the module's invoke.
 
--]]
local function getSubpageLink(args)
if string.trim(args.nosubpage) == "yes" then
return ""
end
if args.subpage then
return "/" .. string.trim(args.subpage)
end
local title = mw.title.getCurrentTitle()
if title.isSubpage then
return "/" .. mw.title.getCurrentTitle().subpageText
end
return ""
end
 
m.PokePrecSucc = function(frame)
local poke = string.trim(frame.args[1]):lower()
or mw.title.getCurrentTitle().rootText):lower()
local pokeData = multigen.getGen(pokes[poke] or pokes[mw.text.decode(poke)])
local type1, type2 = pokeData.type1, pokeData.type2
local prevTf, nextTf = string.tf(prev), string.tf(next)
local prevname, nextname = pokes[prev].name, pokes[next].name
local linksuffix = getSubpageLink(frame.args)
return prevnext.PrevNextLua{
color = type1,
list = "Elenco Pokémon secondo il Pokédex Nazionale",
prev = table.concat{"#", prevTf, ": ", prevname},
prevlink = prevname .. linksuffix,
prevspr = prevTf,
next = table.concat{"#", nextTf, ": ", nextname},
nextlink = nextname .. linksuffix,
nextspr = nextTf,
}
79 548

contributi