Modul:TV sezona
Izgled
Modul:TV sezona koristi se u predlošcima {{Infookvir TV sezona}}) i {{Infookvir reality TV sezona}} za automatsko ispunjavanje infookivra pojedinim informacijama o sezoni.
Funkcije
[uredi kôd]| Funkcija | Opis |
|---|---|
| brojsezone | Dohvaća broj sezone i upisuje pronađeni broj u podzaglavlje infookivra. Broj se dohvaća iz naslova članka na koji je infookvir postavljen, npr. na članku MasterChef Hrvatska (7. sezona), funkcija će upisati "7. sezona" u podzaglavlje infookivra. |
| prethodna | Pronalazi članak prethodne sezone i, ako postoji, unosi ga u obliku poveznice s tekstom, npr. "6. sezona", ako je trenutni članak o 7. sezoni. |
| sljedeca | Pronalazi članak sljedeće sezone i, ako postoji, unosi ga u obliku poveznice s tekstom, npr. "8. sezona", ako je trenutni članak o 7. sezoni. |
| popisepizoda | Pronalazi članak s popisom epizoda serije ili emisije, ako postoji pod naslovom "Popis epizoda serije [ime serije]", odnosno "Popis epizoda emisije [ime emisije]," te ga stavlja u povezinu s tekstom "Popis epizoda." |
Bilješke
[uredi kôd]- Gore navedene informacije se u infookviru mogu samostalno definirati u parametrima
|broj sezone=,|prethodna=,|sljedeća=i|popis epizoda=. Modul automatski ispunjava navedene parametre samo ako nisu ispunjeni. - Modul ne podržava sezone serija i emisija koje nemaju broj sezone u naslovu, npr. Američka horor priča: Vještičja družba. Kod takvih je članaka, i svih ostalih koji nemaju naslov u formi "Ime serije (XY. sezona)", potrebno samostalno ispuniti navedene informacije.
local p = {}
-- Provjeri postoji li stranica
local function pageExists(title)
local result = mw.title.new(title)
return result and result.exists
end
-- Potrazi clanak za prethodnu sezonu
function p.prethodna(frame)
-- Get the full page title
local title = mw.title.getCurrentTitle().text
-- Extract the base name and number using pattern matching
local base, number = string.match(title, '^(.-)%s*%((%d+)%.%s*sezona%)$')
-- If match fails, return empty string to avoid errors
if not base or not number then
return ''
end
local prevNumber = tonumber(number) - 1
if prevNumber < 1 then
return '' -- No season 0 or negative
end
local linkTitle = string.format('%s (%d. sezona)', base, prevNumber)
-- Check if the previous season's page exists
if not pageExists(linkTitle) then
return '' -- Return empty string if the page doesn't exist
end
local linkText = string.format('%d. sezona', prevNumber)
return string.format('[[%s|%s]]', linkTitle, linkText)
end
-- Potrazi clanak za sljedecu sezonu
function p.sljedeca(frame)
-- Get the full page title
local title = mw.title.getCurrentTitle().text
-- Extract the base name and number using pattern matching
local base, number = string.match(title, '^(.-)%s*%((%d+)%.%s*sezona%)$')
-- If match fails, return empty string to avoid errors
if not base or not number then
return ''
end
local nextNumber = tonumber(number) + 1
local linkTitle = string.format('%s (%d. sezona)', base, nextNumber)
-- Check if the next season's page exists
if not pageExists(linkTitle) then
return '' -- Return empty string if the page doesn't exist
end
local linkText = string.format('%d. sezona', nextNumber)
return string.format('[[%s|%s]]', linkTitle, linkText)
end
-- New function to retrieve the current season's number (brojsezone)
function p.brojsezone(frame)
-- Get the full page title
local title = mw.title.getCurrentTitle().text
-- Extract the base name and number using pattern matching
local base, number = string.match(title, '^(.-)%s*%((%d+)%.%s*sezona%)$')
-- If no match is found, return an empty string
if not base or not number then
return ''
end
-- If the season number was found, return it in the format "x. sezona"
return string.format('%s. sezona', number)
end
-- New function for Popis epizoda (popisepizoda)
function p.popisepizoda(frame)
-- Get the full page title
local title = mw.title.getCurrentTitle().text
-- Extract the base name from the page title (remove any bracket content)
local base = string.match(title, '^(.-)%s*%b()')
if not base then
return '' -- Return empty if no base name could be extracted
end
-- Define possible page titles to check
local candidates = {
string.format('Popis epizoda serije %s', base),
string.format('Popis epizoda emisije %s', base),
string.format('Dodatak:Popis epizoda serije %s', base),
string.format('Dodatak:Popis epizoda emisije %s', base)
}
-- Iterate through candidates and return the first one that exists
for _, candidate in ipairs(candidates) do
if pageExists(candidate) then
return string.format('[[%s|Popis epizoda]]', candidate)
end
end
-- If none found, return empty string
return ''
end
return p