<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://elite.mistflux.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ANaval_Vessel_Register</id>
	<title>Module:Naval Vessel Register - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://elite.mistflux.co.uk/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ANaval_Vessel_Register"/>
	<link rel="alternate" type="text/html" href="https://elite.mistflux.co.uk/w/index.php?title=Module:Naval_Vessel_Register&amp;action=history"/>
	<updated>2026-10-31T17:21:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://elite.mistflux.co.uk/w/index.php?title=Module:Naval_Vessel_Register&amp;diff=112597&amp;oldid=prev</id>
		<title>Wikipedia&gt;Pppery: Changed protection settings for &quot;Module:Naval Vessel Register&quot;: Match template ([Edit=Require template editor access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://elite.mistflux.co.uk/w/index.php?title=Module:Naval_Vessel_Register&amp;diff=112597&amp;oldid=prev"/>
		<updated>2025-07-29T00:48:06Z</updated>

		<summary type="html">&lt;p&gt;Changed protection settings for &amp;quot;&lt;a href=&quot;/wiki/Module:Naval_Vessel_Register&quot; title=&quot;Module:Naval Vessel Register&quot;&gt;Module:Naval Vessel Register&lt;/a&gt;&amp;quot;: Match template ([Edit=Require template editor access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local get_args = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;&lt;br /&gt;
local nvr_url_mod = require (&amp;#039;Module:Naval Vessel Register URL&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local prefix = &amp;#039;[[File:PD-icon.svg|12px|class=noviewer|link=|alt=Public Domain]]&amp;amp;nbsp;This article incorporates [[Copyright status of works by the federal government of the United States|public domain material]] from&amp;#039;;&lt;br /&gt;
local postfix = &amp;#039;the \&amp;#039;\&amp;#039;[[Naval Vessel Register]]\&amp;#039;\&amp;#039;.&amp;#039;&lt;br /&gt;
&lt;br /&gt;
local namespace = mw.title.getCurrentTitle().namespace;							-- used for categorization&lt;br /&gt;
local category = 0 == namespace and &amp;#039;[[Category:Wikipedia articles incorporating text from the Naval Vessel Register]]&amp;#039; or &amp;#039;&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E P _ L I S T _ M A K E &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
create a separated list according to the number of items in the list (2 or more) – don&amp;#039;t call this function when&lt;br /&gt;
there is only one item in the list.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function sep_list_make (list_t)&lt;br /&gt;
	local count = #list_t;														-- get the number of items in the list&lt;br /&gt;
	local list = &amp;#039;&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
	local sep_list_pair = &amp;#039; and &amp;#039;;												-- for a list of two items&lt;br /&gt;
	local sep_list = &amp;#039;, &amp;#039;;														-- and these for lists of three or more items&lt;br /&gt;
	local sep_list_end = &amp;#039;, and &amp;#039;;&lt;br /&gt;
&lt;br /&gt;
	if 2 &amp;gt;= count then&lt;br /&gt;
		list = table.concat (list_t, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item&lt;br /&gt;
	elseif 2 &amp;lt; count then&lt;br /&gt;
		list = table.concat (list_t, sep_list, 1, count - 1);					-- concatenate all but last item with plain list separator&lt;br /&gt;
		list = table.concat ({list, list_t[count]}, sep_list_end);				-- concatenate last item onto end of &amp;lt;list&amp;gt; with final separator&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return list;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L I N K _ M A K E &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
call Module:Naval Vessel Register URL to make an ext link to the NVR page associated with &amp;lt;hull&amp;gt; (the ship&amp;#039;s hull&lt;br /&gt;
designator).  When &amp;lt;title&amp;gt; is set, use that value as the ext link&amp;#039;s display value.  When &amp;lt;title&amp;gt; is not set,&lt;br /&gt;
instruct NVR url to provide a display label (ship&amp;#039;s name with parenthetical hull designator)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function link_make (hull, title, archive)&lt;br /&gt;
	local name = not title and &amp;#039;nh&amp;#039;;											-- &amp;lt;name&amp;gt; set to &amp;#039;nh&amp;#039; tells NVR url to return ship&amp;#039;s name and hull designator as display label; TODO: better rvalue?&lt;br /&gt;
&lt;br /&gt;
	local nvr_link = nvr_url_mod._nvr_url_make ({[&amp;#039;id&amp;#039;]=hull, [&amp;#039;title&amp;#039;]=title, [&amp;#039;name&amp;#039;]=name});&lt;br /&gt;
	if archive then&lt;br /&gt;
		nvr_link = string.format (&amp;#039;%s &amp;lt;span style=&amp;quot;font-size: 85%%;&amp;quot;&amp;gt;([%s Archived])&amp;lt;/span&amp;gt;&amp;#039;, nvr_link, archive);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return nvr_link;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; R E N D E R &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
assemble the various parts into the final rendering&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function render (list_t)&lt;br /&gt;
	local count = #list_t;&lt;br /&gt;
	&lt;br /&gt;
	if 0 == count then&lt;br /&gt;
		return string.format (&amp;#039;%s %s%s&amp;#039;, prefix, postfix, category);			-- the no ext link generic rendering&lt;br /&gt;
&lt;br /&gt;
	else&lt;br /&gt;
		return string.format (&amp;#039;%s %s at %s%s&amp;#039;,									-- the one-or-more ext link rendering&lt;br /&gt;
			prefix,&lt;br /&gt;
			1 == count and list_t[1] or sep_list_make (list_t),					-- a single nvr ext link or a separated list of multiple nvr ext links&lt;br /&gt;
			postfix,&lt;br /&gt;
			category);&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O L D _ F O R M &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
TODO: this function to go away&lt;br /&gt;
&lt;br /&gt;
this function allows support for the current (as of 2025-07-20) {{Naval Vessel Register}} template which uses&lt;br /&gt;
positional parameters.  The rendering isn&amp;#039;t perfect but will suffice until the template is updated to use the&lt;br /&gt;
new parameters.  When all old-form templates have been replaced, this function goes away to be replaced with an&lt;br /&gt;
error message when positional parameters are encountered.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function old_form (args_t)&lt;br /&gt;
	local list_t = {args_t[1], args_t[2]};										-- make a list&lt;br /&gt;
	for i, list_item in ipairs (list_t) do&lt;br /&gt;
		list_t[i] = string.format (&amp;#039;[%s here]&amp;#039;, list_item);						-- format as an ext link&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return render (list_t);														-- and go render the output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A I N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
implements {{Naval Vessel Register}}&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Naval Vessel Register|main}}&lt;br /&gt;
&lt;br /&gt;
has enumerated parameters.  Non-enumerated forms of these parameters are treated as if they had enumerator &amp;#039;1&amp;#039;.&lt;br /&gt;
the enumerators are not bounded except that there must be no gaps between sucessive enumerators.&lt;br /&gt;
&lt;br /&gt;
|hulln=		– (required if |titlen= or |archiven= provided) the ship&amp;#039;s hull number in a form acceptable to {{NVR url}}&lt;br /&gt;
|titlen=	– (optional) any text; when empty or omitted, creates value from {{NVR url}}&lt;br /&gt;
|archiven=	– (optional) url linking to an archived copy of the NVR page&lt;br /&gt;
&lt;br /&gt;
The original form of {{Naval Vessel Register}} accepted one or two optional positional parameters (urls).  During&lt;br /&gt;
the transition from old to new, this module supports both forms.  After the transition, positional parameters&lt;br /&gt;
will cause the module to emit an error message.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function main (frame)&lt;br /&gt;
	local args_t = get_args (frame)&lt;br /&gt;
&lt;br /&gt;
	if args_t[1] then															-- old form with positional parameters; to be discontinued&lt;br /&gt;
		return old_form (args_t);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local unsorted_enumerators_t = {}											-- unsorted  k/v table of enumerators where k is the enumerator and v is always true&lt;br /&gt;
&lt;br /&gt;
	for param, _ in pairs (args_t) do											-- loop through all parameters&lt;br /&gt;
		local enumerator = mw.ustring.match (param, &amp;quot;(%d+)$&amp;quot;)					-- does this parameter have an enumerator?&lt;br /&gt;
		if enumerator then														-- if there is an enumerator&lt;br /&gt;
			unsorted_enumerators_t[tonumber(enumerator)] = true					-- add enumerator to the table&lt;br /&gt;
		else&lt;br /&gt;
			unsorted_enumerators_t[1] = true									-- assume enumerator is 1&lt;br /&gt;
			args_t[param .. &amp;#039;1&amp;#039;] = args_t[param];								-- copy unenumerated parameter value to the enumerated parameter&lt;br /&gt;
			args_t[param] = nil;												-- unset unenumerated parameter because redundant&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local enumerators_t = {}													-- will hold a sorted sequence of enumerators&lt;br /&gt;
	for n, _ in pairs (unsorted_enumerators_t) do								-- loop through the k/v table of enumerators&lt;br /&gt;
		table.insert (enumerators_t, n)											-- add the enumerator to the sequence&lt;br /&gt;
	end&lt;br /&gt;
	table.sort (enumerators_t)													-- and ascending sort&lt;br /&gt;
&lt;br /&gt;
	local list_t = {};															-- list of formatted nvr ext links goes here&lt;br /&gt;
&lt;br /&gt;
	for _, n in ipairs (enumerators_t) do										-- loop through the sorted enumerators&lt;br /&gt;
		table.insert (list_t, link_make (args_t[&amp;#039;hull&amp;#039;..n], args_t[&amp;#039;title&amp;#039;..n], args_t[&amp;#039;archive&amp;#039;..n]));	-- make the nvr page link and add to the list of links&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return render (list_t);														-- and go render the output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T S &amp;gt;----------------------------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	main = main,&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;Pppery</name></author>
	</entry>
</feed>