<?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_URL</id>
	<title>Module:Naval Vessel Register URL - 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_URL"/>
	<link rel="alternate" type="text/html" href="https://elite.mistflux.co.uk/w/index.php?title=Module:Naval_Vessel_Register_URL&amp;action=history"/>
	<updated>2026-11-01T13:01:33Z</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_URL&amp;diff=112599&amp;oldid=prev</id>
		<title>Wikipedia&gt;Pppery: Changed protection settings for &quot;Module:Naval Vessel Register URL&quot;: High-risk template or module ([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_URL&amp;diff=112599&amp;oldid=prev"/>
		<updated>2025-08-11T16:02:19Z</updated>

		<summary type="html">&lt;p&gt;Changed protection settings for &amp;quot;&lt;a href=&quot;/wiki/Module:Naval_Vessel_Register_URL&quot; title=&quot;Module:Naval Vessel Register URL&quot;&gt;Module:Naval Vessel Register URL&lt;/a&gt;&amp;quot;: &lt;a href=&quot;/w/index.php?title=WP:High-risk_templates&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:High-risk templates (page does not exist)&quot;&gt;High-risk template or module&lt;/a&gt; ([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;--[[  &lt;br /&gt;
 &lt;br /&gt;
This module generates links to ships in the Naval Vessel Register (nvr.navy.mil) database.  &lt;br /&gt;
It is used by Template:Naval Vessel Register URL and Template:Naval Vessel Register service craft URL&lt;br /&gt;
 &lt;br /&gt;
Please do not modify this code without applying the changes first at Module:Naval Vessel Register URL/sandbox and testing &lt;br /&gt;
at Module:Naval Vessel Register URL/sandbox/testcases and Module talk:Naval Vessel Register URL/sandbox/testcases.&lt;br /&gt;
 &lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:RP88&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
local get_args = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;&lt;br /&gt;
local data_t = mw.loadData (&amp;#039;Module:Naval Vessel Register URL/data&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ E R R O R _ M E S S A G E &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
General purpose error message function to render error messages and categorization&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_error_message (output, prefix, item, suffix, srv_craft)&lt;br /&gt;
	local category = &amp;#039;&amp;#039;;														-- for concatenation&lt;br /&gt;
	&lt;br /&gt;
	if 0 == mw.title.getCurrentTitle().namespace then							-- article namespace&lt;br /&gt;
		category = &amp;#039;[[Category:WPSHIPS:Template_errors]]&amp;#039;;						-- categorize only from article namespace&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.insert (output, &amp;#039;&amp;lt;span style=&amp;quot;font-size:100%&amp;quot; class=&amp;quot;error&amp;quot;&amp;gt;&amp;#039;)&lt;br /&gt;
	table.insert (output, prefix);&lt;br /&gt;
	table.insert (output, item);&lt;br /&gt;
	table.insert (output, suffix);&lt;br /&gt;
	if srv_craft then&lt;br /&gt;
		table.insert (output, &amp;#039; ([[Template:Naval Vessel Register service craft URL#Error messages|help]])&amp;lt;/span&amp;gt;&amp;#039;);&lt;br /&gt;
	else&lt;br /&gt;
		table.insert (output, &amp;#039; ([[Template:Naval Vessel Register URL#Error messages|help]])&amp;lt;/span&amp;gt;&amp;#039;);&lt;br /&gt;
	end&lt;br /&gt;
	table.insert (output, category);&lt;br /&gt;
	return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; _ N V R _ U R L _M A K E &amp;gt;-----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
common function to return an NVR url when given &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function _nvr_url_make (args_t)&lt;br /&gt;
	local output = {};&lt;br /&gt;
&lt;br /&gt;
	if (not args_t[1]) and (not args_t[&amp;#039;id&amp;#039;]) then&lt;br /&gt;
		make_error_message (output, &amp;#039;required parameter missing&amp;#039;, &amp;#039;&amp;#039;, &amp;#039;&amp;#039;);&lt;br /&gt;
		return table.concat (output);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local hull = args_t[&amp;#039;id&amp;#039;] or args_t[1];&lt;br /&gt;
	local hull_designator;														-- for use with |name= parameter rendering&lt;br /&gt;
	local hull_prefix;&lt;br /&gt;
	local title = args_t[&amp;quot;title&amp;quot;] or args_t[2];&lt;br /&gt;
	&lt;br /&gt;
	hull = mw.text.trim (hull):upper():gsub (&amp;#039;[ _%-]+&amp;#039;, &amp;#039;-&amp;#039;);					-- no leading/trailing whitespace, uppercase; convert spaces, underscores, hyphens to hyphens&lt;br /&gt;
&lt;br /&gt;
	local patterns_t = {														-- patterns for various NVR hull classification&lt;br /&gt;
		{&amp;#039;^(T)%-?(%u+)%-?(%d+)$&amp;#039;, &amp;#039;%1-%2-%3&amp;#039;, &amp;#039;^T%-%u+&amp;#039;},						-- for certain auxilliaries that have a &amp;#039;T-&amp;#039; prefix&lt;br /&gt;
		{&amp;#039;^(%u+)%-?(%d+)$&amp;#039;, &amp;#039;%1-%2&amp;#039;, &amp;#039;^%u+&amp;#039;},									-- most common hull designator format&lt;br /&gt;
		{&amp;#039;^(AFDB)%-?(%d+%u?)$&amp;#039;, &amp;#039;%1-%2&amp;#039;, &amp;#039;^%u+&amp;#039;},								-- special case for AFDB drydock sections&lt;br /&gt;
		{&amp;#039;^AFSB%-?%(I%)%-?15&amp;#039;, &amp;#039;AFSB-(I)-15&amp;#039;, &amp;#039;AFSB&amp;#039;},							-- special case for Ponce (AFSB-(I)-15)&lt;br /&gt;
		};&lt;br /&gt;
	&lt;br /&gt;
	for _, pattern_t in ipairs (patterns_t) do									-- spin through the patterns_t sequence&lt;br /&gt;
		if hull:match (pattern_t[1]) then										-- if a match&lt;br /&gt;
			hull = hull:gsub (pattern_t[1], pattern_t[2]);						-- ensure proper format&lt;br /&gt;
			hull_prefix = hull:match (pattern_t[3]);							-- and extract the alpha hull prefix (SSBN from SSBN-659)&lt;br /&gt;
			break;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not hull_prefix then&lt;br /&gt;
		if ({[&amp;#039;CONSTITUTION&amp;#039;] = true, [&amp;#039;MAINE&amp;#039;] = true, [&amp;#039;TEXAS&amp;#039;] = true})[hull] then	-- special case for these three ships which do not have standard hull designators in NVR&lt;br /&gt;
			hull_prefix = hull;													-- so use ship name to index into data table&lt;br /&gt;
		else&lt;br /&gt;
			make_error_message (output, &amp;#039;malformed hull classification symbol: &amp;#039;, hull, &amp;#039;&amp;#039;);&lt;br /&gt;
			return table.concat (output);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	hull_designator = hull;														-- copy for use with |name= parameter&lt;br /&gt;
&lt;br /&gt;
	if not data_t[hull_prefix] then											-- is there a group for the hull number?&lt;br /&gt;
		make_error_message (output, &amp;#039;unable to find group: [\&amp;#039;&amp;#039;, hull_prefix, &amp;#039;\&amp;#039;] in [[Module:Naval Vessel Register URL/data]]&amp;#039;);&lt;br /&gt;
		return table.concat (output);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not data_t[hull_prefix][hull] then										-- is there a hull number&lt;br /&gt;
		make_error_message (output, &amp;#039;unable to find hull classification symbol: [\&amp;#039;&amp;#039;, hull, &amp;#039;\&amp;#039;] in [[Module:Naval Vessel Register URL/data]]&amp;#039;);&lt;br /&gt;
		return table.concat (output);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local nvr_id = data_t[hull_prefix][hull][1];								-- try to fetch nvr id&lt;br /&gt;
	if not title and (args_t[&amp;#039;name&amp;#039;] and &amp;#039;&amp;#039; ~= args_t[&amp;#039;name&amp;#039;]) then&lt;br /&gt;
		title = data_t[hull_prefix][hull][2];&lt;br /&gt;
		if not title or &amp;#039;&amp;#039; == title then&lt;br /&gt;
			title = nil;														-- ensure&lt;br /&gt;
		elseif &amp;#039;no name&amp;#039; == title:lower() then									-- new construction capital ships, and many service craft&lt;br /&gt;
			title = title .. &amp;#039; (&amp;#039; .. hull_designator .. &amp;#039;)&amp;#039;;&lt;br /&gt;
		elseif &amp;#039;nh&amp;#039; == args_t[&amp;#039;name&amp;#039;] then										-- special keyword to render name and hull designator&lt;br /&gt;
			title = &amp;#039;\&amp;#039;\&amp;#039;&amp;#039; .. data_t[hull_prefix][hull][2] .. &amp;#039;\&amp;#039;\&amp;#039; (&amp;#039; .. hull_designator .. &amp;#039;)&amp;#039;;&lt;br /&gt;
		else&lt;br /&gt;
			title = &amp;#039;\&amp;#039;\&amp;#039;&amp;#039; .. data_t[hull_prefix][hull][2] .. &amp;#039;\&amp;#039;\&amp;#039;&amp;#039;;		-- just the name&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (nil ~= nvr_id) and (&amp;#039;&amp;#039; ~= nvr_id) then									-- there appears to be an identifier, so use it&lt;br /&gt;
		if title then															-- if there is a title then make an external link from it&lt;br /&gt;
			table.insert (output, &amp;#039;[&amp;#039;);											-- opening bracket&lt;br /&gt;
		end&lt;br /&gt;
		table.insert (output, &amp;#039;https://www.nvr.navy.mil/nvr/getHull.htm?shipId=&amp;#039;);	-- create the url&lt;br /&gt;
		table.insert (output, nvr_id);&lt;br /&gt;
		if title then&lt;br /&gt;
			table.insert (output, &amp;#039; &amp;#039;);											-- required space&lt;br /&gt;
			table.insert (output, title);										-- title&lt;br /&gt;
			table.insert (output, &amp;#039;]&amp;#039;);											-- and closing bracket&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
	else																		-- no identifier&lt;br /&gt;
		make_error_message (output, &amp;#039;no identifier for hull classification symbol: [\&amp;#039;&amp;#039;, hull, &amp;#039;\&amp;#039;] in [[Module:Naval Vessel Register URL/data]]&amp;#039;);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return table.concat (output);												-- and done&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; N V R _ U R L _M A K E &amp;gt;-------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Naval Vessel Register URL|nvr_url_make|1=|title=}}&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
    {{{1}}} or |id=: required; the ship&amp;#039;s hull designator: T-ARC-7, SSBN-658, YTB-760, etc&lt;br /&gt;
    {{{2}}} or |title=: optional; a title or label for the link&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function nvr_url_make (frame)&lt;br /&gt;
	local args_t = get_args (frame);&lt;br /&gt;
	return _nvr_url_make (args_t)&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;
	nvr_url_make = nvr_url_make,												-- entry point when called from a template&lt;br /&gt;
	&lt;br /&gt;
	_nvr_url_make = _nvr_url_make,												-- entry point when called from a module&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;Pppery</name></author>
	</entry>
</feed>