Module:Arbitration Committee open tasks/sandbox

local p = {}

local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local match = mw.ustring.match
local trim = mw.text.trim
local insert = table.insert
local concat = table.concat

function p.caserequests ( frame )
	frame = frame or mw.getCurrentFrame()
	local page = mw.title.new('Wikipedia:Arbitration/Requests/Case'):getContent()
	
	local re = '\n==%f[^=](.-)=='
	local sections = {}
	local count, loc = 0, 0
	repeat
		loc = find(page, re, loc+1)
		if (loc) then
			count = count + 1
			sections[count] = {
				id = count, 
				start = loc,
				title = trim(match(page, re, loc))
			}
		end
	until not loc
	
	for i=1, count, 1 do
		local sec = sections[i]
		local content = ''
		if sections[i+1] then
			content = sub( page, sec.start, sections[i+1].start )
		else
			content = sub( page, sec.start )
		end
		
		local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'
		sec.date = match(content, redate)
		
		local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?'
		local m = match(content, remotion)
		if (m) then 
			sec.motion = trim(m)
		end
		
		local revotes = '\n===[^\n]*<(%d+/%d+/%d+)>%s*==='
		sec.votes = match(content, revotes)
	end

	local result = {}
	for i=1, count, 1 do
		local sec = sections[i]
		local s = frame:expandTemplate{
			title = 'ArbComOpenTasks/line',
			args = {
				mode = 'caserequest',
				name = sec.title,
				date = sec.date,
				motion = sec.motion,
				votes = sec.votes
			}
		}
		insert(result, s)
	end
	
	return concat(result, '\n')
end

function p.arca ( frame )
	frame = frame or mw.getCurrentFrame()
	local page = mw.title.new('User:SilverLocust/sandbox/7'):getContent()
	
	local re = '\n==%f[^=](.-)=='
	local sections = {}
	local count, loc = 0, 0
	repeat
		loc = find(page, re, loc+1)
		if (loc) then
			count = count + 1
			sections[count] = {
				id = count, 
				start = loc,
				title = trim(match(page, re, loc))
			}
		end
	until not loc
	
	for i=1, count, 1 do
		local sec = sections[i]
		local content = ''
		if sections[i+1] then
			content = sub( page, sec.start, sections[i+1].start )
		else
			content = sub( page, sec.start )
		end
		
		local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'
		sec.date = match(content, redate)

		local remotion = '\n====?([^\n]*[Mm]otion[^\n]-)====?'
		local m = match(content, remotion)
		if (m) then 
			sec.motion = trim(m)
		end
		
		local relink = '{{RFARlinks%|(.-)}}'
		sec.link = match(content, relink)
	end

	local result = {}
	for i=1, count, 1 do
		local sec = sections[i]
		local s = frame:expandTemplate{
			title = 'ArbComOpenTasks/line',
			args = {
				mode = 'amendment',
				name = sec.title,
				date = sec.date,
				motion = sec.motion,
				link = sec.link
			}
		}
		insert(result, s)
	end
	
	return concat(result, '\n')
end

function p.motions ( frame )
	frame = frame or mw.getCurrentFrame()
	local page = mw.title.new('Wikipedia:Arbitration/Requests/Motions'):getContent()
	local re = '\n==%f[^=](.-)=='
	local sections = {}
	local count, loc = 0, 0
	repeat
		loc = find(page, re, loc+1)
		if (loc) then
			count = count + 1
			sections[count] = {
				id = count, 
				start = loc,
				title = trim(match(page, re, loc))
			}
		end
	until not loc
	
	for i=1, count, 1 do
		local sec = sections[i]
		local content = ''
		if sections[i+1] then
			content = sub( page, sec.start, sections[i+1].start )
		else
			content = sub( page, sec.start )
		end
		
		local redate = '%d%d?%s%a*%s%d%d%d%d%f[(%s%(UTC%)]'
		sec.date = match(content, redate)
	end

	local result = {}
	for i=1, count, 1 do
		local sec = sections[i]
		local s = frame:expandTemplate{
			title = 'ArbComOpenTasks/line',
			args = {
				mode = 'motion',
				name = sec.title,
				date = sec.date,
			}
		}
		insert(result, s)
	end
	
	return concat(result, '\n')
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.