Moduł:TOC

 Dokumentacja modułu[stwórz] • [odśwież]
-- Funkcje pomocnicze do tworzenia spisu treści.
-- Lua info: https://en.wikipedia.org/wiki/Wikipedia:Lua
-- mw.*: https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Scribunto_libraries
local p = {}

-- link z from (dla kategorii)
function p.linkKategoria(page, from)
	local url = tostring(mw.uri.fullUrl(page, 'from='..from ))
	return '['.. url .. ' ' .. from .. ']'
end

--[[ Funkcja do generowania linków dwuliterowych w rozwiniętym spisie treści.

Używane w: https://pl.wikipedia.org/wiki/Szablon:Spis_treści_kategoria/rozwinięty

Generowane linki składają się z dwóch liter. Obie mogą pochodzić z jednego alfabetu:
{{#invoke:TOC|linkiAA|strona=Test|alfabet=abcdefghijklmnopqrstuvwxyz}}

Lub z dwóch różnych:
{{#invoke:TOC|linkiAA|strona=Test|alfabet1=abcćdeęfghijklłmnńoópqrsśtuvwxyzźż|alfabet2=aąbcćdeęfghijklłmnńoópqrsśtuvwxyzźż}}

Wywołanie testowe (w konsoli debugowania):
=p.linkiAA({args={strona='Test', alfabet='abcdefghijklnopqrstuvwxyz'}})
=p.linkiAA({args={strona='Test', alfabet1='abcćdeęfghijklłmnńoópqrsśtuvwxyzźż', alfabet2='aąbcćdeęfghijklłmnńoópqrsśtuvwxyzźż'}})
]]--
function p.linkiAA(frame)
	local strona = frame.args.strona
	local alfabet1, alfabet2
	if frame.args['alfabet'] ~= nil then
		alfabet1 = frame.args.alfabet
		alfabet2 = frame.args.alfabet
	else
		alfabet1 = frame.args.alfabet1
		alfabet2 = frame.args.alfabet2
	end
	
	local result = ''
	for litera1 in alfabet1:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
		result = result .. '\n\'\'\''.. mw.ustring.upper(litera1) ..'\'\'\''
		for litera2 in alfabet2:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
			result = result .. ' ' .. p.linkKategoria(strona, mw.ustring.upper(litera1) .. litera2)
		end
	end
	return result
end

--[[ Funkcja do generowania linków jednoliterowych w spisie treści.

Używane w: https://pl.wikipedia.org/wiki/Szablon:Spis_treści_kategoria/rozwinięty

Generowane linki składają się z jednej litery (znaku). Wywołanie:
{{#invoke:TOC|linkiA|strona=Test|alfabet=abcdefghijklmnopqrstuvwxyz}}
{{#invoke:TOC|linkiA|strona=Test|alfabet=0123456789}}

Wywołanie testowe (w konsoli debugowania):
=p.linkiA({args={strona='Test', alfabet='abcdefghijklnopqrstuvwxyz'}})
]]--
function p.linkiA(frame)
	local strona = frame.args.strona
	local alfabet1 = frame.args.alfabet

	local result = ''
	for litera1 in alfabet1:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
		result = result .. p.linkKategoria(strona, mw.ustring.upper(litera1)) .. ' '
	end
	return result
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.
Kembali kehalaman sebelumnya