Module:Top icons: Difference between revisions

no edit summary
scape_>Gaz Lloyd
m (fix rs3 wiki links)
scape_>Gaz Lloyd
No edit summary
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]]',
-- @TODO: update with new url post forking RSC
format = '[[rsw:%s]]',
params = { 'rsc', 'classic', 'c' },
params = { 'rsc', 'classic', 'c' },
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 = '[[w:c:runescape:%s|%s]]',
format = '[[rsw:%s]]',
params = { 'runescape', 'rs', 'rsw', 'rs3' },
params = { 'runescape', 'rs', 'rsw', 'rs3' },
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:%s]]',
params = { 'wikipedia', 'wp', 'w' },
abbr = 'Wikipedia',
title = 'Wikipedia also has an article on %s.',
},
},
}
}


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


local allparams = {}
local allparams = {}
Line 56: Line 57:
local ret = mw.html.create('div')
local ret = mw.html.create('div')
ret:addClass('topright topright-icon')
ret:addClass('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
Line 69: Line 73:
return tostring(ret)
return tostring(ret)
end
end


return p
return p
Anonymous user