モジュール:サンドボックス/Q8j/UserAN

モジュールの解説[作成]
local p = {} --p はパッケージの p です。この変数名は何でも構いません。
-- target=利用者名、type=type、status=状態
function p.Main( frame )
	--Local宣言
	local username = mw.uri.decode(frame.args['target'],'WIKI')
	local userping = "[[利用者:" .. username .. "]]"
	local usernolink = "利用者:" .. username
	local talk = "[[利用者‐会話:" .. username .. "|会話]]"
	local contributions = "[[特別:投稿記録/" .. username .. "|投稿記録]]"
	local log = "[//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録]"
	local ca = "[[特別:アカウント統一管理/" .. username .. "|CA]]"
	local block = "[[特別:投稿ブロック/" .. username .. "|ブロック]]"
	local guc = "[https://guc.toolforge.org/index.php?user=" .. username .. " guc]"
	local whois4 = "[https://whois.domaintools.com/" .. username .. " IPv4]"
	local whois6 = "[https://www.ultratools.com/tools/ipv6InfoResult?ipAddress=" .. username .. " IPv6]"
	local forip = "IP:" .. username .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. ")</span>"
	local forping = userping .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local forusernolink =  usernolink .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local icon = {
		done = '[[File:Yes check.svg|20px|<span class="done">済</span>]]',
		doing = '[[File:Stock post message.svg|22px|<span class="doing">未了</span>]]',
		reject = '[[File:X mark.svg|15px|<span class="done">却下</span>]] <span style="font-weight: bold;">却下</span>',
	}
	local type2 = string.lower(frame.args["type"])
	local statusA = string.lower(frame.args["status"])
	local statusB = frame.args["status2"]
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			mtype = forusernolink
		elseif type2 == 'diff' then
			mtype = '[[特別:差分/' .. username .. ']]の投稿者'
		elseif type2 == 'logid' then
			mtype = '[[特別:転送/logid/' .. username .. ']]の利用者'
		else
			mtype = forping
		end
	-- type判定ここまで

	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "<small>'''" .. frame.args["status"] .. "'''</small>"
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 

end
function p.test1( frame )
	-- test1。[[Template‐ノート:UserAN#引数「type」のUserNoLink(UNL)について]]([[Special:Diff/84301971]])。提案通りPageIDで転送するもの
	--Local宣言
	local username = mw.uri.decode(frame.args['target'],'WIKI')
	local userping = "[[利用者:" .. username .. "]]"
	local usernolink = "利用者:" .. username
	local talk = "[[利用者‐会話:" .. username .. "|会話]]"
	local contributions = "[[特別:投稿記録/" .. username .. "|投稿記録]]"
	local log = "[//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録]"
	local ca = "[[特別:アカウント統一管理/" .. username .. "|CA]]"
	local block = "[[特別:投稿ブロック/" .. username .. "|ブロック]]"
	local guc = "[//xtools.wmflabs.org/globalcontribs/ipr-" .. username .. " xtool]"
	local whois4 = "[https://whois.domaintools.com/" .. username .. " IPv4]"
	local whois6 = "[https://www.ultratools.com/tools/ipv6InfoResult?ipAddress=" .. username .. " IPv6]"
	local forip = "IP:" .. username .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. ")</span>"
	local forping = userping .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local forusernolink =  usernolink .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local icon = {
		done = '[[File:Yes check.svg|20px|<span class="done">済</span>]]',
		doing = '[[File:Stock post message.svg|22px|<span class="doing">未了</span>]]',
		reject = '[[File:X mark.svg|15px|<span class="done">却下</span>]] <span style="font-weight: bold;">却下</span>',
	}
	local type2 = string.lower(frame.args["type"])
	local statusA = string.lower(frame.args["status"])
	local statusB = frame.args["status2"]
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			if mw.title.new(username,2).exists then
				mtype = '[[Special:Redirect/page/' .. mw.title.new(username,2).id .. '|利用者:' .. username .. ']]<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
			else
				mtype = forusernolink
			end
		else
			mtype = forping
		end
	-- type判定ここまで

	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "<small>'''" .. frame.args["status"] .. "'''</small>"
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 
end
function p.test2( frame )
	-- test1。[[Template‐ノート:UserAN#引数「type」のUserNoLink(UNL)について]]([[Special:Diff/84301971]])。fullurl、plainlinks
	--Local宣言
	local username = mw.uri.decode(frame.args['target'],'WIKI')
	local userping = "[[利用者:" .. username .. "]]"
	local usernolink = "利用者:" .. username
	local talk = "[[利用者‐会話:" .. username .. "|会話]]"
	local contributions = "[[特別:投稿記録/" .. username .. "|投稿記録]]"
	local log = "[//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録]"
	local ca = "[[特別:アカウント統一管理/" .. username .. "|CA]]"
	local block = "[[特別:投稿ブロック/" .. username .. "|ブロック]]"
	local guc = "[//xtools.wmflabs.org/globalcontribs/ipr-" .. username .. " xtool]"
	local whois4 = "[https://whois.domaintools.com/" .. username .. " IPv4]"
	local whois6 = "[https://www.ultratools.com/tools/ipv6InfoResult?ipAddress=" .. username .. " IPv6]"
	local forip = "IP:" .. username .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. ")</span>"
	local forping = userping .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local forusernolink =  usernolink .. '<span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
	local icon = {
		done = '[[File:Yes check.svg|20px|<span class="done">済</span>]]',
		doing = '[[File:Stock post message.svg|22px|<span class="doing">未了</span>]]',
		reject = '[[File:X mark.svg|15px|<span class="done">却下</span>]] <span style="font-weight: bold;">却下</span>',
	}
	local type2 = string.lower(frame.args["type"])
	local statusA = string.lower(frame.args["status"])
	local statusB = frame.args["status2"]
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			if mw.title.new(username,2).exists then
				mtype = '<span class="plainlinks">[' .. mw.title.new( username , 2 ).fullUrl .. ' 利用者:' .. username .. ']</span><span class="plainlinks" style="font-size:smaller">(' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. ")</span>"
			else
				mtype = forusernolink
			end
		else
			mtype = forping
		end
	-- type判定ここまで

	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "<small>'''" .. frame.args["status"] .. "'''</small>"
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 
	end
return p