<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://splatoonfanon.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFile</id>
	<title>Module:File - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://splatoonfanon.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFile"/>
	<link rel="alternate" type="text/html" href="https://splatoonfanon.org/w/index.php?title=Module:File&amp;action=history"/>
	<updated>2026-04-30T21:34:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://splatoonfanon.org/w/index.php?title=Module:File&amp;diff=412&amp;oldid=prev</id>
		<title>Lakelimbo: Created page with &quot;-- 	This is an updated version of Inkipedia&#039;s File module, less bloated 	and easier to add features if needed. 	In fact, the way it works might as well be used as a base/generic module for 	other things. --  local license = require(&quot;Module:File/Licenses&quot;)  local f = {} local container = mw.html 	.create(&quot;table&quot;) 	:tag(&quot;tr&quot;) 	:tag(&quot;th&quot;) 	:attr({ 		[&quot;colspan&quot;] = 2 	}) 	:css({ 		[&quot;text-align&quot;] = &quot;center&quot; 	}) 	:wikitext(&quot;File information&quot;) 	:done() 	:done()  ---Will conv...&quot;</title>
		<link rel="alternate" type="text/html" href="https://splatoonfanon.org/w/index.php?title=Module:File&amp;diff=412&amp;oldid=prev"/>
		<updated>2025-08-20T15:01:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--[[ 	This is an updated version of Inkipedia&amp;#039;s File module, less bloated 	and easier to add features if needed. 	In fact, the way it works might as well be used as a base/generic module for 	other things. ]]--  local license = require(&amp;quot;Module:File/Licenses&amp;quot;)  local f = {} local container = mw.html 	.create(&amp;quot;table&amp;quot;) 	:tag(&amp;quot;tr&amp;quot;) 	:tag(&amp;quot;th&amp;quot;) 	:attr({ 		[&amp;quot;colspan&amp;quot;] = 2 	}) 	:css({ 		[&amp;quot;text-align&amp;quot;] = &amp;quot;center&amp;quot; 	}) 	:wikitext(&amp;quot;File information&amp;quot;) 	:done() 	:done()  ---Will conv...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
	This is an updated version of Inkipedia&amp;#039;s File module, less bloated&lt;br /&gt;
	and easier to add features if needed.&lt;br /&gt;
	In fact, the way it works might as well be used as a base/generic module for&lt;br /&gt;
	other things.&lt;br /&gt;
]]--&lt;br /&gt;
&lt;br /&gt;
local license = require(&amp;quot;Module:File/Licenses&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local f = {}&lt;br /&gt;
local container = mw.html&lt;br /&gt;
	.create(&amp;quot;table&amp;quot;)&lt;br /&gt;
	:tag(&amp;quot;tr&amp;quot;)&lt;br /&gt;
	:tag(&amp;quot;th&amp;quot;)&lt;br /&gt;
	:attr({&lt;br /&gt;
		[&amp;quot;colspan&amp;quot;] = 2&lt;br /&gt;
	})&lt;br /&gt;
	:css({&lt;br /&gt;
		[&amp;quot;text-align&amp;quot;] = &amp;quot;center&amp;quot;&lt;br /&gt;
	})&lt;br /&gt;
	:wikitext(&amp;quot;File information&amp;quot;)&lt;br /&gt;
	:done()&lt;br /&gt;
	:done()&lt;br /&gt;
&lt;br /&gt;
---Will convert a string with some delimiter into an iterable array,&lt;br /&gt;
---trimming spaces as well.&lt;br /&gt;
---The default delimiter is a comma (`&amp;quot;,%s*&amp;quot;`), but it&amp;#039;s possible to&lt;br /&gt;
---change to something else.&lt;br /&gt;
---&lt;br /&gt;
---Examples:&lt;br /&gt;
---		&amp;quot;foo,bar,baz&amp;quot;			-&amp;gt; { &amp;quot;foo&amp;quot;, &amp;quot;bar&amp;quot;, &amp;quot;baz&amp;quot; }&lt;br /&gt;
---		&amp;quot;green, Yellow   ,Blue&amp;quot;	-&amp;gt; { &amp;quot;green&amp;quot;, &amp;quot;yellow&amp;quot;, &amp;quot;blue&amp;quot; }&lt;br /&gt;
---&lt;br /&gt;
---@param str string&lt;br /&gt;
---@param delimiter string&lt;br /&gt;
---@return string[]&lt;br /&gt;
local function array_from_string(str, delimiter)&lt;br /&gt;
  delimiter = delimiter or &amp;quot;,%s*&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  if not str or #str == 0 then&lt;br /&gt;
    return nil&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  local result = {}&lt;br /&gt;
  local parts = mw.text.split(str, delimiter)&lt;br /&gt;
  &lt;br /&gt;
  for _, s in ipairs(parts) do&lt;br /&gt;
    table.insert(result, mw.text.trim(s))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---Creates a row for an HTML table.&lt;br /&gt;
---Alongside with `rows.list()` down below, if it notices it&amp;#039;s a one-dimensional&lt;br /&gt;
---table (array), likely from `array_from_string()`, it will split each element&lt;br /&gt;
---and add an appropriate space and comma to it.&lt;br /&gt;
---&lt;br /&gt;
---@param name string&lt;br /&gt;
---@content string | string[]&lt;br /&gt;
---@return table&lt;br /&gt;
local function table_row(name, content)&lt;br /&gt;
	local row = container&lt;br /&gt;
		:tag(&amp;quot;tr&amp;quot;)&lt;br /&gt;
		:tag(&amp;quot;th&amp;quot;)&lt;br /&gt;
		:wikitext(name)&lt;br /&gt;
		:done()&lt;br /&gt;
		:tag(&amp;quot;td&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if type(content) == &amp;quot;table&amp;quot; then&lt;br /&gt;
		for k, v in ipairs(content) do&lt;br /&gt;
			if k == #content then&lt;br /&gt;
				row:wikitext(v)&lt;br /&gt;
			else&lt;br /&gt;
				row:wikitext(v .. &amp;quot;, &amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		row:wikitext(content)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	row:done()&lt;br /&gt;
	return row&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---Error message for some elements, if needed.&lt;br /&gt;
---&lt;br /&gt;
---@type message&lt;br /&gt;
---@return string&lt;br /&gt;
local function error_message(message)&lt;br /&gt;
	local span = mw.html.create(&amp;quot;span&amp;quot;)&lt;br /&gt;
		:css({&lt;br /&gt;
			[&amp;quot;color&amp;quot;] = &amp;quot;red&amp;quot;,&lt;br /&gt;
		})&lt;br /&gt;
		:wikitext(message)&lt;br /&gt;
		:done()&lt;br /&gt;
		&lt;br /&gt;
	return tostring(span)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---The list of elements to create a row.&lt;br /&gt;
---You can add any custom items with your own logic, as long as it returns&lt;br /&gt;
---`table_row()`.&lt;br /&gt;
---Even though on MW it&amp;#039;s not necessary, it&amp;#039;s good to adapt the parameter types&lt;br /&gt;
---if you happen to need something different other than args that have string&lt;br /&gt;
---values (e.g: `table&amp;lt;string, string | number&amp;gt;`).&lt;br /&gt;
---&lt;br /&gt;
---@type table&amp;lt;string, fun(content: string, args: table&amp;lt;string, string&amp;gt;)&amp;gt;&lt;br /&gt;
---@return table&lt;br /&gt;
local rows = {&lt;br /&gt;
    list = function(content, args)&lt;br /&gt;
        local lists = array_from_string(content)&lt;br /&gt;
        &lt;br /&gt;
        if not lists or #lists == 0 then&lt;br /&gt;
            return table_row(args.name, error_message(args.error))&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        for _, list in ipairs(lists) do&lt;br /&gt;
            container:wikitext(&amp;quot;[[Category:&amp;quot; .. list .. &amp;quot; files]]&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        return table_row(args.name, lists)&lt;br /&gt;
    end,&lt;br /&gt;
	text = function(content, args)&lt;br /&gt;
		local error = args.error or &amp;quot;Not provided&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		if not content or content == &amp;quot;&amp;quot; then&lt;br /&gt;
			content = &amp;quot;&amp;#039;&amp;#039;&amp;quot; .. error .. &amp;quot;&amp;#039;&amp;#039;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		table_row(args.name, content)&lt;br /&gt;
	end,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function f.main(frame)&lt;br /&gt;
	local param = frame.args&lt;br /&gt;
	&lt;br /&gt;
    rows.list(param.work, { name = &amp;quot;Work&amp;quot;, error = &amp;quot;ERROR: invalid or empty work&amp;quot; })&lt;br /&gt;
    rows.text(param.description, { name =&amp;quot;Description&amp;quot; })&lt;br /&gt;
    rows.list(param.author, { name = &amp;quot;Author&amp;quot;, error = &amp;quot;ERROR: invalid author&amp;quot; })&lt;br /&gt;
    rows.list(param.characters, { name = &amp;quot;Characters&amp;quot;, error = &amp;quot;ERROR: invalid character&amp;quot; })&lt;br /&gt;
    rows.text(param.source, { name = &amp;quot;Source&amp;quot; })&lt;br /&gt;
    rows.text(license.get_license(param.license), { name = &amp;quot;License&amp;quot; })&lt;br /&gt;
    &lt;br /&gt;
    return tostring(container)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return f&lt;/div&gt;</summary>
		<author><name>Lakelimbo</name></author>
	</entry>
</feed>