Перейти к содержанию

Модуль:PagesWithScans

Материал из marxopedia
Версия от 21:35, 2 января 2025; Alexey (обсуждение | вклад) (Новая страница: «local ps = {} function ps.category( frame ) -- local objTitle, cTxt, nPos, nPos1, nPos2, i, yes_no -- local text_find = {'<pagesindex','{{#lst','{{#section'} local objTitle, cTxt, nPos, nPos1, i, yes_no local text_find = {'<pagesindex','{{Страница|'} objTitle = mw.title.getCurrentTitle() if objTitle.namespace ~= 0 then return end cTxt = objTitle:getContent() if not cTxt then return end cTxt = mw.ustring.lower(mw.ustring.gsub(cTxt, ' ', '...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

Для документации этого модуля может быть создана страница Модуль:PagesWithScans/doc

local ps = {}

function ps.category( frame )
	-- local objTitle, cTxt, nPos, nPos1, nPos2, i, yes_no
	-- local text_find = {'<pagesindex','{{#lst','{{#section'}
	local objTitle, cTxt, nPos, nPos1, i, yes_no
	local text_find = {'<pagesindex','{{Страница|'}


	objTitle = mw.title.getCurrentTitle()
	if objTitle.namespace ~= 0 then return end

	cTxt = objTitle:getContent()
	if not cTxt then return end
	cTxt = mw.ustring.lower(mw.ustring.gsub(cTxt, ' ', ''))
	
	yes_no = false
	-- for i = 1, 3 do
	for i = 1, 2 do
		nPos = mw.ustring.find(cTxt, text_find[i], 1, true)
		if nPos ~= nil then
			yes_no = true
			break
		end
	end

	if yes_no then
			return '[[Категория:Страницы со сканами]]'
	else
		nPos1 = mw.ustring.find(cTxt, '{{СписокРедакций', 1, true)
		nPos2 = mw.ustring.find(cTxt, '{{Неоднозначность', 1, true)

		if nPos1 ~= nil or nPos2 ~= nil then
			return ''
		else
			return '[[Категория:Страницы без сканов]]'
		end
	end

end

return ps