Module talk:Wikidata table

(Redirected from Module talk:Wikidata table/doc)
Latest comment: 1 year ago by Pppery in topic This is a very problematic module

Looking good

edit

This template seems to be working well and the performance statistics look like they will be suitable for use in long list articles. And I like the approach of using a wrapper template (e.g. Template:Wdtable row/lighthouse) — Martin (MSGJ · talk) 13:14, 11 February 2021 (UTC)Reply

Deployed on List of lighthouses in England and looking very good. Currently up to 3.8s of Lua time and I'm well over halfway through converting so 10 seconds will not be approached. — Martin (MSGJ · talk) 21:53, 16 February 2021 (UTC)Reply

Wish list

edit

I hope you don't mind but I thought I would start making a wish list for features — Martin (MSGJ · talk) 13:14, 11 February 2021 (UTC)Reply

I'm grateful that you have. Much of the time I'm writing code, I have to guess what functionality and behaviour editors want, and having good feedback from someone actively using modules that I create is incedibly helpful.
I must admit I only created the original function (makerows) to see how fast it could run, not as a basis for a replacement, so it was optimised for speed with little thought of how I could !bolt-on! extra functionality. But I accept that the row-based function looks too useful not to develop further, so I'm content to do so. What I need is guidance on how you would want any extra functionality to be accessed. For example, I could split the parameter c1 into cr1 (for column replace 1) and ca1 (for column append 1), where the first would replace the Wikidata value and the second would append to it. Do you have any any thoughts on that sort of scheme, or did you have something else in mind?
References can be done, but I can't match the existing 'citation style', only supply what is available on Wikidata (often a bare url). That may be a limiting factor for deployment.
I have all the code to display qualifiers in WikidataIB, so it can be adapted quite quickly. Is the convention P123/P580+P582 adequate to request property P123 and its qualifiers P580 and P582? Do you want the qualifiers to display their labels like start date:? or is there a short list of common qualifiers where you want a custom label? It's faster to use a lookup table than to read the label.
The Editonwikidata is easy to add, as I have a function in WikidataIB that I can adapt.
I think the code should already display only the best value. Somebody has to mark one of the coordinates as 'preferred' on Wikidata, though. Please let me know if that doesn't work.
Falling back to alternative property is not difficult, but how do you want to do it? Do you want to write something like P276(P131) or is there a short list of common fallbacks that would be applied automatically?
I'll make a start on some of those when I get a chance. --RexxS (talk) 15:44, 11 February 2021 (UTC)Reply
[Update:] several items from the wish list are done, but more input would be welcome. I'm testing display of coordinates in DMS format rather than decimal; any preferences? --RexxS (talk) 21:28, 11 February 2021 (UTC)Reply
Thanks. More input will certainly be on the way shortly, but I've had a busy couple of days! — Martin (MSGJ · talk) 16:18, 12 February 2021 (UTC)Reply
Qualifiers implemented, I think. Probably needs more testing, but it works with the lighthouses anyway. It doesn't make the rendering any slower (less than 2 sec for 95 rows). I've re-jigged the separators for the pids so that all whitespace is ignored, a , separates each cell contents, a + separates multiple properties in the same cell, a / separates the qualifiers from each property they belong to, and - separates multiple qualifiers (although anything will do for the last one, except you just can't re-use , + / obviously). If you want to change those, let me know while we're still in the drafting stage. --RexxS (talk) 01:10, 13 February 2021 (UTC)Reply

This is all looking very good indeed. I was using unnumbered parameters like {{{1}}} on list item and I was thinking about using {{{1+}}} to add to column 1. If you prefer named parameters like {{{c1}}} then how about {{{c1+}}} to add to column 1? I can't find any errors yet, but I will continue testing. Great work! — Martin (MSGJ · talk) 22:11, 13 February 2021 (UTC)Reply

I much prefer using named parameters in an invoke as I'm assured that the incoming parameter will have whitespace trimmed from it, and that there's never any confusion about which parameter is which when editing the module. Of course, if you use a wrapper template, you're free to use positional (unnamed) parameters by simply setting |qid={{{1|}}} in the wrapper definition.
I'm currently using |cr1=, etc. for cell/column replacement and |ca1=, etc. for cell/column addition because its trivial to extract the number from those by matching "ca%d+" and "cr%d+", but with a little more effort I can match "^c%d+$" and "^c%d+%+$" to use your naming scheme. You can see the ca4 and ca5 adding "FN1" and "FN2" to the Anvil Point Lighthouse row in Module talk:Wikidata table. I'll switch to your scheme tomorrow. Cheers --RexxS (talk) 23:42, 13 February 2021 (UTC)Reply

Moved to main module space

edit

I've moved the sandbox module page Module:Sandbox/RexxS/Wikidata table to main module space at Module:Wikidata table. If it is likely to be used in articles, it's better not to use sandbox code. --RexxS (talk) 17:49, 11 February 2021 (UTC)Reply

Testing/Examples are currently at Module talk:Wikidata table. --RexxS (talk) 17:57, 11 February 2021 (UTC)Reply

Lighthouse tests moved to Template talk:Wdtable row/lighthouse — Martin (MSGJ · talk) 13:06, 14 February 2021 (UTC)Reply

References

edit

References can be done, but I can't match the existing 'citation style', only supply what is available on Wikidata (often a bare url). That may be a limiting factor for deployment.

If it's just a url, i.e. reference URL (P854) then that is all that can be displayed so fine. If the reference is a Wikidata item, i.e. stated in (P248), then can it pushed into {{Cite Q}}? Are there other types of reference that are commonly used? — Martin (MSGJ · talk) 22:14, 13 February 2021 (UTC)Reply
I had coded it in my head to do one of:
  1. push the qid through {{Cite Q}} if it comes from stated in (P248);
  2. push title and url through {{cite web}} if we have both of them;
  3. use the bare url if that's all there is.
Perhaps there are other possibilities, but we can try that out for starters. Maybe add a temporary tracking category or some message if a reference is available that doesn't fit those constraints. I need to make an algorithm to generate a name for the reference based on its contents so that the parser will group identical references. The qid will work, of course, for the first option, but the others will probably need some hashing algorithm. Or maybe just add up the ascii values of each character  . I'll see if I can make time tomorrow after the online Wiki-meetup. --RexxS (talk) 00:00, 14 February 2021 (UTC)Reply
Great. I've mainly seen bare urls and item sources, so that would work for most cases I think. — Martin (MSGJ · talk) 12:36, 14 February 2021 (UTC)Reply

References implemented using bare url, {{cite web}}, or {{cite Q}} as appropriate. I added a title (P1476) to one of the references for focal height (P2923) in Bamburgh Lighthouse (Q3739752) on Wikidata. That shows up as the second reference, which now uses cite web. The downside is that calling those heavy-duty templates has doubled the rendering time for the test at Module talk:Wikidata table (I left your side-by-side testing at Template talk:Wdtable row/lighthouse but reinstated the previous single test, so that I could measure performance). Still, at less than four seconds for 95 rows and 24 references, it's quicker than it was. --RexxS (talk) 19:13, 15 February 2021 (UTC)Reply

Ouch, it's creeping up. But still well short of 10 seconds. I will do some testing. — Martin (MSGJ · talk) 22:39, 15 February 2021 (UTC)Reply

The following row looks fine here, but when previewed on List of lighthouses in England I am getting an error in the Reeds reference Cite error: The <ref> tag name cannot be a simple integer (see the help page). — Martin (MSGJ · talk) 23:17, 19 February 2021 (UTC)Reply

Lighthouse Image Location
coordinates
County Year built Tower height Focal height Range in nm Operator and Notes
Trevose Head Lighthouse   Trevose Head
50°32′57″N 5°2′7″W[1]
Cornwall1847[2]27 m (89 ft)[2]62 m (203 ft)[3][2]21 nmi (39 km; 24 mi)[3][2]Trinity House[2]114-6272[4]

References

  1. ^ Historic England. "Details from listed building database (1212769)". National Heritage List for England.
  2. ^ a b c d e https://www.trinityhouse.co.uk/lighthouses-and-lightvessels/trevose-head
  3. ^ a b Reeds PBO Small Craft Almanac 2014. ISBN 978-1-4081-9330-3. OL 32692860M. Wikidata Q25198336.
  4. ^ NGA List of Lights, Radio Aids and Fog Signals, National Geospatial-Intelligence Agency, Wikidata Q13872896
@RexxS: you may have missed the above error. I need to set up archiving. — Martin (MSGJ · talk) 17:52, 20 February 2021 (UTC)Reply
@Martin: I did miss it. The error surprises me. It's not the Reed citation; that comes through Cite_Q where the ref name is set to the qid of the citation (Q25198336) which is never a simple integer. It's actually the bare url https://www.trinityhouse.co.uk/lighthouses-and-lightvessels/trevose-head which I run through a CRC-32 hash to generate the name, and that url gives "94166689"(hex). Because the hash is a hexadecimal number with 8 hex-digits, I never expected it to generate something that looked like a decimal integer (which is what the parser objects to). I just calculated: it's about a 2.3% chance – more than I expected. Anyway I've just prefixed the hash with "WD", so that error won't happen again. I've edited List of lighthouses in England to put the row back in, but you might want to check I've got it right. --RexxS (talk) 19:50, 20 February 2021 (UTC)Reply

A couple of issues with references. (I realise you may not have time to look at this in the near future.) The most obvious problem is the ridiculous number of references for the dates. Can we limit them to 2 (or 3 at the outside)? The second error is the "Check |url= value" message which is appearing. There seems to be a comma generated which is not on Integrated Authority File (Q36578) — Martin (MSGJ · talk) 11:51, 25 February 2021 (UTC)Reply

Name Image Born Died Notes
Bertrand Russell   18 May 1872[1][2][3]
Trellech[4]
2 Feb 1970[1][5][2]
Plas Penrhyn[4], Penrhyndeudraeth[4]
Influential British thinker of the twentieth century, though more properly a philosopher than a mathematician, was of English descent but born in Monmouthshire.
I have restricted the number of references to 3. This can be adjusted by changing the maxrefs variable in the module code — Martin (MSGJ · talk) 19:33, 2 May 2022 (UTC)Reply

References

  1. ^ a b GND 118604287
  2. ^ a b BnF 11923140h
  3. ^ O'Connor, John J.; Robertson, Edmund F., "Bertrand Russell", MacTutor History of Mathematics Archive, University of St Andrews
  4. ^ a b c Colin Matthew, ed. (2004), Oxford Dictionary of National Biography, Oxford: Oxford University Press, Wikidata Q17565097
  5. ^ А. М. Прохорова, ed. (1969), Большая советская энциклопедия: [в 30 т.] (in Russian) (3rd ed.), Moscow: The Great Russian Encyclopedia, OCLC 14476314, Wikidata Q17378135

Editonwikidata

edit

The Editonwikidata is easy to add, as I have a function in WikidataIB that I can adapt.

Having a link on the name works perfectly from my point of view. Would it worth adding functionality which would allow these links on other columns too? (I personally think that would be excessive but other editors might disagree.) I've thought of something. What if the name is not the first column - I've seen that on for example List of airports in North Dakota - how would that be specified? — Martin (MSGJ · talk) 22:18, 13 February 2021 (UTC)Reply
The List of airports in North Dakota doesn't conform with MOS:ACCESS (specifically MOS:DTAB) because it has no row headers, nor any scopes. It manages to get by with that layout because in that list, there is only one airport per city, i.e. they have a one-to-one correspondence. Elsewhere, that may not be the case and a city may be served by multiple airports, i.e. a one-to-many correspondence. In those cases, the row is uniquely identified by the airport, not the city and it shows that the row header should be the airport name. The airport would be have to be the Wikidata entity (hence the qid) for that row because none of the other columns in the table contain properties of the city, rather they are properties of the airport.
In any case, I coded the first column to be the label associated with the qid, not any of the properties, and made it the row-header with proper scope, so that it conforms to MOS:DTAB. I'm not really interested in enabling non-accessible tables on Wikipedia, so I will respectfully decline to allow other columns to be used as the row-header.
The Editonwikidata icon could easily be added to any or every column, but I see no good reason for it, and I'd rather not go down that road until there is a demand for it. --RexxS (talk) 00:38, 14 February 2021 (UTC)Reply
Okay I understand your point about row headers. No, let's leave things as they are for now. — Martin (MSGJ · talk) 12:34, 14 February 2021 (UTC)Reply

Fallback properties

edit

Falling back to alternative property is not difficult, but how do you want to do it? Do you want to write something like P276(P131) or is there a short list of common fallbacks that would be applied automatically?

I know I added this to the wish list, but are we sure this is a good idea, or might it lead to confusion? I'll explain why I did this on Template:List item/location. Some editor on Wikidata was going round deleting location (P276) when it was the same as located in the administrative territorial entity (P131). Although I couldn't fault the logic of avoiding redundancy, this left some gaps in my tables, and that was how I fixed it. — Martin (MSGJ · talk) 22:24, 13 February 2021 (UTC)Reply
What syntax did you decide to use for this, so then I can go and test it? — Martin (MSGJ · talk) 22:25, 13 February 2021 (UTC)Reply
Another fallback I was using was date of official opening (P1619) for inception (P571) because sometimes they are used interchangeably. — Martin (MSGJ · talk) 22:26, 13 February 2021 (UTC)Reply
I went for automatic fallbacks for a first test. The fallbacks are stored in a simple Lua table around line 49 in Module:Wikidata table. I set it up to try falling back from location (P276) to located in the administrative territorial entity (P131). That already filled in some of the gaps in the Module talk:Wikidata table, but you might not have noticed. I've just added a fallback from 'inception' to 'date of official opening' in this diff as a demonstration. Perhaps you might find a chance to test it out? --RexxS (talk) 00:20, 14 February 2021 (UTC)Reply
I think being able to specify fallback properties in the wrapper template would be very useful, as some fallbacks would make sense in certain contexts only. The bracket notation would work well, e.g. P729(P571,P1619) where it would look in the other properties in turn until it found some data? — Martin (MSGJ · talk) 08:45, 24 February 2021 (UTC)Reply

Qualifiers

edit

I have all the code to display qualifiers in WikidataIB, so it can be adapted quite quickly. Is the convention P123/P580+P582 adequate to request property P123 and its qualifiers P580 and P582? Do you want the qualifiers to display their labels like start date:? or is there a short list of common qualifiers where you want a custom label? It's faster to use a lookup table than to read the label.

I think the current arrangement is working well. I like the way the words "until" and "from" are inserted for dates. In some cases the output does not need linking, e.g. white, but not sure the best way of specifying that. Module:Wikidata displays the qualifiers in a smaller font, which I think looks quite nice. Is that possible, or is that some kind accessibility issue? — Martin (MSGJ · talk) 13:12, 14 February 2021 (UTC)Reply
I'm loathe to make text smaller without good reason because folks have an annoying habit of setting entire tables at 95% or 90% font-size (and 90% of 90% is 81%, which is below the "bright-line" 85% minimum from MOS:TEXTSIZE). They usually do that because they can cram more rows in on the screen they are editing on. I'll set the qualifiers at 90% as a test so you can see how it looks (at least they could set 95% for the entire table without breaking the 85% minimum), I could simply set all qualifiers to be unlinked, but I'm not sure I can come with a sensible algorithm to only unlink some of them. Let's try it and see. --RexxS (talk) 18:44, 14 February 2021 (UTC)Reply
I've rendered the qualifiers as plain text for now, and cleaned up a lot of the logic. The font size for qualifiers is set in line 186, so feel free to play with that setting. --RexxS (talk) 21:14, 14 February 2021 (UTC)Reply
I think the current size works well. What do you think about using small text for coordinates too (like is used at List of crossings of the River Thames#Central London? — Martin (MSGJ · talk) 11:34, 17 February 2021 (UTC)Reply

Could coordinates be linked please - even when they are qualifiers? — Martin (MSGJ · talk) 21:03, 17 February 2021 (UTC)Reply

Name Length Source Mouth Photo
River Camel  74 km (46 mi)Bodmin Moor (50°39′33″N 4°38′29″W)Padstow Bay 
Bearing in mind that the code that renders properties is separate from the code that renders qualifiers, there are two issues:
  1. Linking qualifiers can be done simply but then you get (white). Presumably you want to check just for coordinates when processing qualifiers and link those. I've done that.
  2. I don't like small text, but I've made coordinates smaller (90%) when they are properties. The font size is set in line 247.
Let me know if you want those tweaked. --RexxS (talk) 23:00, 17 February 2021 (UTC)Reply
That's great, thank you. Ideally I would like to be able to select which properties and qualifiers get linked and which do not. (It could be a problem when certain values are repeated a lot on articles. For example there is some overlinking on List of crossings of the River Thames#Windsor to Reading now.) But for now, I think linking coordinates and not other qualifiers is working well. — Martin (MSGJ · talk) 13:24, 18 February 2021 (UTC)Reply
Overlinking of items in tables is one of the exceptions to MOS:OVERLINK because tables may be sorted, and hence it's impossible to predict which is the first occurrence of an item to link. Extra links cost nothing and can be a big benefit to the reader, especially in large tables. I can arrange for certain properties not to be linked, but it would need a lookup table as usual to enumerate them. See Module:WikidataIB/nolinks where I moved a list of specific items (rather than properties) that should not be linked out of the main module to ease internationalisation. --RexxS (talk) 17:26, 18 February 2021 (UTC)Reply

Locally defined column

edit

It's possible to set up a column which has all of its values supplied locally by using a dummy property like P1 which never has any values. For example:

Lighthouses in England
Lighthouse Image Location and Coordinates County Local values Height Focal height Range Operator
Maryport New Lighthouse   Maryport
54°43′4″N 3°30′38″W
Cumberlandsupplied locally4.7 m (15 ft), 6 m (20 ft)10 m (33 ft)6 nmi (11 km; 6.9 mi)Trinity House (until 2010), Maryport Harbour Authority (from 2010)

None of the properties P1 to P5 are in use. --RexxS (talk) 22:09, 14 February 2021 (UTC)Reply

Yep, P1 works well — Martin (MSGJ · talk) 22:25, 16 February 2021 (UTC)Reply

Can we allow the overrides to work if no PID is specified? (I know there is no point using this module in that case, but it would allow consistent syntax for each row of the table, even when wikidata items are not present.) Thank you — Martin (MSGJ · talk) 12:45, 18 February 2021 (UTC)Reply

Example, I just had to do this to display some rows that didn't have wikidata items. Usually I would just create the items, but in these cases I couldn't because I had no information on them at all. — Martin (MSGJ · talk) 13:38, 18 February 2021 (UTC)Reply
I can do it, but it will need a value for qid to indicate no wikidata. For now, I've simply used an invalid qid (e.g. blank) to trigger that. I've reverted your last edit to List of castles in Ireland and it looks okay. If you have any other bits of data (in c2, c3, etc.), they should still display properly. Perhaps you can check further? --RexxS (talk) 17:08, 18 February 2021 (UTC)Reply

Comma separator

edit

Please can a comma be used as a separator when multiple values for a property of qualifier are fetched? This might be better than adding a line break — Martin (MSGJ · talk) 22:22, 16 February 2021 (UTC)Reply

Crossing Type Co-ordinates Date opened Notes Photo
Chelsea Bridge  Road bridge, suspension bridge51°29′5″N 0°9′0″W6 May 1937[1] 

References

  1. ^ Matthews, Peter (2008). London's Bridges. Bloomsbury Publishing. ISBN 978-0-7478-0679-0. OL 23615119M. Wikidata Q105305831.
Sure. I've made it into a variable that you can set in line 10. Please feel free to play with it to see what's best. Let me know if you want different separators for properties and qualifiers. --RexxS (talk) 00:02, 17 February 2021 (UTC)Reply
Thanks. Any easy way to get an uppercase "R" and a lowercase "s"? I note that when there is a site link, it will be capitalised. When there is no site link then the label is used which is usually not capitalised. — Martin (MSGJ · talk) 11:28, 17 February 2021 (UTC)Reply
I've put it back to <br> when it is using values from different properties — Martin (MSGJ · talk) 11:42, 17 February 2021 (UTC)Reply

Capitalisation

edit
Any easy way to get an uppercase "R" and a lowercase "s"? I note that when there is a site link, it will be capitalised. When there is no site link then the label is used which is usually not capitalised. — Martin (MSGJ · talk) 11:28, 17 February 2021 (UTC)Reply
Capitalisation is always a problem. Site links will be in sentence case because of Wikipedia's policy on article titles, while labels are prose case because of Wikidata's policy.
I should have matched the initial capitalisation for each sitelink to the initial capitalisation of the label (so that proper nouns keep their initial capital). I've done that now.
It's possible to capitalise the first character of each table cell, or to capitalise the first character of each different property value in the table cell. I've tried the latter for now, but it's easy enough to change. It will go wrong if we have values like "iPhone", "eBay", etc. --RexxS (talk) 15:05, 17 February 2021 (UTC)Reply
I can't help thinking it would be easier just to use the label itself! — Martin (MSGJ · talk) 18:53, 17 February 2021 (UTC)Reply
Unfortunately, Enwiki articles are very often titled differently from the label on Wikidata. If the label were "Newport", making a link to Newport would not be very helpful to the reader. --RexxS (talk) 20:21, 17 February 2021 (UTC)Reply
Yes I know that. I meant piping to the label. — Martin (MSGJ · talk) 20:50, 17 February 2021 (UTC)Reply
Right. But if the article title had other capital letters not present in the Wikidata label, we'd get a redlink. I've had that happen in the past. Also, linking to the sitelink goes a long way to catching vandalism because it's easy to vandalise a Wikidata label, but near impossible to vandalise the sitelink. That makes it simple to spot what the label should be when fixing it.--RexxS (talk) 23:12, 17 February 2021 (UTC)Reply
I think we must be talking cross-purposes here. I got used to how Module:Wd handles these which is linking to the site link but piping to the label. This works perfectly in every case, in my opinion. I haven't actually experienced label vandalism (I'll take your word it happens) but in my opinion it's just as bad but no worse than vandalism on any number of fields that can be changed on wikidata (e.g. date of birth) and we don't have any extra measures to protect against that. — Martin (MSGJ · talk) 13:45, 18 February 2021 (UTC)Reply
I agree we are talking at cross purposes. Linking to the sitelink and displaying the label is exactly how it's done here when both exist, and I've done that since the first version of Module:Wikidata from 2013. However, I have been moaned at for using piped links when the display was the same as the link; see Template talk:Cite Q/Archive 3 #Piped links for the sort of criticism I get.
Module:WikidataIB takes the sitelink and cleans off any namespace and disambiguation to produce the display for the pipe, so avoids using the label, but that's slower, although it's much more vandal proof.
I don't understand how you think {{#invoke:wd|properties|linked|Q1069141|P31}}road bridge, suspension bridge "works perfectly" when the first item isn't capitalised as you asked for. — Preceding unsigned comment added by RexxS (talkcontribs)
Yes I see this module is following that principle (piping to "Wooden bridge" rather than "Timber bridge" below), so I don't know fully understand what the difference is now, it just seems a lot more convoluted somehow! — Martin (MSGJ · talk) 09:10, 19 February 2021 (UTC)Reply
The code is all in the _getLink function on lines 180-202. If anyone can suggest a simpler algorithm that does the same job, I'm all ears. --RexxS (talk) 23:42, 19 February 2021 (UTC)Reply

Why is "Wooden" capitalised below but "railway" is not? — Martin (MSGJ · talk) 13:48, 18 February 2021 (UTC)Reply

{| class="wikitable plainrowheaders sortable"
|-
! scope="col" | Crossing
! scope="col" | Type
! scope="col" | Co-ordinates
! scope="col" | Date opened
! scope="col" | Notes
! scope="col" | Image
{{list item/bridge1|qid=Q1270799}}
{{list item/bridge1|qid=Q737735|c5=Carrying the [[Great Western Main Line]].}}
|}
It's because I dealt with piped links and unlinked values, but forgot about unpiped links in the ucf function. Should be fixed now. --RexxS (talk) 18:52, 18 February 2021 (UTC)Reply

Please could the "s" in "second" be capitalised? (I know the label is lowercase!) — Martin (MSGJ · talk) 09:53, 19 February 2021 (UTC)Reply

Name Carries Opened
Second Tyne vehicle tunnel  A19 road25 Feb 2011
That one was easy - I forgot to capitalise the row header (which is processed separately). --RexxS (talk) 23:42, 19 February 2021 (UTC)Reply

External identifiers

edit

Could identifiers with formatter URL (P1630) be automatically be linked in the table? — Martin (MSGJ · talk) 18:36, 17 February 2021 (UTC)Reply

For example the NGA number below could be linked to 112-30608 — Martin (MSGJ · talk) 18:38, 17 February 2021 (UTC)Reply
{| class="wikitable sortable" style="margin:auto;text-align:center"
|-
! Name
! Year
! Location &<br /> coordinates
! [[Light characteristic#Class of Light|Class of Light]]
! Focal height
! [[National Geospatial-Intelligence Agency|NGA]] number
! [[United Kingdom Hydrographic Office|Admiralty]] number
! Range
{{list item/lighthouse2|qid=Q105134381}}
|}

Let's {{examine|Q105134381|P3563}}:

table#1 {
    table#2 {
        ["id"] = "Q105134381$25994bec-421f-42dd-f594-089af50eed59",
        ["mainsnak"] = table#3 {
            ["datatype"] = "external-id",
            ["datavalue"] = table#4 {
                ["type"] = "string",
                ["value"] = "112-30608",
            },
            ["property"] = "P3563",
            ["snaktype"] = "value",
        },
        ["rank"] = "normal",
        ["type"] = "statement",
    },
}

