Pojdi na vsebino

Modul:Category handler/shared

Iz Wikipedije, proste enciklopedije
Redakcija dne 21:45, 8. junij 2022 od GeographieMan (pogovor | prispevki) (Zaščitil »Modul:Category handler/shared«: Strani, ki se uporabljajo v sistemskih sporočilih in potrebujejo zaščito ([Urejanje=dovoli samo administratorjem] (nedoločeno) [Prestavljanje=dovoli samo administratorjem] (nedoločeno)))
(razl) ← Starejša redakcija | prikaži trenutno redakcijo (razl) | Novejša redakcija → (razl)
Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osveži]

Usage

{{#invoke:Category handler|function_name}}


-- This module contains shared functions used by [[Module:Category handler]]
-- and its submodules.

local p = {}

function p.matchesBlacklist(page, blacklist)
	for i, pattern in ipairs(blacklist) do
		local match = mw.ustring.match(page, pattern)
		if match then
			return true
		end
	end
	return false
end

function p.getParamMappings(useLoadData)
	local dataPage = 'Modul:Namespace detect/data'
	if useLoadData then
		return mw.loadData(dataPage).mappings
	else
		return require(dataPage).mappings
	end
end

function p.getNamespaceParameters(titleObj, mappings)
	-- We don't use title.nsText for the namespace name because it adds
	-- underscores.
	local mappingsKey
	if titleObj.isTalkPage then
		mappingsKey = 'talk'
	else
		mappingsKey = mw.site.namespaces[titleObj.namespace].name
	end
	mappingsKey = mw.ustring.lower(mappingsKey)
	return mappings[mappingsKey] or {}
end

return p