Module:Top icons: Difference between revisions

m
20 revisions imported
scape_>Spineweilder
No edit summary
m (20 revisions imported)
 
(13 intermediate revisions by 8 users not shown)
Line 2: Line 2:


local sites = {
local sites = {
wp = {
format = '[[wikipedia:%s|%s]]',
params = { 'wikipedia', 'wp', 'w' },
abbr = 'W',
title = 'Wikipedia also has an article on {{PAGENAME}}.',
},
rsc = {
rsc = {
format = '[[w:c:runescapeclassic:%s|%s]]',
format = 'The RuneScape Classic Wiki also has an article on: [[classicrsw:%s]]',
params = { 'rsc', 'classic', 'c' },
params = { 'rsc' },
abbr = 'C',
abbr = 'CS',
title = 'The RuneScape Classic Wiki also has an article on {{PAGENAME}}.',
title = 'The RuneScape Classic Wiki also has an article on %s.',
},
},
rs = {
rs = {
format = '[[runescape:%s|%s]]',
format = 'The RuneScape Wiki also has an article on: [[rsw:%s]]',
params = { 'runescape', 'rs', 'rsw', 'rs3' },
params = { 'rs' },
abbr = 'RS',
abbr = 'RuneScape',
title = 'The RuneScape Wiki also has an article on {{PAGENAME}}.',
title = 'The RuneScape Wiki also has an article on %s.',
},
wp = {
format = 'Wikipedia also has an article on: [[wikipedia:%s]]',
params = { 'wp' },
abbr = 'Wikipedia',
title = 'Wikipedia also has an article on %s.',
},
meta = {
format = '[[meta:%s]]',
params = { 'meta' },
abbr = 'Weird Gloop',
title = 'The Weird Gloop meta wiki also has an article on %s.',
},
},
}
}


local order = { 'wp', 'rsc', 'rs' }
local order = { 'rs', 'rsc', 'wp', 'meta' }


local allparams = {}
local allparams = {}
Line 28: Line 34:
function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
local args = frame:getParent().args
return p._main(args)
end
function p._main(args)
local pagename = mw.title.getCurrentTitle().fullText
local pagename = mw.title.getCurrentTitle().fullText
local vals = {}
local vals = {}
Line 56: Line 66:
local ret = mw.html.create('div')
local ret = mw.html.create('div')
ret:addClass('topright topright-icon')
ret:addClass('noexcerpt noprint nomobile navigation-not-searchable rs-external-header-links'):css('display', 'none')
for _,v in ipairs(order) do
for _,v in ipairs(order) do
if vals[v] then
if vals[v] then
local span = mw.html.create('span')
local span = ret:tag('span')
span:wikitext(sites[v].abbr)
span:wikitext(string.format(sites[v].format, vals[v]))
:addClass('rs-header-icon rs-header-icon-'..v)
:addClass('rs-header-icon rs-header-icon-'..v)
:attr('title', string.format(sites[v].title, vals[v]))
:attr({
ret:wikitext(string.format(sites[v].format, vals[v], tostring(span)))
['data-title'] = string.format(sites[v].title, vals[v]),
['data-site'] = v,
['data-text'] = sites[v].abbr,
})
end
end
end
end


return tostring(ret)
return tostring(ret)
end
end


return p
return p