I can't extract the fact that a formatter url is available from that. We will need to construct a list of external-ids that we are interested in. We could retrieve the formatter URL (P1630) for the external identifier, e.g.

https://wikidata-externalid-url.toolforge.org/?url=https%3A%2F%2Fmsi.nga.mil%2FqueryResults%3Fpublications%2Fngalol%2Flights-buoys%3Fvolume%3D%251%26featureNumber%3D%252%26includeRemovals%3Dfalse%26output%3Dhtml&exp=(%5Cd%7B3%7D)-(.*)&id=$1

That sends the following to a tool-forge handler to create an external url:

msi.nga.mil/queryResults?publications/ngalol/lights-buoys?volume=%1&featureNumber=%2&includeRemovals=false&output=html -- exp=(\d{3})-(.*)&id=$1

Unfortunately the encoding of the formatter-url above isn't directly compatible with Scribunto's URI library (it's set up to be processed by php).

My preference would be to hard-code each formatter url into the list to avoid making the same extra Wikidata lookup many times more. Do you have any thoughts on how might we go about constructing such a list for all of the external identifiers? --RexxS (talk) 21:26, 17 February 2021 (UTC)Reply

At Template:List item/NGA number I was using {{Formatter link}} but I am imagine this is quite resource-heavy and so to be avoided? — Martin (MSGJ · talk) 22:17, 17 February 2021 (UTC)Reply
Yes, I seem to think I wrote {{Formatter link}}, so I was intending to replicate its functionality directly without having to call the toolforge link. But following that link isn't part of the page rendering, so it won't be much of a burden. I've implemented the functionality and added NGA lighthouse ID (P3563) to the table at line 63. Please feel free to add other formatter urls that you want to be linked. --RexxS (talk) 00:10, 18 February 2021 (UTC)Reply
Ah, so you did! I am bit worried about hard-coding these formatter URLs in the module, because they do change from time to time. The property on wikidata would probably be updated quite quickly, but unless you or I happened to be around, no one would know to update the module. Anyway, working well for now ... — Martin (MSGJ · talk) 13:30, 18 February 2021 (UTC)Reply
Wikipedia has 6,252,110 articles and 148,305 active users. That represents 42 articles per user. Wikidata has 92,632,749 articles and 26,719 active users. That represents 3,466 articles per user. My experience is that when something changes, it gets noticed a hundred times quicker on Wikipedia. My recommendation is to leave an html hidden comment in the article or template next to the line that defines pids with a link to the Wikidata item that defines the formatter url, like this: https://www.wikidata.org/wiki/Property:P3563#P1630 for the NGA lighthouse ID (P3563). It is a real performance loss to read the same fixed Wikidata value on every line of a table when that value changes rarely. --RexxS (talk) 17:49, 18 February 2021 (UTC)Reply
edit

The link to State Road 108 (Serbia) has not resolved properly — Martin (MSGJ · talk) 09:06, 19 February 2021 (UTC)Reply

Crossing Distance Carries Location Built Coordinates Photograph
Ilok–Bačka Palanka Bridge  1297D2 road, IIA-108 highwayIlok, Bačka Palanka197445°13′58″N 19°24′6″E 
@RexxS: I would appreciate if you could fix this error, thanks! — Martin (MSGJ · talk) 21:39, 19 February 2021 (UTC)Reply
@Martin: Multiple piped values for a property weren't being handled properly because there was more than one pipe character. I've improved the logic in the ucf function. --RexxS (talk) 23:11, 19 February 2021 (UTC)Reply

Coordinates

edit

We are now using two different icons for coordinates, dependent on whether they are main property or qualifier. I think I prefer the second one. The globe is not really identifiable at that size anyway. — Martin (MSGJ · talk) 09:21, 19 February 2021 (UTC)Reply

Crossing Carries Location Miles above the Ohio Coordinates Photo
Black Hawk Bridge  Iowa Highway 9, Wisconsin Highway 82Lansing663.443°21′55″N 91°12′54″W 
Name Length Source Mouth Photo
River Gannel  13 km (8.1 mi)Carland Cross (50°20′57″N 5°1′32″W)Atlantic Ocean 
Okay, the property was being rendered by passing through {{coord}} to obtain the full functionality (decimal or dms, etc,), but if you're happy with the default output from the built-in mw.wikibase.formatValue() function, that will improve performance. --RexxS (talk) 00:19, 20 February 2021 (UTC)Reply
After I asked for qualifiers to be on the same line, I find myself wishing that in some cases (like the one above) the qualifier go on a new line and unbracketed. I don't know how to formulate what looks best in each case. Perhaps if I use the "+" notation instead of the "/" notation it would know to use a new line and no brackets? But then it would be looking for a main property rather than qualifier. — Martin (MSGJ · talk) 17:51, 20 February 2021 (UTC)Reply
You can't use , + / as the code looks for them and splits the list of pids at those points. Fortuitously, the quals separator can be anything else (well, not P, | or a digit), and I just suggested - as a counterpart to +. So you can pick two unused symbols, then I'll code one for the "space and brackets" separator and the other for the "new line and no brackets" separator. Take your pick: (! £ $ % ^ & * - ~ # @ and lots more). --RexxS (talk) 20:08, 20 February 2021 (UTC)Reply
@MSGJ: did you get a chance to think about what you want for these cases? --RexxS (talk) 01:12, 23 February 2021 (UTC)Reply
Not really but I will give it some thought! Are these punctuation marks really the best syntax for this? — Martin (MSGJ · talk) 08:37, 24 February 2021 (UTC)Reply

Dates

edit

I notice that all dates are currently being rounded to the year, so the following shows 2008 instead of the exact date 30 September 2008. I found the setting to change the date format in the module, but when I changed it to dmy all the dates with only years specified were then displayed as 1 Jan ----. It would be good to display them to the accuracy that is available (but I don't know how to tackle the mdy vs dmy problem.) — Martin (MSGJ · talk) 09:26, 19 February 2021 (UTC)Reply

Crossing Distance from mouth Carries Location Opened Coordinates Photo
Megyeri Bridge  1660M0 motorwayBudapest, Dunakeszi30 Sep 200847°36′25″N 19°5′31″E 
I've amended the code to read the date precision (if set) on Wikidata, which will switch between (year only), (month and year), or (day month year).
The module accepts an optional parameter |df=mdy that will set (month day, year) format. It defaults to dmy.
Crossing Distance from mouth Carries Location Opened Coordinates Photo
Megyeri Bridge  1660M0 motorwayBudapest, DunakesziSep 30, 200847°36′25″N 19°5′31″E 
I'm using three-character abbreviations for month names as space can be tight in a table. If you would prefer full month names, amend line 246 to read:
month = months[tonumber(month)]
--RexxS (talk) 01:01, 20 February 2021 (UTC)Reply
Thanks. Abbreviations are good — Martin (MSGJ · talk) 17:46, 20 February 2021 (UTC)Reply

Could the date (December 1832) below be abbreviated? Also I think the default accuracy of month+year would be sufficient for qualifiers. Thanks — Martin (MSGJ · talk) 16:24, 22 February 2021 (UTC)Reply

Lighthouse Image Location
coordinates
County First lit Decom­mis­sioned Tower height Former operator(s)
Burnham-on-Sea Round Tower   Burnham-on-Sea
51°14′23″N 2°59′54″W
Somerset1832[a]Trinity House (from 1829 until Dec 1832)

And one more request. The date below is recorded as 2nd century on Wikidata, but displayed here as 200 (which is the first year in the 3rd century). Could the precision be shown appropriately? — Martin (MSGJ · talk) 16:27, 22 February 2021 (UTC)Reply

Lighthouse Image Location
coordinates
County First lit Decom­mis­sioned Tower height Former operator(s)
Dubris Pharos[b]   Dover Castle
51°7′42″N 1°19′23″E[1]
Kent[c]19 m (62 ft)

Notes

  1. ^ Replaced by High & Low lights in 1832.
  2. ^ Also known as the Dover Pharos or Roman Pharos.
  3. ^ Dating varies from AD 50 to 150.
Bleh. Wikidata renders it as "2. century" by default. Who uses that? I've rewritten the date handling completely. The parameter |df= now only differentiates between dmy and mdy formats, as it's global for the row and you don't want to fix "year" or "month year" across the entire row. The date format depends on the precision stored on Wikidata, except for qualifiers which no longer display day. --RexxS (talk) 00:48, 23 February 2021 (UTC)Reply
Thanks — Martin (MSGJ · talk) 08:39, 24 February 2021 (UTC)Reply

Template:List item

edit

I have now orphaned Template:List item by converting all articles to use this module instead. I'm a bit sad to see it go because I liked that template. Pity the performance wasn't good enough. — Martin (MSGJ · talk) 17:54, 20 February 2021 (UTC)Reply

makerows

edit

I am just wondering if all this added functionality would be available to the makerows function too? There are quite a lot of articles which don't have any row customisation (e.g. List of lighthouses in Madagascar which I did yesterday) which might be able to use that function more efficiently. — Martin (MSGJ · talk) 08:39, 24 February 2021 (UTC)Reply

@MSGJ: Unfortunately, I'm going to be distracted by an ArCom case for the foreseeable future. I'll get back to these issues if and when I'm able to. --RexxS (talk) 19:26, 24 February 2021 (UTC)Reply
Sorry about that — Martin (MSGJ · talk) 21:10, 24 February 2021 (UTC)Reply

New script errors

edit

New script errors have appeared at multiple template pages, including Template:Wdtable row/lighthouse9. They may be related to recent changes to this module. – Jonesey95 (talk) 13:53, 3 May 2022 (UTC)Reply

Also see multiple sections above, on this talk page. Pinging MSGJ. – Jonesey95 (talk) 13:54, 3 May 2022 (UTC)Reply
Apologies and that is now fixed — Martin (MSGJ · talk) 13:56, 3 May 2022 (UTC)Reply
Thanks, and no worries. Bugs happen. – Jonesey95 (talk) 14:41, 3 May 2022 (UTC)Reply

List of crossings of the River Thames

edit

List of crossings of the River Thames seems to be the only article currently using this template directly, and it's adding a comma to the end of the URL in some reference, breaking the reference link and showing as a "Check |url= value" in the reference section. There have been no recent changes to the code. Could someone please take a look? Thanks. Storchy (talk) 09:14, 25 September 2022 (UTC)Reply

  Fixed This is my fault, sorry. * Pppery * it has begun... 16:02, 25 September 2022 (UTC)Reply
Thanks for the quick turnaround! Storchy (talk) 16:05, 25 September 2022 (UTC)Reply

This is a very problematic module

edit

I just happened upon this module being used in some standalone lists. While this may have some niche uses, I think it is very problematic for general use in lists. It makes editing lists by someone without an intense knowledge of Wikidata next to impossible. Some policy ought to be added to discourage its use for accessibility sake. IronGargoyle (talk) 01:47, 20 August 2023 (UTC)Reply

Thanks for your comments. This template/module was designed to try and make it easier for editors to include data tables, so if you have any suggestions on how it can be improved then please let me know, particularly if it relates to accessibility. You may be significantly overestimating the difficulty of using Wikidata while underestimating how hard it can be for newcomers to produce tables using wikicode. — Martin (MSGJ · talk) 14:41, 4 October 2023 (UTC)Reply
Note for the record: Wikipedia:Village pump (proposals)/Archive 197#Wikidata lists. This is a perpetual frozen conflict. * Pppery * it has begun... 23:16, 4 October 2023 (UTC)Reply