Module:Icons: Difference between revisions

Icon: Support 'section' parameter, for linking to sections within pages
(Icon: Revert removal of `#` from links, facilitates linking directly to page sections with no obvious downside)
(Icon: Support 'section' parameter, for linking to sections within pages)
Line 178: Line 178:
["Winter"] = "png",
["Winter"] = "png",
["Nightfall"] = "png",
["Nightfall"] = "png",
["Solar Eclipse"] = "png",
["Solar Eclipse"] = "png"
}
}
}
}
Line 185: Line 185:
local typeOverrides = {
local typeOverrides = {
['combat'] = 'combatArea',
['combat'] = 'combatArea',
['slayer'] = 'combatArea',
['slayer'] = 'combatArea'
}
}
--When calling for an icon for Key, replace with image Value, and optionally override type also
--When calling for an icon for Key, replace with image Value, and optionally override type also
Line 322: Line 322:
['resource'] = {
['resource'] = {
['Rune Essence'] = {'Rune Essence', 'item'},
['Rune Essence'] = {'Rune Essence', 'item'},
['Leather'] = {'Leather', 'item'},
['Leather'] = {'Leather', 'item'}
}
}
}
}
Line 399: Line 399:
['Spectre'] = true,
['Spectre'] = true,
['Siren'] = true,
['Siren'] = true,
['Lightning Spirit'] = true,
['Lightning Spirit'] = true
}
}
--When calling for an icon for Key, add a css class
--When calling for an icon for Key, add a css class
Line 416: Line 416:
local nolink = args.nolink ~= nil and args.nolink ~= ''
local nolink = args.nolink ~= nil and args.nolink ~= ''
local noicon = args.noicon ~= nil and args.noicon ~= ''
local noicon = args.noicon ~= nil and args.noicon ~= ''
local nospan = args.nospan ~= nil and args.nospan
local menu = args.menu ~= nil and args.menu ~= ''
local menu = args.menu ~= nil and args.menu ~= ''
local imgSize = args.size ~= nil and args.size or 25
local imgSize = args.size ~= nil and args.size or 25
Line 422: Line 423:
local class = args.class ~= nil and args.class ~= '' and args.class or ''
local class = args.class ~= nil and args.class ~= '' and args.class or ''
local altText = args.alt ~= nil and args.alt or (notext and (text or link)) or ''
local altText = args.alt ~= nil and args.alt or (notext and (text or link)) or ''
local nospan = args.nospan ~= nil and args.nospan
local linkSection = args.section
local expIcon = args.expicon ~= nil and args.expicon or ''
local expIcon = args.expicon ~= nil and args.expicon or ''


Line 439: Line 440:
text = link
text = link
end
end
link = 'Agility#' .. string.gsub(link, ' ', '')
linkSection = string.gsub(link, ' ', '')
link = 'Agility'
end
end


Line 470: Line 472:
-- Type & extension overrides must be after adjustments have been made
-- Type & extension overrides must be after adjustments have been made
-- for any image overrides
-- for any image overrides
local ovrTypeExt = typeExtOverrides[iconType]
local ovrTypeExt, ovrTypeExtTable = nil, typeExtOverrides[iconType]
if ovrTypeExt ~= nil then
if ovrTypeExtTable ~= nil then
ovrTypeExt = ovrTypeExt[img]
ovrTypeExt = ovrTypeExtTable[img]
end
end
local ovrType = typeOverrides[iconType]
local ovrType = typeOverrides[iconType]
Line 502: Line 504:
end
end
-- There are a couple specific double overrides to be included that don't fit in the above lists
-- There are a couple specific double overrides to be included that don't fit in the above lists
if ambiguousOverrides[link] then
 
-- If the link requires disambiguation or a section, the modify the link accordingly without
-- while preserving the displayed text
local isAmbig, hasSection = ambiguousOverrides[link], linkSection ~= nil and linkSection ~= ''
if isAmbig or hasSection then
if not hasText then
if not hasText then
text = link
text = link
hasText = true
hasText = true
end
end
link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')'
link = link .. (isAmbig and ' ('..(iconType == 'mark' and 'item' or iconType)..')' or '') .. (hasSection and '#' .. linkSection or '')
end
end