Minecraft Wiki Polska
Advertisement
Template-info
Dokumentacja

Using in the {{Dokumentacja}} and {{Dokumentacja/Nagłówek}}

Zależności

Powyższy opis jest dołączany ze strony Moduł:Dokumentacja/opis.

local p = {}
-- Creating a documentation page or transclution through {{subst:doc}}
function p.create( f )
	local args = require( 'Moduł:ProcessArgs' ).norm()
	page = mw.title.getCurrentTitle()
	namespace = args['typ'] or page.nsText
	docPage = args['strona'] or namespace .. ':' .. page.baseText .. '/opis'
	
	local out
	if page.fullText == docPage then
		out = f:preprocess( '{{subst:Szablon:Dokumentacja/preload}}' )
	else
		local templateArgs = {}
		if args['typ'] then
			table.insert( templateArgs, 'typ=' .. args['typ'] )
		end
		if args['strona'] then
			table.insert( templateArgs, 'strona=' .. args['strona'] )
		end
		
		out = '{{Dokumentacja|' .. table.concat( templateArgs, '|' ) .. '}}\n<!-- Kategorie i interwiki umieść na stronie dokumentacji. -->'
		out = out:gsub( '|}}', '}}' )
	end
	
	if not mw.isSubsting() then
		out = f:preprocess( out )
		if args['niekat'] ~= 1 then
			out = out .. '[[Kategoria:Страницы с требующими подстановки шаблонами]]'
		end
	end
	
	return out
end

-- Header on the documentation page
function p.docPage(f)
	local args = require( 'Moduł:ProcessArgs' ).merge( true )
	local badDoc = args['zladok'] or ''
	local noDoc = args['brakdok'] or ''
	if f:callParserFunction( '#dplvar:noheader' ) == '1' then
		if noDoc ~= '' then
			f:callParserFunction( '#dplvar:set', 'notdoc', '1' )
		elseif badDoc ~= '' then
			f:callParserFunction( '#dplvar:set', 'baddoc', '1' )
		end
		return ''
	end
	local page = mw.title.getCurrentTitle()
	local namespace = args['typ'] or page.nsText
	local pageType = 'tym szablonie'
	local pageType2 = 'tego szablonu'
	local pageType3 = 'Szablony'


	if namespace == 'Moduł' then
		pageType = 'tym module'
		pageType2 = 'tego modułu'
		pageType3 = 'Moduły'
	elseif page.fullText:find( '.css$' ) then
		pageType = 'tem arkuszu stylów'
		pageType2 = 'tego arkusza stylów'
		pageType3 = 'Arkusze stylów'
	elseif page.fullText:find( '.js$' ) then
		pageType = 'tym skrypcie'
		pageType2 = 'tego skryptu'
		pageType3 = 'Skrypty'
	elseif namespace == 'MediaWiki' then
		pageType = 'tej wiadomości systemowej'
		pageType2 = 'tej wiadomości systemowej'
		pageType3 = 'Wiadomości'
	end

	local colour = 'EAF4F9'
	local message = ''
	local imageType = ''
	if badDoc ~= '' then
		colour = 'F9F2EA'
		imageType = 'bad'
		message = "'''Dokumentacja " .. pageType .. " została uznana za niepoprawną. Jeżeli chcesz, możesz ją poprawić!'''"
	end
	if noDoc ~= '' then
		imageType = 'no'
		colour = 'F9EAEA'
		message = "'''W " .. pageType .. " nie ma dokumentacji. Jeżeli wiesz jak używać " .. pageType2 .. ", dodaj więcej informacji do dokumentacji.'''"
	end

	local certainty = 'powinna ona być dołączona'
	if pageType2 ~= 'tego szablonu' then
		certainty = 'będzie ona dołączona'
	end
	
	local category = ''
	if args['niekat'] ~= '1' then
		category = '[[Kategoria:Szablony dokumentacji]]'
	end
	
	local out = table.concat( {
		'<div style="margin-bottom: 0.8em; padding: 0.8em 1em 0.7em; background-color: #' .. colour .. '; border: 1px solid #AAA">',
			'<div class="doc-image">[[File:Template-' .. imageType .. 'info.png|60px]]</div>',

			'<div style="float: right">[[' .. page:fullUrl( 'action=purge' ) .. ' ' .. f:preprocess( '{{lc:{{int:purge}}}}' ) .. ']]</div>',
			'<div style="margin: 0">To jest strona dokumentacji, ' .. certainty .. ' na stronie głównej ' .. pageType .. '. Aby uzyskać więcej informacji sprawdź  [[Szablon:Dokumentacja]].</div>',
			message,
		'</div>',
		category
	}, '\n' )
	
	return mw.text.trim( out )
end

