모듈:Category handler/shared

Utolee90 (토론 | 기여)님의 2017년 1월 27일 (금) 02:01 판 (판 1개를 가져왔습니다: 위키백과 등->자유위키에서 모듈 가져옴)

{{#css: .template-documentation {

   clear: both;
   margin: 1em 0 0 0;
   padding: 1em

} /* 아래 상자 */ .mbox-text {

   clear: both;
   background-color: #e8ffe8;

}

.template-documentation-template-data .mw-templatedata-doc-desc {

   display: none;

}

}}

설명문서 [보기] [편집] [역사] [새로 고침]
이 모듈 문서의 출처는 위키백과:모듈:Category handler/shared입니다.
위 설명은 모듈:Category handler/shared/설명문서의 내용을 가져와 보여주고 있습니다.
연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는 /설명문서에 넣어주세요. 이 틀의 하위문서.

-- 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 = 'Module: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