Difference between revisions of "Module:NVR/doc"
blackwiki>RP88 (expand examples) |
blackwiki>RP88 (ServiceShip -> ServiceCraft) |
||
| Line 29: | Line 29: | ||
: <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}} | : <code><nowiki>{{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}</nowiki></code> produces {{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}} | ||
| − | === | + | === MakeServiceCraftLink === |
| − | This function returns a link to a service | + | This function returns a link to a service craft in the Naval Vessel Register. |
Usage: | Usage: | ||
| − | : <code><nowiki>{{#invoke:NVR| | + | : <code><nowiki>{{#invoke:NVR|MakeServiceCraftLink|id=|title=}}</nowiki></code> |
| − | : <code><nowiki>{{#invoke:NVR| | + | : <code><nowiki>{{#invoke:NVR|MakeServiceCraftLink}}</nowiki></code> — uses the calling template's parameters |
Parameters: | Parameters: | ||
| − | : '''1''' or '''id''' — The 'file name' portion of the url path (typically the | + | : '''1''' or '''id''' — The 'file name' portion of the url path (typically the craft's hull designation) without the .HTM/.HTML extension. |
: '''2''' or '''title''' — A title or label for the link. | : '''2''' or '''title''' — A title or label for the link. | ||
Example: | Example: | ||
| − | : <code><nowiki>{{#invoke:NVR| | + | : <code><nowiki>{{#invoke:NVR|MakeServiceCraftLink|AFDB1_1}}</nowiki></code> produces {{#invoke:NVR|MakeServiceCraftLink|AFDB1_1}} |
== Using this module from Lua code == | == Using this module from Lua code == | ||
| Line 66: | Line 66: | ||
: <code><nowiki>link_string = nvr._MakeShipLink('OLDIRON', '')</nowiki></code> | : <code><nowiki>link_string = nvr._MakeShipLink('OLDIRON', '')</nowiki></code> | ||
| − | === | + | === _MakeServiceCraftLink === |
| − | This function returns a link to a service | + | This function returns a link to a service craft in the Naval Vessel Register. |
Usage: | Usage: | ||
| − | : <code><nowiki>link_string = nvr. | + | : <code><nowiki>link_string = nvr._MakeServiceCraftLink(nvrid, title)</nowiki></code> |
Parameters: | Parameters: | ||
| − | : '''nvrid''' — The 'file name' portion of the url path (typically the | + | : '''nvrid''' — The 'file name' portion of the url path (typically the craft's hull designation) without the .HTM/.HTML extension, as a string. |
: '''title''' — Title for link, set to <code><nowiki>''</nowiki></code> for a bare link without a title. | : '''title''' — Title for link, set to <code><nowiki>''</nowiki></code> for a bare link without a title. | ||
Example: | Example: | ||
| − | : <code><nowiki>link_string = nvr. | + | : <code><nowiki>link_string = nvr._MakeServiceCraftLink('AFDB1_1', '')</nowiki></code> |
==See Also== | ==See Also== | ||
Revision as of 02:09, 4 October 2016
{{#invoke:NVR|function}}
| This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Summary
This module generates links to ships in the Naval Vessel Register (nvr.navy.mil) database. Intended to be used by:
- {{NVR url}}
- {{NVR SC url}}
The table of URL transformations used by this module can be found at Module:NVR/rules.
Using this module from templates
MakeShipLink
This function returns a link to a ship in the Naval Vessel Register.
Usage:
{{#invoke:NVR|MakeShipLink|id=|title=}}{{#invoke:NVR|MakeShipLink}}— uses the calling template's parameters
Parameters:
- 1 or id — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension.
- 2 or title — A title or label for the link.
Examples:
{{#invoke:NVR|MakeShipLink|DDG_1000}}produces http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_DDG_1000.HTML{{#invoke:NVR|MakeShipLink|OLDIRON}}produces malformed hull classification symbol: OLDIRON (help){{#invoke:NVR|MakeShipLink|OLDIRON|USS ''Constitution''}}produces malformed hull classification symbol: OLDIRON (help)
MakeServiceCraftLink
This function returns a link to a service craft in the Naval Vessel Register.
Usage:
{{#invoke:NVR|MakeServiceCraftLink|id=|title=}}{{#invoke:NVR|MakeServiceCraftLink}}— uses the calling template's parameters
Parameters:
- 1 or id — The 'file name' portion of the url path (typically the craft's hull designation) without the .HTM/.HTML extension.
- 2 or title — A title or label for the link.
Example:
{{#invoke:NVR|MakeServiceCraftLink|AFDB1_1}}produces unable to find hull classification symbol: ['AFDB-1_1'] in Module:NVR/data nvr_srv_craft_id (help)
Using this module from Lua code
In order to use the functions in this module from another Lua module you first have to import this module.
Example:
local nvr = require('Module:NVR')
_MakeShipLink
This function returns a link to a ship in the Naval Vessel Register.
Usage:
link_string = nvr._MakeShipLink(nvrid, title)
Parameters:
- nvrid — The 'file name' portion of the url path (typically the ship's hull designation) without the .HTM/.HTML extension, as a string.
- title — Title for link, set to
''for a bare link without a title.
Examples:
link_string = nvr._MakeShipLink('DDG_1000', '')link_string = nvr._MakeShipLink('OLDIRON', '')
_MakeServiceCraftLink
This function returns a link to a service craft in the Naval Vessel Register.
Usage:
link_string = nvr._MakeServiceCraftLink(nvrid, title)
Parameters:
- nvrid — The 'file name' portion of the url path (typically the craft's hull designation) without the .HTM/.HTML extension, as a string.
- title — Title for link, set to
''for a bare link without a title.
Example:
link_string = nvr._MakeServiceCraftLink('AFDB1_1', '')