-- Wrapper around the documentation on the main page
function p.page( f )
	local args = require( 'Moduł:ProcessArgs' ).merge( true )	
	local page = mw.title.getCurrentTitle()
	local namespace = args['typ'] or page.nsText
	local docPage = mw.title.new( args['strona'] or namespace .. ':' .. page.text .. '/opis' )
	local noDoc = args['brakdok'] or ''
	if not docPage.exists or noDoc ~= '' then
	local noDoc = 1
	local badDoc = nil
	elseif args['zladok'] ~= '' then
		local badDoc = 1
		local noDoc = nil
	end
	local pageType = 'tym szablonie'
	local pageType2 = 'tego szablonu'
	local pageType3 = 'Szablony'

	if namespace == 'Moduł' then
		pageType = 'tym module'
		pageType2 = 'tego modułu'
		pageType3 = 'Moduły'
	elseif page.fullText:find( '.css$' ) then
		pageType = 'tem arkuszu stylów'
		pageType2 = 'tego arkusza stylów'
		pageType3 = 'Arkusze stylów'
	elseif page.fullText:find( '.js$' ) then
		pageType = 'tym skrypcie'
		pageType2 = 'tego skryptu'
		pageType3 = 'Skrypty'
	elseif namespace == 'MediaWiki' then
		pageType = 'tej wiadomości systemowej'
		pageType2 = 'tej wiadomości systemowej'
		pageType3 = 'Wiadomości'

	end

	local docText = ''

	if docPage.exists then
		f:callParserFunction( '#dplvar:set', 'noheader', '1' )
		docText = mw.text.trim( f:expandTemplate{ title = ':' .. docPage.fullText } )
		if f:callParserFunction( '#dplvar:baddoc' ) == '1' then
			badDoc = 1
		end

		if docText == '' then
			noDoc = 1
		else
			docText = '\n' .. docText .. '\n'
		end

		if f:callParserFunction( '#dplvar:notdoc' ) == '1' then
			noDoc = 1
		end
	end
	
	local action = f:preprocess( '{{lc:{{int:editlink}}}}' )
	local preload = ''
	local colour = 'EAF4F9'
	local message = ''
	local category = ''
	local imageType = ''
	if not docPage.exists then
		action = f:preprocess( '{{lc:{{int:create}}}}' )
		preload = '&preload=Szablon:Dokumentacja/preload'
		noDoc = 1
	end
	if noDoc == 1 then
		imageType = 'no'
		colour = 'F9EAEA'
		message = "'''W " .. pageType .. " nie ma dokumentacji. Jeśli wiesz jak używać " .. pageType2 .. ", dodaj odpowiednie informacje.'''"
		if args['niekat'] ~= '1' then
			if mw.title.new( 'Kategoria:' .. pageType3 .. ' bez dokumentacji' ).exists then
				category = '[[Kategoria:' .. pageType3 .. ' bez dokumentacji]]'
			else
				category = '[[Kategoria:Strony bez dokumentacji]]'
			end
		end
	elseif badDoc then
		imageType = 'bad'
		colour = 'F9F2EA'
		message = "'''Dokumentacja " .. pageType .. " została uznanana za niepoprawną. Jeżeli masz czas, uzupełnij ją!'''\n"
		if args['niekat'] ~= '1' then
			if mw.title.new( 'Kategoria:' .. pageType3 .. ' ze złą dokumentacją' ).exists then
				category = '[[Kategoria:' .. pageType3 .. ' ze złą dokumentacją]]'
			else
				category = '[[Kategoria:Strony ze złą dokumentacją]]'
			end
		end
	end
	
	local links = {
		'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
		'[' .. page:fullUrl( 'action=purge' ) .. ' ' .. f:preprocess( '{{lc:{{int:purge}}}}' ) .. ']'
	}
	local footer = ''
	if docPage.exists then
		table.insert( links, 1, '[[' .. docPage.fullText .. '|' .. f:preprocess( '{{lc:{{int:view}}}}' ) .. ']]' )
		footer = table.concat( {
			'<div style="margin: 0.7em -1em -0.7em; background-color: #EAF4F9; border-top: 1px solid #AAA; padding: 0.8em 1em 0.7em; clear: both">\n',
				'<div style="float: right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n',
				'<p style="margin: 0">Powyższy opis jest dołączany ze strony [[' .. docPage.fullText .. ']].</p>\n',
			'</div>\n'
		} )
	end
	
	local out = {
		'<div style="background-color: #' .. colour .. '; border: 1px solid #AAA; padding: 0.8em 1em 0.7em; clear: both">\n',
			'<div style="margin: -0.8em -1em 0.8em; padding: 0.8em 1em 0.7em; background-color: #EAF4F9; border-bottom: 1px solid #AAA">\n',
				'<div class="doc-image">[[File:Template-' .. imageType .. 'info.png|60px]]</div>',
				'<div style="float: right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n',
				'<span style="font-weight: bold; font-size: 130%">Dokumentacja</span>',
			'</div>\n',
			message,
			docText,
			footer,
		'</div>\n',
		category
	}
	
	return mw.text.trim( table.concat( out ) )
end
return p
Advertisement