Anonymous user
Module:Find sources: Difference between revisions
m
Changed protection settings for "Module:Find sources": dropping per request of EXCON editor ([Edit=Require extended confirmed access] (indefinite) [Move=Require template editor access] (indefinite))
Richardpruen (talk | contribs) m (1 revision imported: Wikipedia article on Nicotine templates needed) |
m (Changed protection settings for "Module:Find sources": dropping per request of EXCON editor ([Edit=Require extended confirmed access] (indefinite) [Move=Require template editor access] (indefinite))) |
||
Line 40: | Line 40: | ||
end | end | ||
function p._renderLink(code, searchTerms, display) | function p._renderLink(code, searchTerms, display, tooltip) | ||
-- Renders the external link wikicode for one link, given the link code, | -- Renders the external link wikicode for one link, given the link code, | ||
-- a table of search terms, and an optional display value. | -- a table of search terms, and an optional display value and tooltip. | ||
-- Get link config. | -- Get link config. | ||
Line 65: | Line 65: | ||
url = substituteParams(linkCfg.url, searchString) | url = substituteParams(linkCfg.url, searchString) | ||
end | end | ||
return string.format('[%s %s]', url, display or linkCfg.display) | if tooltip then | ||
return string.format('<span title="%s" style="border-bottom: 1px dotted;">[%s %s]</span>', | |||
mw.text.encode(tooltip), url, display or linkCfg.display) | |||
else | |||
return string.format('[%s %s]', url, display or linkCfg.display) | |||
end | |||
end | end | ||
Line 131: | Line 136: | ||
' ' | ' ' | ||
) | ) | ||
introLink = p._renderLink(code, searchTerms, display) | local tooltip = templateCfg.introLink.tooltip | ||
introLink = p._renderLink(code, searchTerms, display, tooltip) | |||
else | else | ||
introLink = '' | introLink = '' | ||
Line 141: | Line 147: | ||
local sep = '' | local sep = '' | ||
for i, t in ipairs(templateCfg.links) do | for i, t in ipairs(templateCfg.links) do | ||
links[i] = sep .. p._renderLink(t.code, searchTerms, t.display) .. | links[i] = sep .. p._renderLink(t.code, searchTerms, t.display, t.tooltip) .. | ||
(t.afterDisplay or '') | (t.afterDisplay or '') | ||
sep = t.separator or separator | sep = t.separator or separator |