Модуль:Chronicle

Материал из Справочника наблюдателя
Перейти к:навигация, поиск

(i)      Описание модуля[]

Документация отсутствует!


local p={}

p.chapName = {
	['']      = 'Новости сайта',
	none      = 'Новости сайта',
	wiki      = 'Новости сайта',
	article   = 'Новые статьи',
	news      = 'Новости',
	law       = 'Документы',
	elections = 'Выборы',
	lawnews   = 'Новости законодательства',
}

p.chapIcon = {
	['']      = '∇',
	none      = '∇',
	wiki      = '∇',
	article   = '<i class="far fa-file-alt"></i>',
	news      = '<i class="far fa-newspaper"></i>',
	law       = '<i class="fa fa-book"></i>',
	elections = '<i class="far fa-check-square"></i>',
	lawnews   = '[[Файл:Seal1.svg|x20px|link=]]',
}

p.streamName = {
	['lawnews'] = 'Новости законодательства',
	['sitenews'] = 'Новости сайта',
	['elections'] = 'Выборы',
}
p.streamCondition = {
	['lawnews'] = '[[Chronicle Type::lawnews]]',
	['sitenews'] = '[[Chronicle Type::wiki||article||law]]',
	['elections'] = '[[Chronicle Type::elections]]',
}



function p.StreamCondition (frame)
	return p.streamCondition[frame.args[1]]
end		

function p.StreamName (frame)
	return p.streamName[frame.args[1]]
end		

function p.ChapName (frame)
	return p.chapName[frame.args[1]]
end		

function p.ChapIcon (frame)
	return p.chapIcon[frame.args[1]]
end		

function p.SortCat(frame)
	local cats = frame.args[1] or '-'
	local tags ={}
	local chapters = {}
	local res 
	if cats ~= '-' then
		cats = mw.ustring.sub(cats, 3, -3)
		cats = mw.text.split(cats, ']],  [[', true)
		for k, v in ipairs (cats) do
			-- v = Категория:х|х
			-- х = ChChap:рубрика либо тег
			local vv = mw.ustring.match(v, '^[^%|]+%|([^%|]+)$')
			if vv then
				if mw.ustring.sub(vv, 1, 7) == 'ChChap:' then
					table.insert (chapters, (p.chapName[mw.ustring.sub(vv, 8, -1)] or p.chapName[none]))
				else
					table.insert (tags, '[' 
						.. tostring (mw.uri.fullUrl('Chronicle:Select',{tag=vv})) .. ' ' .. vv .. ']')
				end
			else
				return 'ERROR: «' .. v .. '»'
			end
		end	
	end	
	res = ' &nbsp; &nbsp; <i class="far fa-folder cursor-help" title="Рубрики"></i> '
	if #chapters == 0 then
		res = res .. '<i>вне рубрик</i>'
--	elseif #chapters == 1 then
--		res = res .. ' в рубрике <b>' .. chapters[1] .. '</b>'
	else
		res = res .. '<b>' .. table.concat(chapters, '</b>, <b>') .. '</b>'
	end
	res = res .. ' &nbsp; &nbsp; <i class="fas fa-tags cursor-help" title="Теги"></i> '
	if #tags == 0 then
		res = res .. '<i>без тегов</i>'
	else
		res = res .. '<b>' .. table.concat(tags, '</b>, <b>') .. '</b>'
	end
	return res
end

return p