79 548
contributi
(Adding support for subpages *** sovrascritto il testo esistente ***) |
(Better solution to support subpages *** sovrascritto il testo esistente ***) |
||
Navigation bar with previous and next Pokémon in dex order.
This module exports two functions.
links the previous and next Pokémon pages.
The other is "subpage", intended to be used in Pokémon subpages to link
corresponding subpages of previous and next Pokémon.
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,▼
- subpage: (optional) if given, it is used to determine the subpage to▼
name of the subpage to link without the leading /.▼
--]]
--[[
Base (internal) function to create a PokePrecSucc. Performs basic operations
such as computing previous and next Pokémon ndex, and preparing the printed
text.
Parameters:
- poke: the Pokémon name
- linksuffix: (optional) the suffix to append to links. If not given
defaults to nothing (ie: links base Pokémon pages). This suffix is
appended as is; it's not modified, for instance, adding a leading "/".
--]]
local function
linksuffix = linksuffix or ""
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▼
end▼
m.PokePrecSucc = function(frame)▼
local poke = string.trim(frame.args[1]▼
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,
nextspr = nextTf,
}
--[[
Function to create a PrecSucc of subpages.
▲Usage:
{{#invoke: PokePrecSucc | subpage | <Pokémon name> | <suffix> }}
page title.
given, it defaults to the same suffix as the page it's invoked in.
--]]
m.subpage = function(frame)
▲ local poke = string.trim(frame.args[1]
▲ or mw.title.getCurrentTitle().rootText):lower()
local subpageSuffix = ""
▲ local title = mw.title.getCurrentTitle()
▲ if title.isSubpage then
▲ end
return basePokePrecSucc(poke, subpageSuffix)
▲end
--[[
Function to create a PrecSucc in a Pokémon page.
Usage:
- 1: (optional) the name of a Pokémon. In a Pokémon the suggested value for
this is "{{PAGENAME}}", that evaluates to the page name that (often) is
the Pokémon name desired. If not given, it defaults to the page title.
--]]
▲m.PokePrecSucc = function(frame)
or mw.title.getCurrentTitle().text):lower()
return basePokePrecSucc(poke)
end
|