Template talk:Listed building Scotland

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

This template currently takes a numeric ID (eg 12345), and puts it into a URL formatted as portal.historicenvironment.scot/designation/LB12345. Numbers are imported from Wikidata by some of the WLM upload tools, but at this point we get a problem. The relevant Wikidata field (P709) currently has a mix of values. Some are numeric; some include the LB prefix; some include the SM prefix (for scheduled monuments, which live in the same database and overlap with LB numbers).

This means that the template is trying to produce things like .../designation/LBLB12345 or .../designation/LBSM12345 - see eg/ File:1 Castle St, Dornoch.jpg (LB) or File:Black House, 42 Arnol, Isle of Lewis 1.jpg (SM).

Wikidata is likely to standardise on including the prefixes (see d:Property talk:P709 - I'm working on this update just now) which means the problem is likely to grow with any newly uploaded items or any copying IDs across from Wikidata

The template probably needs updated to:

  1. remove the hardcoded LB element (so that future imported values work okay)
  2. stop generating Category:Listed buildings in Scotland without known IDs if there is an LB/SM prefix (perhaps only generate this if the ID isn't present)
  3. detect if there is no LB/SM prefix on the ID and treat it as having the LB prefix - this will work for most items and even if it guesses wrong for a handful which are really SM, it's no worse than it is now (where they're all SM)

I can do the first bit but not #2 or #3, which are a bit complex for me. @Jheald: , is this something you'd be able to try? Andrew Gray (talk) 22:35, 26 September 2018 (UTC)[reply]

@Andrew Gray: A couple of other jobs I need to clear first, but let me see if I can do any good over the next day or two. Jheald (talk) 08:27, 27 September 2018 (UTC)[reply]
@Jheald: Great, thanks - I'll keep hacking away at updating the WD elements at the same time. There seem to be a few WP templates as well but not as sophisticated, so I'll see if I can update those myself. Andrew Gray (talk) 10:48, 27 September 2018 (UTC)[reply]
@Andrew Gray and Jheald: this template is for the listed buildings and we have {{Scheduled monument Scotland}} for the scheduled monuments. Please don't change any of these templates before first discussing this because you'll break the Wiki Loves Monuments tooling and more. Multichill (talk) 21:29, 27 September 2018 (UTC)[reply]
@Multichill: I don't think anyone is currently talking about changing any of the data currently stored in the template, just fixing the display on the page and getting the external links to work. Would either of those impact WLM? Jheald (talk) 21:40, 27 September 2018 (UTC)[reply]
@Multichill: . Ah - apologies if this is a problem. The reason I spotted it originally is that I uploaded a few scheduled monument pictures through the WLM tool (eg File:Callanish Stones - 20180411085105.jpg), saw the template was giving the error category, and discovered it's doing it for a few hundred others.
I didn't know about {{Scheduled monument Scotland}}, but on investigation that doesn't seem to have been used for the WLM uploads infrastructure (at least not in recent years) - I've checked through a lot of the images in Category:Scheduled monuments in Scotland with known IDs and they all seem to have been added afterwards or inserted as part of a manual non-WLM upload. As far as I can tell this one is being applied for both listed and scheduled sites by the tools. Andrew Gray (talk) 22:11, 27 September 2018 (UTC)[reply]
Thought about this a bit more over lunch and I've mocked up a new pair of template at User:Andrew Gray/test - this follows the following logic
  • if the ID has an SM prefix, it invokes the scheduled monuments template
  • ...which generates a correct URL
  • if the ID has an LB prefix, it generates a correct URL
  • otherwise, it falls back on the old system (URL with prefix)
This will mean there is no change in behaviour for an entry with a plain number ID, but it will correctly handle any that come in with LB/SM prefixes. The template will still have trouble with scheduled monuments uploaded with numeric IDs, but I don't think there's any real way we can solve that.
I still need to make sure they emit the correct categories but I think the template logic is otherwise sound and won't cause problems - any existing item will have the same handling it does now. @Multichill and Jheald: , thoughts? Andrew Gray (talk) 12:30, 28 September 2018 (UTC)[reply]
Categories now working as well, I think. Tested here and it seems to work okay. Andrew Gray (talk) 12:57, 28 September 2018 (UTC)[reply]
  • @Multichill and Jheald: Following up on this - are you happy for me to update the templates as per the draft above? If there's anything I've missed or slipped up on, please let me know and I'll try to get it fixed. (It's been a few years since I did this much work with parser functions!).
I've not introduced any additional functionality beyond handling SM/LB prefixes in addition to plain numbers, but one option would be to have a tracking category for known scheduled monuments which are using the listed building template - this would allow them to be changed over properly at a later date. Andrew Gray (talk) 08:53, 3 October 2018 (UTC)[reply]
It's unclear to me what the changes are exactly. Can you use {{Listed building Scotland/sandbox}} to show the exact changes? Multichill (talk) 15:38, 3 October 2018 (UTC)[reply]

