Modul:SimpleLinkList
Erscheinungsbild
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
--[=[ SimpleLinkList 2022-02-10
simple link list generators for navigation in simmilar pages
Param for all methods: lemmas, comma separated
* culled: links to lemmas, hyphen separated, current page culled
* highlighted: links to lemmas, hyphen separated, current page highlighted
* stacked: links to lemmas, line break separated, current page culled
* stackedHL: links to lemmas, line break separated, current page highlighted
]=]
p = {service = {}}
p.service.list = function(frame, formatPassive, formatActive)
if frame.args[1] == nil then
return frame:preprocess('[[Modul:SimpleLinkList]]')
end
local Param = mw.text.split(frame.args[1], ',')
local result = ""
local title = mw.title.getCurrentTitle()
for _, v in ipairs(Param) do
local elm = string.gsub(v, '^%s*(.-)%s*$', '%1')
if elm ~= "" then
string.gsub(elm, "[{]3![}]3", '|')
if elm == title.fullText or elm == title.text then
result = result .. string.format(formatActive, elm)
else
result = result .. string.format(formatPassive,
frame:preprocess('[[' .. elm .. ']]'))
end
end
end
return mw.ustring.sub(result, len)
end
p.culled = function(frame)
return p.service.list(frame, ' - %s', ' - %s')
end
p.stacked = function(frame)
return p.service.list(frame, '<br />%s','<br />%s')
end
p.highlighted = function(frame)
return p.service.list(frame, ' - %s',
' - <span class="highlight">%s</span>')
end
p.stackedHL = function(frame)
return p.service.list(frame, '<br />%s',
'<br /><span class="highlight">%s</span>')
end
TABS = {}
TABS.HEADER='<table class="tab"><tr><td class="marginLT"> </td>'
TABS.FOOTER='</tr></table>'
TABS.SPACING='<td class="spacingTR"> </td>'
TABS.DEFAULT='<td>%s</td>' .. TABS.SPACING
TABS.ACTIVE='<td class="active">%s</td>' .. TABS.SPACING
TABS.ACTIVETH='<th class="active">%s</th>' .. TABS.SPACING
TABS.ACTIVEHL='<td class="active highlight">%s</td>' .. TABS.SPACING
p.tabulated = function(frame)
local result = TABS.HEADER
local result = result .. p.service.list(frame, TABS.DEFAULT, TABS.ACTIVE)
return result .. TABS.FOOTER
end
p.tabulatedTH = function(frame)
local result = TABS.HEADER
local result = result .. p.service.list(frame, TABS.DEFAULT, TABS.ACTIVETH)
return result .. TABS.FOOTER
end
p.tabulatedHL = function(frame)
local result = TABS.HEADER
local result = result .. p.service.list(frame, TABS.DEFAULT, TABS.ACTIVEHL)
return result .. TABS.FOOTER
end
return p