Jump to content

Module:Navigation-is

Unchecked
From Wikipedia

Documentation for this module may be created at Module:Navigation-is/doc

-- Siblings are indexed by a canonical name.
local siblings = {
    commons     = { name = "[[Commons]]", logo = "Commons-logo.svg", suffix = "", what = "er með margmiðlunarefni sem tengist" },
    meta        = { name = "the Wikimedia Community wiki", logo = "Wikimedia Community Logo.svg", suffix = "", what = "Wikimedia Community pages" },
    wikibooks   = { name = "[[Wikibækur]]", logo = "Wikibooks-logo-is.png", suffix = "", what = "eru með efni sem tengist" },
    wikiquote   = { name = "[[Wikivitnun]]", logo = "Wikiquote-logo.png", suffix = "", what = "er með safn tilvitnana á síðunni" },
    wikipedia   = { name = "[[Wikipedia]]", logo = "Wikipedia-logo-v2.svg", suffix = "", what = "hefur upp á að bjóða efni tengt" },
    wikisource  = { name = "Á [[Wikiheimild]]", logo = "Wikisource-logo.svg", suffix = "", what = "er að finna texta sem tengist" },
    wiktionary  = { name = "[[Wikiorðabók]]", logo = "Wiktionary-logo-is.png", suffix = "", what = "er með skilgreiningu á orðinu" },
    wikinews    = { name = "[[Wikifréttir]]", logo = "Wikinews-logo.svg", suffix = "", what = "eru með grein sem tengist" },
    wikispecies = { name = "[[Wikilífverur]]", logo = "Wikispecies-logo.svg", suffix = "", what = "eru með efni sem tengist" },
    wikiversity = { name = "[[Wikiháskóli]]", logo = "Wikiversity-logo.svg", suffix = "", what = " er með efni sem tengist" },
    mediawiki   = { name = "Mediawiki", logo = "Mediawiki.png", suffix = "", what = "MediaWiki information" },
    outreachwiki= { name = "Wikimedia Outreach",  logo = "Wikimedia Outreach.png", suffix = "", what = "outreach" },
    incubator   = { name = "the Wikimedia Incubator", logo = "Incubator-notext.svg", suffix = "", what = "incubated projects" },
    foundation  = { name = "the Wikimedia Foundation wiki", logo = "Incubator-notext.svg", suffix = "", what = "Wikimedia Foundation stuff" },
    { name = "Wikimedia", logo = "Wikimedia-logo.svg", suffix = "", what = "stuff" },
}

-- The interwiki map maps an interwiki prefix onto a canonical name.
-- The actual interwiki map used by the servers is at [[m:interwiki map]].
-- This map contains the subset of projects that are Wikimedia Foundation projects.
-- It also contains some prefixes that are used in templates but that aren't actually valid interwiki prefixes.
local interwiki_map = {
    commons = "commons",
    meta = "meta",
    m = "meta",
    metawiki = "meta",
    wikibooks = "wikibooks",
    b = "wikibooks",
    wb = "wikibooks",
    wbk = "wikibooks",
    wikiquote = "wikiquote",
    q = "wikiquote",
    wqt = "wikiquote",
    quote = "wikiquote",
    wikipedia = "wikipedia",
    w = "wikipedia",
    wp = "wikipedia",
    wikisource = "wikisource",
    s = "wikisource",
    ws = "wikisource",
    source = "wikisource",
    wiktionary = "wiktionary",
    d = "wiktionary",
    wkt = "wiktionary",
    wikt = "wiktionary",
    wdy = "wiktionary",
    wikinews = "wikinews",
    n = "wikinews",
    wnw = "wikinews",
    news = "wikinews",
    wikispecies = "wikispecies",
    species = "wikispecies",
    wikiversity = "wikiversity",
    v = "wikiversity",
    wvy = "wikiversity",
    mw = "wikiversity",
    outreachwiki = "outreachwiki",
    outreach = "outreachwiki",
}

local z = {}

-- This is used by templates {{wiktionary}}, {{wikibooks}}, {{wikisource}}, {{commons}}, {{wikiquote}}, {{meta}}, {{wikispecies}}, and {{wikinews}}.
-- It entirely replaces template {{sister}}, which is now obsolete.
function z.sibling(frame)
    local pframe = frame:getParent()
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local pagename = mw.title.getCurrentTitle().text
    local wiki = config.interwiki
    local interwiki = interwiki_map[wiki] or interwiki_map[1]
    local Position = args.position or "right"
    local sibling = siblings[interwiki] or siblings[1]

    local link = "[[" .. interwiki .. ":Special:Search/" .. ( args[1] or pagename ) .. "|" .. ( args[2] or pagename ) .. "]]"

    local text = {}
    local icon = "[[File:" .. sibling.logo .. "|40px|left|link=|alt=]] "
    local linksdiv = '<div style="margin-left:50px;">' .. link .. '</span>';
    local div = '<div style="margin-left:10px;">' .. sibling.name .. " " .. sibling.what .. ": " .. linksdiv .. '</span>'

    local Left = "t" .. Position
    return '<div style="float: right; width: 222px; font-size: 85%; border:solid #ccc 1px; margin:0.5em 0.5em 0.5em 0">' .. icon .. " " .. div ..'</div>'
end

return z