Minecraft Wiki
Advertisement

p.unsigned{{unsigned}} および {{undated}} を実装しています。

依存関係[]

[閲覧 | 編集 | 履歴 | キャッシュ破棄]上記の解説は、モジュール:Unsigned/docから参照されています。
local p = {}

local i18n = {
    unsigned = '無署名の',
    undated = '日付のない',
}
p.i18n = i18n

function base( args )
	local type = args.type or 'Unsigned'
	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>– ' .. i18n[ mw.ustring.lower( type ) ] .. 'コメントが',
		'投稿されました。~~' .. nowiki .. '~~ で署名をしてください。</small>'
	}
	if date then
		table.insert( text, 2, date .. 'に' )
	end
	if user then
		local userLinks
		if not user:find( '[^:%x%.%d]' ) and require( 'モジュール:IPAddress' ).isIP( user ) then
			userLinks = '[[特別:投稿記録/' .. user .. '|' .. user .. ']]([[利用者・トーク:' .. user .. '|トーク]])'
		else
			userLinks = '[[利用者:' .. user .. '|' .. user .. ']]([[利用者・トーク:' .. user .. '|トーク]] • [[特別:投稿記録/' .. user .. '|投稿記録]])'
		end
		table.insert( text, 2, userLinks .. 'により' )
	end

	return table.concat( text )
end

p.unsigned = function( f )
	local args = require( 'モジュール:ProcessArgs' ).norm( f.args or f )
	local type = args.type or 'Unsigned'
	local user = args.user
	local date = args.date
	
	local category = { '<!-- テンプレート:' .. 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, '[[カテゴリ:テンプレート:Unsignedが正しく使用されていないページ]]' )
		elseif type == 'Undated' and not date then
			table.insert( category, '[[カテゴリ:テンプレート:Undatedが正しく使用されていないページ]]' )
		end
		table.insert( category, '[[カテゴリ:テンプレートの置換を必要とするページ]]' )
	end
	
	return base( args ) .. table.concat( category )
end

return p
Advertisement