Modul:SimpleLinkList

Modul:SimpleLinkList

Modul:SimpleLinkList
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
			local splE = mw.text.split(elm, '{{{!}}}')
			if splE[2] == nil then splE = {elm, elm} end
			if splE[1] == title.fullText or splE[1] == title.text then
				result = result .. string.format(formatActive, splE[2])
			else
				result = result .. string.format(formatPassive,
				         frame:preprocess('[[' .. splE[1] .. '|' .. splE[2] .. ']]'))
			end
		end
	end
	return mw.ustring.sub(result, len)
end

p.spaced = function(frame)
	return p.service.list(frame, ' %s', ' %s')
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">&nbsp;</td>'
	TABS.FOOTER='</tr></table>'
	TABS.SPACING='<td class="spacingTR">&nbsp;</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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.