Module:Government/list: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
(create)
 
(Updating Torn leadership)
 
(33 intermediate revisions by 2 users not shown)
Line 4: Line 4:
--  *Each position on its own line as follows:
--  *Each position on its own line as follows:
--    position name - position holder(s) separated by a comma and space
--    position name - position holder(s) separated by a comma and space
--    Optionally, each position holder can have a specialization specified in square brackets preceded by a space, e.g.
--      Position - Person [duties], Some Guy, Other Person [other duties]
--      Therefore, names cannot contain square brackets.
--  *Do not pluralize position names, and don't use abbreviations. These are added in Module:Government.
--  *Do not pluralize position names, and don't use abbreviations. These are added in Module:Government.
--  *Empty lines can be used for readability, they will be ignored
--  *Empty lines can be used for readability and will be ignored.
--To test changes, type =p in the console below and press Enter. It should return "table".
--The intention is that the list can be maintained elsewhere and copy-pasted here when an update is needed, or vice versa.
--To smoke-test changes, type =p in the console below and press Enter. It should return "table".


--only edit below the following line
--only edit below the following line
Line 15: Line 19:


Administrator - Lord of Darkness, Frawley, Jesse End
Administrator - Lord of Darkness, Frawley, Jesse End
Moderator - Edward I, Imperial Emperor, Tebeat, Malabyte, Marina, Qazzian, Xoriet
Moderator - Edward I, Tebeat, Malabyte, Marina, Qazzian, Xoriet


----
----
Line 24: Line 28:
Legatus - Xoriet
Legatus - Xoriet
Praetor - Marina
Praetor - Marina
Censor - Shnailand
Censor - ShnailandC
Tribune - Jar Wattinree
Tribune - Jar Wattinree
Vox Populi - Dimitri
Vox Populi - Dimitri
Line 33: Line 37:
Emperor - Lord of Darkness
Emperor - Lord of Darkness
Regent - Jesse End
Regent - Jesse End
Imperial Officer - DeathAdder, Emperor Ice, SynysterGates, Tebeat
Imperial Officer - DeathAdder [military/diplomacy], Emperor Ice [military/economy], SynysterGates, Tebeat [internal]


Exarch - jgolla, Llednar Twem, Eric the Red, Edward I, Amyameretta
Exarch - jgolla, Llednar Twem, Eric the Red, Edward I, Amyameretta
Line 46: Line 50:
Torn
Torn


Emperor - SynysterGates
Emperor - Nemphesis
Regent - Tiberius
Regent - Deatvert
Imperial Officer - Dan100, Pansy, Keshav, Antiega, Community
Imperial Officer - SableCanary, Selina, Nijil1, OsRavan, Xoriet, Altmoras
Counselor - Lord of Darkness, Red
Imperial Governor - DarkParticle, Pep_9090
Counselor - Lord of Darkness, Jgolla, Dan100
 
General - Twobagger
Colonel - Gandroff, Pixxiec, Nerdypeep, Happy_as
 
Provost - Iamthey
Deputy Provost - Ultravi0let, Pressure
 
Intelligence Director - N/A
 
Executive - TBD


]=]--only edit above this line
]=]--only edit above this line
Line 57: Line 72:


local function strip(s)
local function strip(s)
--trim, lowercase, and remove non-alphanumeric characters
--trim, lowercase, and remove non-alphanumeric characters. Also used in base module
return mw.text.trim(mw.ustring.gsub(mw.ustring.lower(s), '%W', ''))
return mw.text.trim(mw.ustring.gsub(mw.ustring.lower(s or ''), '%W', ''))
end
end



Latest revision as of 23:55, 9 June 2023

Documentation [edit]

This is a data module to be used with mw.loadData. It parses the regular text list and returns the formatted data structure. This is meant to be an easy way to keep external lists in sync with the wiki.

See the comments at the top for how to modify the list. Only edit between the marked lines. Please check for errors before saving.

If changes to functionality are needed, please contact an administrator.

The above documentation is transcluded from Module:Government/list/doc.

--The list must follow this format:
--  *Game/category blocks separated by a series of at least one hyphen on its own line
--  *Game/category name on its own line at the beginning of the block
--  *Each position on its own line as follows:
--     position name - position holder(s) separated by a comma and space
--     Optionally, each position holder can have a specialization specified in square brackets preceded by a space, e.g.
--       Position - Person [duties], Some Guy, Other Person [other duties]
--       Therefore, names cannot contain square brackets.
--  *Do not pluralize position names, and don't use abbreviations. These are added in Module:Government.
--  *Empty lines can be used for readability and will be ignored.
--The intention is that the list can be maintained elsewhere and copy-pasted here when an update is needed, or vice versa.
--To smoke-test changes, type =p in the console below and press Enter. It should return "table".

--only edit below the following line
local list = [=[

----
Community

Administrator - Lord of Darkness, Frawley, Jesse End
Moderator - Edward I, Tebeat, Malabyte, Marina, Qazzian, Xoriet

----
NationStates

Emperor - Lord of Darkness
Consul - Elegarth
Legatus - Xoriet
Praetor - Marina
Censor - ShnailandC
Tribune - Jar Wattinree
Vox Populi - Dimitri

----
Cyber Nations

Emperor - Lord of Darkness
Regent - Jesse End
Imperial Officer - DeathAdder [military/diplomacy], Emperor Ice [military/economy], SynysterGates, Tebeat [internal]

Exarch - jgolla, Llednar Twem, Eric the Red, Edward I, Amyameretta

General - Antiega
Colonel - Eclipse

Prefect - Eric the Red
Tribune - Necrosin, Biowulf

----
Torn

Emperor - Nemphesis
Regent - Deatvert
Imperial Officer - SableCanary, Selina, Nijil1, OsRavan, Xoriet, Altmoras
Imperial Governor - DarkParticle, Pep_9090
Counselor - Lord of Darkness, Jgolla, Dan100

General - Twobagger
Colonel - Gandroff, Pixxiec, Nerdypeep, Happy_as

Provost - Iamthey
Deputy Provost - Ultravi0let, Pressure

Intelligence Director - N/A

Executive - TBD

]=]--only edit above this line

--the separator between position names and occupants
local sep = ' - '

local function strip(s)
	--trim, lowercase, and remove non-alphanumeric characters. Also used in base module
	return mw.text.trim(mw.ustring.gsub(mw.ustring.lower(s or ''), '%W', ''))
end

local struct = {}
local title, positions
local subStart, subEnd
for game in mw.text.gsplit(list, '\n%-+\n') do
	title = nil
	positions = {}
	for line in mw.text.gsplit(game, '\n') do
		line = mw.text.trim(line)
		if line ~= '' then
			if not title then
				title = line
			else
				subStart, subEnd = mw.ustring.find(line, sep, 1, true)
				if not subStart or not subEnd then
					return '<span class="error">Parse error in [[Module:Government/list]]: ' .. line .. '</span>'
				else
					positions[strip(mw.ustring.sub(line, 1, subStart - 1))] =
						mw.text.trim(mw.ustring.sub(line, subEnd + 1))
				end
			end
		end
	end
	if title then
		struct[strip(title)] = positions
	end
end

return struct