@Multichill: done - I've had to create a .../sandbox/layout and .../sandbox/en subpage as well (since it relies on the URL in the /layout template). The changes are:

a) a wrapper to invoke {{Scheduled monument Scotland}} and skip everything else if SM prefixes are used;
b) logic in .../layout to see if it's using an LB prefix, and if so give a correct URL form; if a number, the old-style URL form; if anything else, "unknown" (as before);
c) logic in the main template to give correct categories for both LB prefixes and plain numbers
d) category sort order standardised on using the prefix

{{Scheduled monument Scotland/sandbox}} is tweaked in the same way, with extra logic to cope with either SM prefixes or plain numbers. Andrew Gray (talk) 17:17, 3 October 2018 (UTC)[reply]

@Multichill: do you have any further concerns with this, or can I set it to go live? Andrew Gray (talk) 22:18, 11 October 2018 (UTC)[reply]
Sorry for delaying this Andrew. I think I now properly understand your problem. To summarize
Intead of trying to rebuild this template to also include scheduled monuments I would create {{Historic Scotland listing}} which tracks files in Category:Historic Scotland listing with known IDs (anyone a better name for the template and the category?). This would be a meta template that takes both LB123 and SM123. The old templates would wrap around the new template. I can add some template checks so direct usage can easily be converted. This is all extremely easy to do. No breakage of existing logic and gives us a nice alignment with Wikidata. Would you agree with this approach or am I missing something here? I'll just make a proof of concept to show the possibilities. Fixing Category:Listed buildings in Scotland without known IDs should be an easy bot job. Multichill (talk) 10:50, 13 October 2018 (UTC)[reply]
@Multichill: Thanks - I think that's a good summary of the situation. Your solution of a wrapper template sounds good - to check I've got this right, that's a template that takes either LB or SM numbers and generates the correct template + categories? It would also let us extend it if we ever get around to covering the other things in the Historic Scotland database (they have a few entries for battlefields and historic gardens with different prefixes).
How would the wrapper cope with "no prefix" items (about 80% of the existing uses)? I would recommend we default to assuming LB for these, since it will usually be the right solution, but write the documentation to encourage people to include a prefix (and assume one will come in through WLM/Wikidata based uploads). Historic Scotland now present the numbers with prefixes as standard, so this seems to be the preferred format, and happily it's unambiguous. Andrew Gray (talk) 12:46, 14 October 2018 (UTC)[reply]
@Andrew Gray: it's the other way around. User uses either {{Listed building Scotland|<someid>}} or {{Scheduled monument Scotland|<someid>}} which invokes {{Historic Scotland listing|LB<someid>}} or {{Historic Scotland listing|SM<someid>}}. You can see this in Category:Historic Scotland listing with known IDs. I do realize that category should be named Category:Historic Scotland listings with known IDs. I'll move it when we're all on the same page. Multichill (talk) 16:34, 14 October 2018 (UTC)[reply]
@Multichill: aha, I get you now. This certainly sounds like it should solve the problem. Andrew Gray (talk) 17:04, 14 October 2018 (UTC)[reply]
@Andrew Gray: ok. Renamed the category and I cleaned out Category:Listed buildings in Scotland without known IDs now (LB example and SM example). Can you check the remaining files? The all have the code "MHG5519". Multichill (talk) 19:12, 14 October 2018 (UTC)[reply]
@Andrew Gray: that combined with another fix caused the report of unused images to be generated again. Maybe nice to convert lists like en:Scheduled monuments in Dumfries and Galloway also to a template based format to complete it. Multichill (talk) 17:40, 15 October 2018 (UTC)[reply]
@Multichill: I've fixed those last ones (no idea where that code came from!). The last thing I think we need to work out is how to fix the WLM upload campaign for next year so that it doesn't just send both types to {{Listed building Scotland}}, but that's definitely outside my competence. Any ideas? Andrew Gray (talk) 19:03, 15 October 2018 (UTC)[reply]
The campaign Campaign:wlm-gb-sct looks a bit bare. We could split it up in one for the listed buildings and one for the scheduled monuments. We'll figure it out before the start of next year. Multichill (talk) 11:18, 16 October 2018 (UTC)[reply]

Dual Designation 2A project[edit]

A lot of listings are being removed due to the Dual Designation 2A project. Would a delisting parameter be advisable that would indicate the current status as no longer listed, but give us the option to retain historical information. An example would be Category:Linlithgow Palace gatehouse where marked it with a strike. Normally I put the delisting data into WikiData, but there I did not find a WD object. Agathoclea (talk) 10:37, 28 January 2019 (UTC)[reply]