Minecraft Wiki
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 1: Riga 1:
 
local p = {}
 
local p = {}
  +
function base( args )
p.unsigned = function( f )
 
local args = require( 'Modulo:ProcessArgs' ).norm( f.args or f )
 
 
local type = args.type or 'Non firmato'
 
local type = args.type or 'Non firmato'
 
local user = args.user
 
local user = args.user
Riga 15: Riga 14:
 
local text = {
 
local text = {
 
'<small>–Il commento ' .. mw.ustring.lower( type ) .. ' precedente è stato aggiunto',
 
'<small>–Il commento ' .. mw.ustring.lower( type ) .. ' precedente è stato aggiunto',
'. Per favore firma i tuoi post con ~~' .. nowiki .. '~~</small><!-- Template:' .. type .. ' -->'
+
'. Per favore firma i tuoi post con ~~' .. nowiki .. '~~</small>'
 
}
 
}
 
if date then
 
if date then
Riga 29: Riga 28:
 
table.insert( text, 2, ' da ' .. userLinks )
 
table.insert( text, 2, ' da ' .. userLinks )
 
end
 
end
  +
  +
return table.concat( text )
  +
end
  +
 
p.unsigned = function( f )
 
local args = require( 'Module:ProcessArgs' ).norm( f.args or f )
  +
local type = args.type or 'Unsigned'
  +
local user = args.user
  +
local date = args.date
 
 
  +
local category = { '<!-- Template:' .. type .. ' -->' }
 
if mw.isSubsting() then
 
if mw.isSubsting() then
 
-- Don't allow substitution with missing required arg
 
-- Don't allow substitution with missing required arg
Riga 43: Riga 52:
 
elseif mw.title:getCurrentTitle().namespace ~= 10 then
 
elseif mw.title:getCurrentTitle().namespace ~= 10 then
 
if type == 'Unsigned' and not user then
 
if type == 'Unsigned' and not user then
table.insert( text, '[[Categoria:Template unsigned non usato correttamente]]' )
+
table.insert( category, '[[Categoria:Template unsigned non usato correttamente]]' )
 
elseif type == 'Undated' and not date then
 
elseif type == 'Undated' and not date then
table.insert( text, '[[Categoria:Template undated non usato correttamente]]' )
+
table.insert( category, '[[Categoria:Template undated non usato correttamente]]' )
 
end
 
end
table.insert( text, '[[Categoria:Pagina con template che richiedono la sostituzione]]' )
+
table.insert( category, '[[Categoria:Pagina con template che richiedono la sostituzione]]' )
 
end
 
end
 
 
return table.concat( text )
+
return base( args ) .. table.concat( category )
 
end
 
end
  +
 
return p
 
return p

Versione delle 12:45, 13 set 2020

La documentazione per questo modulo può essere creata in Modulo:Unsigned/doc

local p = {}
function base( args )
	local type = args.type or 'Non firmato'
	local user = args.user
	local date = args.date
	if date and not date:find( '%(UTC%)$' ) then
		date = date .. ' (UTC)'
	end
	local nowiki = ''
	if mw.isSubsting() then
		nowiki = '<nowiki/>'
	end
	
	local text = {
		'<small>–Il commento ' .. mw.ustring.lower( type ) .. ' precedente è stato aggiunto',
		'. Per favore firma i tuoi post con ~~' .. nowiki .. '~~</small>'
	}
	if date then
		table.insert( text, 2, ' at ' .. date )
	end
	if user then
		local userLinks
		if not user:find( '[^:%x%.%d]' ) and require( 'Modulo:IPAddress' ).isIP( user ) then
			userLinks = '[[Speciale:Contributi/' .. user .. '|' .. user .. ']] ([[Discussioni utente:' .. user .. '|discussione]])'
		else
			userLinks = '[[Utente:' .. user .. '|' .. user .. ']] ([[Discussioni utente:' .. user .. '|discussione]] • [[Speciale:Contributi/' .. user .. '|contributi]])'
		end
		table.insert( text, 2, ' da ' .. userLinks )
	end

	return table.concat( text )
end

p.unsigned = function( f )
	local args = require( 'Module:ProcessArgs' ).norm( f.args or f )
	local type = args.type or 'Unsigned'
	local user = args.user
	local date = args.date
	
	local category = { '<!-- Template:' .. type .. ' -->' }
	if mw.isSubsting() then
		-- Don't allow substitution with missing required arg
		if type == 'Unsigned' and not user then
			local dateArg = ''
			if date then
				dateArg = '||' .. date
			end
			return '{{Unsigned' .. dateArg .. '}}'
		elseif type == 'Undated' and not date then
			return '{{Undated}}'
		end
	elseif mw.title:getCurrentTitle().namespace ~= 10 then
		if type == 'Unsigned' and not user then
			table.insert( category, '[[Categoria:Template unsigned non usato correttamente]]' )
		elseif type == 'Undated' and not date then
			table.insert( category, '[[Categoria:Template undated non usato correttamente]]' )
		end
		table.insert( category, '[[Categoria:Pagina con template che richiedono la sostituzione]]' )
	end
	
	return base( args ) .. table.concat( category )
end

return p