Template talk:Naval Vessel Register URL
To help centralise discussions and keep related topics together, Module talk:Naval Vessel Register URL and Template talk:Naval Vessel Register service craft URL redirect here. |
Generated NVR links are out of date
[edit]@Trappist the monk: It appears that NVR has changed the layout for links to ships in the NVR database. While the old links still work, they link to pages that are no longer being updated. For example, if you drill down from http://www.nvr.navy.mil to LCS 26 you end up at http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_LCS_26.HTML while the template {{NVR url|id=LCS26}}
generates a link to http://www.nvr.navy.mil/NVRSHIPS/DETAILS/LCS26.HTM . Unfortunately an update of the template to use the new URL scheme is not entirely straightforward since the new URL scheme can't be generated by a direct substitution of the old "id" parameters. I could code up a Lua replacement if we want to keep the old ID scheme, or alternatively, we could update the ~1000 transclusions to use an "id" format with an underscore between the hull classification symbol and the hull number (i.e. "LCS_26" instead of "LCS26"). Thoughts? —RP88 (talk) 00:10, 27 September 2016 (UTC)
- Sigh. Why do they do this? Some new ensign with a need to be seen having his division 'doing something'? I despair.
- We can change the url simply enough and perhaps include something like this to add the underscore between the classification and the hull number:
{{#invoke:String|replace|source=LCS26|pattern=(%u)(%d)|replace=%1_%2|plain=false}}
- LCS_26
- where
|source={{uc:{{{id|{{{1}}}}}}}}
- No need then to update all the articles.
- I would have expected that our new ensign would have been consistent, it is, after all the Navy way, which then would make this fix work for all of the ship detail pages at NVR. You would think that they would keep the hull symbol portion of the url mostly the same. Alas, no. I guess I expect too much:
- http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_OLDIRON.HTML – doesn't work
- http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_1315.HTML – does works (and what does 1315 mean?)
- So, there will be a need to do some fiddling with individual pages.
- —Trappist the monk (talk) 00:51, 27 September 2016 (UTC)
- Thanks for taking a look at this. I agree that it is possible to use template syntax to produce a more complex version of the template that might handle some of the weird edge cases, but I'm inclined to say that as soon we start trying to build a template that contains something that starts to look like parser we might as well do it in Lua (which would be more flexible if the Navy changes the scheme once again). I'd be willing to make a first past at a Lua implementation if you'd like. I think I could have an implementation and test cases ready by tomorrow. However, I don't want to step on your toes since you're the original author of this template. —RP88 (talk) 01:13, 27 September 2016 (UTC)
- You wouldn't be stepping on my toes.
- —Trappist the monk (talk) 01:19, 27 September 2016 (UTC)
- OK. I'll work on coding a module (perhaps at Module:NVR) that can be used by both {{NVR url}} and {{NVR SC url}}. It is my plan for the module to work with id's based on the original file names as well as id's based on the new scheme. I'll ping you as soon as I have something ready for you to review (should be within a day). —RP88 (talk) 01:26, 27 September 2016 (UTC)
- Thanks for taking a look at this. I agree that it is possible to use template syntax to produce a more complex version of the template that might handle some of the weird edge cases, but I'm inclined to say that as soon we start trying to build a template that contains something that starts to look like parser we might as well do it in Lua (which would be more flexible if the Navy changes the scheme once again). I'd be willing to make a first past at a Lua implementation if you'd like. I think I could have an implementation and test cases ready by tomorrow. However, I don't want to step on your toes since you're the original author of this template. —RP88 (talk) 01:13, 27 September 2016 (UTC)
- I've reviewed the content of the "new" NVR vs. the older NVR and found the following exceptions:
- http://www.nvr.navy.mil/NVRSHIPS/DETAILS/OLDIRON.HTM is now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_1315.HTML
- http://www.nvr.navy.mil/NVRSHIPS/DETAILS/MAINE.HTM is now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_939.HTML
- http://www.nvr.navy.mil/NVRSHIPS/DETAILS/MARCOS.HTM is now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_940.HTML
- http://www.nvr.navy.mil/NVRSHIPS/DETAILS/AFSB15.HTM is now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_AFSB_(I)_15.HTML
- http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/AFDB1_1.HTM is maybe? now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_AFDB_1.HTML
- http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/AFDB7_1.HTM is now http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_AFDB_7.HTML
- http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/AFDB1_3.HTM doesn't appear to have a "new" page.
- http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/AFDB1_4.HTM doesn't appear to have a "new" page.
- http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/AFDB7_2.HTM doesn't appear to have a "new" page.
- —RP88 (talk) 22:13, 27 September 2016 (UTC)
- I've reviewed the content of the "new" NVR vs. the older NVR and found the following exceptions:
New Module:NVR implementation
[edit]@Trappist the monk: I've implemented a new Lua module Module:NVR intended to replace the implementation of this template. See Module_talk:NVR/testcases for the test cases and Module talk:NVR for discussion about the module itself. The goal of the Lua implentation was to preserve the style of output from the current {{NVR url}} template, but with links that point to the new entries in the NVR database. The Lua code will correctly handle "id" parameter values that are in both the "old" scheme as well as the "new" scheme. Where possible the code outputs links to the new NVR entries, even if an id that is from the older scheme is supplied. It also handles all of the "exceptions" identified above (in some cases falling back to returning links to the older pages using the older linking scheme if I couldn't identify the correct page in the new scheme. Because it is used on more than a thousand pages, I didn't switch {{NVR url}} and {{NVR SC url}} to use Module:NVR on my own, but if there are no suggested improvement or objections, I'll make the switch. The new code is currently installed in this template's sandbox if you want to experiment with it (as well as at the service versions's sandbox). Use them like {{NVR url/sandbox|OLDIRON}}
. —RP88 (talk) 01:27, 28 September 2016 (UTC)
- If you are happy with it, then proceed. If I were to make any suggestions, it would be to put the exceptions in tables so that follow-on editors who don't know anything about Lua can add/remove/edit those database entries without jeopardizing the rest of the code.
- —Trappist the monk (talk) 10:23, 28 September 2016 (UTC)
- Good idea. I've updated Module:NVR to load a table of URLs and 'id' transformation rules from Module:NVR/rules. It should be possible to add new entries to the rules table if new exceptions are found, or even add an entirely new set of transformations if NVR introduce a third URL scheme at some point. If you're fine with the new code, I'll update the templates to use it. —RP88 (talk) 23:19, 28 September 2016 (UTC)
- Not a show-stopper but, is it really necessary to do this:
match = '^[A-Z]+[0-9]+$', pattern = '^([A-Z]+)([0-9]+)$',
- Except for the captures they are identical.
- —Trappist the monk (talk) 00:44, 30 September 2016 (UTC)
- No, it's not necessary per se. I implemented the code to use distinct patterns for the match criteria and the substitution patterns with the thought that this might add some flexibility to support future changes to NVR without having to edit the code. That flexibility is not necessary for the existing "old" and 'new" NVR schemes. As a purely hypothetical example, you could use the following rule to remove underscores only from IDs that start with AFDB:
method = 'pattern', match = '^AFDB', pattern = '_', replace = '', url='future_third_url'
- I agree that a separate match and substitution pattern does make the rule you point to more complex that it would otherwise need to be. However, having a separate match and substitution pattern does make certain other rules simpler. For example, the rule for "leave all ID's that start with AFDB unchanged with URLs pointing to old locations' would look like the following with the current code...
method = 'pattern', match = '^AFDB', url = 'old',
- ...while it would need to be the following if support for the match parameter was removed:
method = 'pattern', pattern = '^AFDB(.*)', replace = 'AFDB%1' url = 'old',
- Would you like me to remove the match parameter? It would be an easy change. —RP88 (talk) 02:05, 30 September 2016 (UTC)
- No, it's not necessary per se. I implemented the code to use distinct patterns for the match criteria and the substitution patterns with the thought that this might add some flexibility to support future changes to NVR without having to edit the code. That flexibility is not necessary for the existing "old" and 'new" NVR schemes. As a purely hypothetical example, you could use the following rule to remove underscores only from IDs that start with AFDB:
- Not a show-stopper but, is it really necessary to do this:
- Good idea. I've updated Module:NVR to load a table of URLs and 'id' transformation rules from Module:NVR/rules. It should be possible to add new entries to the rules table if new exceptions are found, or even add an entirely new set of transformations if NVR introduce a third URL scheme at some point. If you're fine with the new code, I'll update the templates to use it. —RP88 (talk) 23:19, 28 September 2016 (UTC)
OK, I've deployed the version using Module:NVR both here and at Template:NVR SC url. —RP88 (talk) 06:22, 2 October 2016 (UTC)
NVR links are out of date again
[edit]@Trappist the monk: It appears that NVR has once again changed the layout for links to ships in the NVR database. Just like before, the old links continue to work, but they link to pages that are no longer being updated. For example, if you drill down from http://www.nvr.navy.mil to EPF 9 you end up at http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_EPF_9_1985.HTML while the template {{NVR url|id=EPF9}}
generates a link to http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_EPF_9.HTML . Even worse than the last change, an update of the template to use the new URL scheme is complicated by the fact that the new URLs incorporate a new number unrelated to the hull number, probably a database ID of some kind. I could add a new parameter that needs to be specified in addition to the hull number (or change the documentation to say the id parameter should be of a form like EPF_9_1985), or maybe add a lookup table in Module:NVR that maps the hull number to the appropriate database number. Or perhaps even a fallback scheme where the template can accept both the hull number and new NVR id, but if only the hull number is specified we look the new NVR id up in a table, and if the NVR id is not found in the table we output a tracking category. Frankly, I was hoping you'd have a better suggestion. —RP88 (talk) 00:15, 3 February 2017 (UTC)
- It would be best to act rather than to react. I think that you should contact the NVR webmaster (email address at the bottom of every NVR page) and see if it is possible for them to settle on a single consistent page naming format that can remain in place for longer than six months. Explain to them that the English Wikipedia has approximately 3150 links into the NVR website, that other language Wikipedias may also be linking to NVR pages, that every time they change the page naming and url structure, all of the existing links here and at the other language Wikipedias are jeopardized. See where you get. If you do this, post the results here (leave out email addresses).
- —Trappist the monk (talk) 01:07, 3 February 2017 (UTC)
- I just ran into this at USS Antietam (CG-54). I changed id=CG54 to id=CG_54_5116 and that fixed it, but it seems an unsatisfying fix. Kendall-K1 (talk) 20:28, 1 August 2017 (UTC)
- I contacted the NVR custodian both by email and by regular postal mail back in February, but I have not yet received a reply. I think we will have to simply adapt to whatever scheme they are using. I am leaning towards going ahead and implementing the solution of "add a fallback scheme where the template can accept both the hull number and new NVR id, but if only the hull number is specified we look the new NVR id up in a table, and if the NVR id is not found in the table we output a tracking category". —RP88 (talk) 21:28, 1 August 2017 (UTC)
- I think I concur. To that end, somehow tables must be made. I have concocted a scheme that uses a small module to read the content of an nvr hull-classification page and build a lua table from that. To do this:
- create a page in your sandbox that has just this line:
{{#invoke:Sandbox/trappist_the_monk/nvr|nvr_extract}}
- visit the nvr hull list page
- choose a hull-classification symbol
- use your browser to view the html page source
- copy all of that to the clipboard
- paste it in your sandbox page
- click Show preview
- copy the rendered table to someplace else to be amalgamated with other such tables.
- create a page in your sandbox that has just this line:
- See my sandbox for an example.
- —Trappist the monk (talk) 11:44, 26 August 2017 (UTC)
- I think I concur. To that end, somehow tables must be made. I have concocted a scheme that uses a small module to read the content of an nvr hull-classification page and build a lua table from that. To do this:
I've created a new Module:NVR/sandbox that uses Module:NVR/data as a brute-force way of handling the identifiers in the NVR urls. The module accepts a hull number in any of five forms:
|id=SSBN-659
– this I think should be the preferred form because it matches how WP formats hull classification symbols for the US Navy|id=SSBN659
|id=SSBN 659
|id=SSBN_659
|id=SSBN_659_1635
– the identifier currently used by NVR (the trailing '_\d+' is discarded)
This version of the module recognizes the names of three ships that don't have hull numbers: Constitution, Maine, and Texas:
{{NVR url/sandbox|Constitution|''Constitution''}}
{{NVR url/sandbox|Maine|''Maine''}}
{{NVR url/sandbox|Texas|''Texas''}}
The code word OLDIRON is not recognized:
- malformed hull classification symbol: OLDIRON (help)
This version of the module recognizes the one-off case of Ponce which has a uniquely formed hull number: AFSB (I)-15:
{{NVR url/sandbox|AFSB (I)-15|''Ponce''}}
For those ships that have hull numbers beginning with the 'T-' prefix, that prefix is discarded before the module looks up the NVR id.
{{NVR url/sandbox|T-AK-3010|''1st Lt Baldomero Lopez''}}
As a test, I copied the sandbox code over the live module and previewed List of current ships of the United States Navy. From all of those references to NVR, two are reported as errors and, of the rest, a random spot check found none that didn't link to the proper place in NVR. The two errors were OLDIRON (expected as already noted) and Ponce which has |id=AFSB15
as its ID. Because Ponce's hull number at NVR is 'AFSB (I)-15', I'm not inclined to make the sandbox module recognize 'AFSB15'.
These changes apply equally to {{NVR SC url}}
and that test I just mentioned showed that the service craft are also supported well by the sandbox.
There is a testcases page for the sandbox at Module:NVR/sandbox/testcases.
The error messages (there are two) need to be tweaked so that they link to a relevant section of this template's documentation. I'll do that and then, without objection, shall sync the live module from the sandbox.
—Trappist the monk (talk) 15:20, 30 August 2017 (UTC)
Requested move 7 October 2020
[edit]- The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion.
The result of the move request was: Consensus to move. I leave the technical aspects to someone else. (non-admin closure) (t · c) buidhe 05:03, 22 October 2020 (UTC)
- Template:NVR url → Template:Naval Vessel Register URL
- Template:NVR SC url → Template:Naval Vessel Register service craft URL
- Module:NVR → Module:Naval Vessel Register URL
- Module:NVR/data → Module:Naval Vessel Register URL/data
– Expand overabbreviated template name, harmonize template and module names. Additionally, the article URL is titled in all caps, so the templates for producing URLs should also capitalize it. * Pppery * it has begun... 22:49, 7 October 2020 (UTC)
- Support all changes mentioned. --Gonnym (talk) 13:40, 8 October 2020 (UTC)
- It seems to me a pointless exercise to move the templates and modules when, in article space, the resulting redirects will remain in-place as the preferred name precisely because they are short. Editor Pppery must show that there is a need or that there is some policy that mandates fully spelled-out template names. The opinion that the names are
overabbreviated
doesn't seem like much of a reason to me. We might harmonize the module names to Module:NVR url and Module:NVR url/data. —Trappist the monk (talk) 14:13, 8 October 2020 (UTC) - Support because clarity of titling matters. This YA example of how the point of Wikipedia gets twisted in the making – template editors serve editors, and editors serve readers, not the other way around. If template editors want to use the "inside baseball" redirects, let them. For everyone else, give these templates titles that are intelligible to the masses. --IJBall (contribs • talk) 15:03, 14 October 2020 (UTC)
Implementation Done * Pppery * it has begun... 20:18, 22 October 2020 (UTC)