Toggle menu
244K
68
18
624.9K
Hrvatska internetska enciklopedija
Toggle preferences menu
Toggle personal menu
Niste prijavljeni
Your IP address will be publicly visible if you make any edits.

Modul:Televizijske serije po godini završetka

Izvor: Hrvatska internetska enciklopedija

<templatestyles src="Modul:Dokumentacija/styles.css"></templatestyles>

Dokumentacija modula[stvori]
local p = {}  -- Initialize the table for the module functions

function p.generateTimeline(frame)
    -- Get the current page year from the title
    local title = mw.title.getCurrentTitle().text
    local currentYear = tonumber(title:match("(%d%d%d%d)"))
    
    -- Check if year extraction was successful
    if not currentYear then
        return "Error: Unable to extract year from the title."
    end

    -- Define the range of years (5 before and 5 after)
    local startYear = currentYear - 5
    local endYear = currentYear + 5
    
    -- Create a list of years with links where applicable
    local years = {}
    
    for year = startYear, endYear do
        local categoryTitle = "Kategorija:Televizijske serije koje su završile " .. year .. "."
        -- Check if the category exists
        local category = mw.title.new(categoryTitle)
        
        -- If the category exists, link it, otherwise display it as plain text
        if category.exists then
            -- Include the colon in the link to prevent page categorization and ensure correct link format
            table.insert(years, string.format("[[:%s|%d.]]", categoryTitle, year))
        else
            -- Display year with dot if category does not exist
            table.insert(years, string.format("%d.", year))
        end
    end
    
    -- Join the years into a single string with " · " as separator
    return table.concat(years, " · ")
end

function p.timeline(frame)
    return p.generateTimeline(frame)
end

return p  -- Return the table of functions