Module:Sandbox/Bradv/Case

local p = {}

local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local trim = mw.text.trim

local prefix = 'Wikipedia:Arbitration/Requests/Case/'
local ptalk = 'Wikipedia talk:Arbitration/Requests/Case/'

function render ( tbl, count )
	local output = ''
	if (count > 0) then
		local div = mw.html.create( 'div' )
		div
			:css( 'text-align', 'left' )
			:wikitext( '<p>\n' .. table.concat(tbl, '</p><p>\n') .. '</p>\n' )
		output = tostring( div )
	else
		output = "''none''"
	end
	return output
end

function p.dates( frame )
	local case = frame.args[1] or frame.args.case
	return p._dates( case )
end
function p._dates( case )
	local page = prefix .. case
	local pagecontent = mw.title.new(page):getContent()
	local result = {}
	local re = '\n<big>(.-)</big>'
	for str in gmatch (pagecontent, re) do
		table.insert(result, trim(str))
	end
	return render( result, 1 )
end

function p.decision( frame )
	local case = frame.args[1] or frame.args.case
	return p._decision( case )
end
function p._decision( case )
	local page = prefix .. case
	local pagecontent = mw.title.new(page):getContent()
	local fdstart = find(pagecontent, '\n=%s*Final decision')
	local fd = sub(pagecontent, fdstart)
	local result = {}
	local count = 0
	local re = '\n==(.-)=='
	for str in gmatch(fd, re) do
		if find(str, '^%s*Enforcement') then
			--ignore
		else
			if find(str, '^=') then
				s = trim(sub(str, 2))
				table.insert(result, ':[[' .. page .. '#' .. s .. '|' .. s .. ']]')
			else
				table.insert(result, "'''" .. str .. "'''")
			end
			count = count + 1
		end
	end
	
	return render ( result, count )
end

function p.arca( frame )
	local case = frame.args[1] or frame.args.case
	return p._arca( case )
end
function p._arca( case )
	local page = ptalk .. case
	local pagecontent = mw.title.new(page):getContent()
	local result = {}
	local count = 0
	local re = '\n==(.-)=='
	for str in gmatch (pagecontent, re) do
		str = trim(str)
		if find(str, '^Amendment request')
		or find(str, '^Clarification request') then
			table.insert(result, '[[' .. page .. '#' .. str .. '|' .. str .. ']]')
			count = count + 1
		end
	end
	return render ( result, count )
end

function p.sections( frame )
	local case = frame.args[1] or frame.args.case
	return p._sections( case )
end
function p._sections( case )
	local page = prefix .. case
	local talkpage = ptalk .. case
	
	local result = {}
	
	function add (name)
		local path = ''
		if name then
			path = '/' .. name
		else
			name = 'Case'
		end
		
		local title = mw.title.new(page .. path)
		if (title.exists) then
			table.insert(result, 
				'[[' .. page .. path .. '|' .. name .. ']]'
				.. ' (' .. '[[' .. talkpage .. path .. '|' .. 'talk]])'
				) 
		end
	end
	
	add()
	add('Evidence')
	add('Workshop')
	add('Proposed decision')

	return table.concat(result, ' • ')
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.