Module:Setlist/Songs: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
-- Функция для определения актуального альбома по названию страницы
function p.getCurrentAlbum()
    local title = mw.title.getCurrentTitle().text or ""
    local year = mw.ustring.match(title, "%.(%d%d%d%d)$")
    year = tonumber(year)
    if year and year >= 2008 and year <= 2012 then
        return "Regional At Best"
    elseif year and year >= 2013 then
        return "Vessel"
    end
    return nil
end
local songs = {
local songs = {
     ["Implicit Demand For Proof"] = {"Twenty One Pilots"},
     ["Implicit Demand For Proof"] = {"Twenty One Pilots"},
Line 22: Line 7:
     ["March To The Sea"] = {"Twenty One Pilots"},
     ["March To The Sea"] = {"Twenty One Pilots"},
     ["Johnny Boy"] = {"Twenty One Pilots"},
     ["Johnny Boy"] = {"Twenty One Pilots"},
     ["Oh Ms Believer"] = {"Twenty One Pilots"},
     ["Oh, Ms. Believer"] = {"Twenty One Pilots"},
     ["Air Catcher"] = {"Twenty One Pilots"},
     ["Air Catcher"] = {"Twenty One Pilots"},
     ["Trapdoor"] = {"Twenty One Pilots"},
     ["Trapdoor"] = {"Twenty One Pilots"},
Line 103: Line 88:
     ["Paladin Strait"] = {"Clancy"},
     ["Paladin Strait"] = {"Clancy"},
     ["Time To Say Goodbye"] = {"Johnny Boy"}
     ["Time To Say Goodbye"] = {"Johnny Boy"}
    -- ... и т.д.
}
}
-- Определяем цвета альбомов
-- Определяем цвета альбомов
local albumColors = {
local albumColors = {
Line 114: Line 99:
     ["Scaled And Icy"] = "#b3e7fa",
     ["Scaled And Icy"] = "#b3e7fa",
     ["Johnny Boy"] = "#CECECE",
     ["Johnny Boy"] = "#CECECE",
    ["Non-Album"] = "white",
}
}
-- Определяем ссылки для альбомов
-- Определяем ссылки для альбомов
local albumLinks = {
local albumLinks = {
     ["Twenty One Pilots"] = "Twenty One Pilots (album)",
     ["Twenty One Pilots"] = "Twenty One Pilots (album)",
     ["Regional at Best"] = "Regional at Best",
     ["Regional At Best"] = "Regional at Best",
     ["Vessel"] = "Vessel (album)",
     ["Vessel"] = "Vessel",
     ["Blurryface"] = "Blurryface (album)",
     ["Blurryface"] = "Blurryface (album)",
     ["Trench"] = "Trench (album)",
     ["Trench"] = "Trench (album)",
Line 126: Line 111:
     ["Johnny Boy (EP)"] = "Johnny Boy",
     ["Johnny Boy (EP)"] = "Johnny Boy",
}
}
 
return {
-- Пример функции: возвращает песни, относящиеся к альбому для текущей страницы
     songs = songs,
function p.getSongsForCurrentAlbum(frame)
    albumColors = albumColors,
    local album = p.getCurrentAlbum()
     albumLinks = albumLinks,
    if not album then
}
        return "Альбом не определён"
     end
    local result = {}
    for song, albums in pairs(songs) do
        for _, a in ipairs(albums) do
            if a == album then
                table.insert(result, song)
                break
            end
        end
     end
    return table.concat(result, "<br>")
end
 
return p

Navigation menu