FANDOM


-- <nowiki>
local p = {}
 
function p.main(frame)
    local title = mw.title.getCurrentTitle()
    local html = mw.html.create('div'):addClass('canontab')
    local args = frame:getParent().args
    local type = args[1]
    local ret = ''
    local eraicons = mw.html.create('div'):addClass('eraicons__wrapper')
    -- TODO: DRY
    if (title.subpageText ~= title.text and title.subpageText == 'Легенди') or type == 'легенди' then
        -- Legends
        if title.subpageText == 'Легенди' then
            ret = ret .. frame:preprocess('{{DISPLAYTITLE:' .. title.baseText .. '}}')
        end
        ret = ret .. '[[Категорія:Легендарні статті|' .. title.baseText .. ']]'
        eraicons:tag('div')
                    :addClass('eraicons')
                    :wikitext('[[File:Premium-Eras-legends.png|This article details a subject that falls under the Legends brand.|link=Легенди]]')
                :done()
        local page
        if args['канон'] then
            page = mw.title.new(args['канон'])
        elseif title.subpageText ~= title.text then
            page = mw.title.new(title.baseText)
        else
            return ret .. tostring(eraicons:done())
        end
        if not page.exists then
            -- Canon tab doesn't exist, return
            return ret .. tostring(eraicons:done())
        end
        html:tag('div')
                :addClass('canontab__tab')
                :wikitext('[[File:Tab-canon-black.png|Click here for Wookieepedia\'s article on the Canon version of this subject.|link=' .. page.text .. ']]')
            :done()
            :tag('div')
                :addClass('canontab__tab')
                :addClass('canontab__current')
                :wikitext('[[File:Tab-legends-white.png|This article covers the Legends version of this subject.|link=' .. title.text .. ']]')
            :done()
    elseif type ~= 'легенди' then
        -- Canon
        ret = ret .. '[[Категорія:Канонічні статті|' .. title.baseText .. ']]'
        eraicons:tag('div')
                    :addClass('eraicons')
                    :wikitext('[[File:Premium-Eras-canon.png|This article details a subject that is considered canon.|link=Канон]]')
                :done()
        local page = mw.title.new(args['легенди'] or (title.text .. '/Легенди'))
        if not page.exists then
            -- Legends tab doesn't exist, return
            return ret .. tostring(eraicons:done())
        end
        html:tag('div')
                :addClass('canontab__tab')
                :addClass('canontab__current')
                :wikitext('[[File:Tab-canon-white.png|This article covers the Canon version of this subject.|link=' .. title.text .. ']]')
            :done()
            :tag('div')
                :addClass('canontab__tab')
                :wikitext('[[File:Tab-legends-black.png|Click here for Wookieepedia\'s article on the Legends version of this subject.|link=' .. page.text .. ']]')
            :done()
    end
    return ret .. tostring(html:done()) .. tostring(eraicons:done())
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.