Content deleted Content added
No edit summary |
|||
(12 intermediate revisions by 2 users not shown) | |||
Line 5:
local ROOT_PAGE = 'Module:Find sources'
local TEMPLATE_ROOT = ROOT_PAGE .. '/templates/' -- for template config modules
local
local CONFIG_PAGE = ROOT_PAGE .. '/config' -- for global config
Line 40:
end
function p._renderLink(code, searchTerms, display, tooltip)
-- Renders the external link wikicode for one link, given the link code,
-- a table of search terms, and an optional display value and tooltip.
-- Get link config.
local
local linkCfg = links[code]
if not linkCfg then
error(string.format(
"invalid link code '%s'; no link config found at [[%s]]",
code,
LINK_CONFIG
))
end
Line 65 ⟶ 66:
url = substituteParams(linkCfg.url, searchString)
end
if tooltip then
return string.format('[%s %s]', url, display or linkCfg.display)▼
return string.format('<span title="%s" style="border-bottom: 1px dotted;">[%s %s]</span>',
mw.text.encode(tooltip), url, display or linkCfg.display)
else
end
end
Line 77 ⟶ 83:
-- Get the template config.
local templateCfgPage = TEMPLATE_ROOT .. template .. '/sandbox'
local templateCfg = maybeLoadData(templateCfgPage)
if not templateCfg then
Line 131 ⟶ 137:
' '
)
local tooltip = templateCfg.introLink.tooltip
introLink = p._renderLink(code, searchTerms, display, tooltip)
else
introLink = ''
Line 141 ⟶ 148:
local sep = ''
for i, t in ipairs(templateCfg.links) do
links[i] = sep .. p._renderLink(t.code, searchTerms, t.display, t.tooltip) ..
(t.afterDisplay or '')
sep = t.separator or separator
|