Jump to content

Module talk:WikidataIB/Archive 7

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 06:56, 24 November 2020 (Archiving 1 discussion(s) from Module talk:WikidataIB) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 5Archive 6Archive 7Archive 8

Add more wbr in URLs

{{edit template-protected}} The current url2 function only adds soft line-breaks after dots in the URL. This is insufficient for things as simple as http://opensource.org/licenses/HPND when put in an infobox.

Since the function already references Module:URL, a much better way to do it would be to just reuse what the Module exports. The block starting with p.url2 should be rewritten as:

local fmt_url = require([[Module:URL]])._url           -- put this near the top

-------------------------------------------------------------------------------
-- url2 takes a parameter url= that is a proper url potentially followed by an edit icon
-- It returns a wikitext representation with line-wraps for infobox use.
-- If no parameter is supplied, it returns nothing.
-- This is the equivalent of Template:URL
-- but it keeps the "edit at Wikidata" pen icon out of the microformat.
-- Usually it will take its url parameter directly from a Wikidata call:
-- e.g. {{#invoke:WikidataIB |url2 |url={{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}}
-------------------------------------------------------------------------------
-- Dependencies: Module:URL
-------------------------------------------------------------------------------
p.url2 = function(frame)
	local txt = frame.args.url or ""
	if txt == "" then return nil end
	local url, icon = txt:match("(.+) (.+)")
	return fmt_url(url or txt) .. (icon and ' ' .. icon or "")
end

Artoria2e5 🌉 12:37, 15 July 2020 (UTC)

The module doesn't currently reference Module:URL and it's preferable to reduce the number of external dependencies, rather than increase them unnecessarily. One of the issues with using {{URL}} which prompted the fork to {{URL2}} was that passing a blank url causes an error message by default in URL, but not in URL2:
  • {{#invoke:URL |url | }}{{URL|example.com|optional display text}}
  • {{#invoke:WikidataIB |url2 |url= }}
There is little point in re-using the code from Module:URL if it's going to reintroduce the problem that the fork was intended to fix. If the extra functionality required is simply to add word break opportunities at forward-slashes, then simplistically, changing to
  • local disp, _ = addr:gsub("%.", "<wbr>."):gsub("/", "<wbr>/")
    
would seem to me to achieve the desired result. Similarly, fragments could be accommodated, but I don't see the use-case for that in infoboxes. --RexxS (talk) 20:10, 15 July 2020 (UTC)

Infoboxes still using Module:Wikidata directly

And here are 97 more that are using Module:Wikidata directly:

Extended content

I have noted infoboxes with 2,000 or more transclusions; I may have missed a couple, made an error or two, or both. All of the above need to be checked manually to see if they really do transclude Module:Wikidata and if they are convertible to WikidataIB; I didn't do any checking myself.

Any editor here is welcome to annotate, strike out, or otherwise fix or update either of the lists above. – Jonesey95 (talk) 19:43, 2 July 2020 (UTC)

I am not sure if all of those are directly transcluded invocations or not. I would start with a source search like searching template source for "FETCH_WIKIDATA" (Module:Wikidata seems to be the only thing that uses the "FETCH_WIKIDATA" sentinel value; after we get rid of those we can look harder for every transcluded invocation) instead of Special:WhatLinksHere/Module:Wikidata. There is also some more useful information at Module talk:Wikidata#Porting Guide. —Uzume (talk) 15:31, 13 September 2020 (UTC)
I am not sure either, hence my disclaimers above, but they are easy to check by looking at the template code. Infobox AFL biography, for example, contains "invoke:Wikidata|claim|P18" in its template code. The search result linked above contains 100 infobox templates (excluding sandboxes) and overlaps pretty well with the list I made above. If you want to add to the list above, please do so. If you find that a template in the list above does not need modification, feel free to strike it out, as I have done with Infobox Tibetan Buddhist monastery. – Jonesey95 (talk) 15:46, 13 September 2020 (UTC)

Uppercase first letter

Is there an easy way to make the first character uppercase (which is the usual format for parameters in an infobox) apart from stripping off the icon and using the ucfirst magic word? — Martin (MSGJ · talk) 13:41, 23 September 2020 (UTC)

Instead of the magic word, you could try this. Rehman 15:24, 23 September 2020 (UTC)
Perfect, thank you — Martin (MSGJ · talk) 15:58, 23 September 2020 (UTC)

Convert units

I know {{convert}} contains from clever functions to get quantities from wikidata and convert them. I wondered if it possible to use this module, so that the parameters |fwd= and |osd= can be used to match the other fields in the infobox. But I don't if/how I can put the output of this module through the convert template. Any advice please? — Martin (MSGJ · talk) 13:29, 23 September 2020 (UTC)

Have you looked at the (extensive!) documentation for Module:Wikidata or Module:Wd? Do a Find for "unit" on those pages. – Jonesey95 (talk) 15:20, 23 September 2020 (UTC)
@Martin: If you want to stick with WikidataIB, you can use the |convert= parameter (alias conv) which pipes the output directly through Template:Cvt:
It's documented at Module:WikidataIB #Parameters to getValue. Hope that helps. --RexxS (talk) 16:47, 23 September 2020 (UTC)
That's just what I'm looking for, thanks. I looked through that table twice so no idea why I didn't spot that option. — Martin (MSGJ · talk) 17:50, 23 September 2020 (UTC)

Label truncated

{{#invoke:WikidataIB|getLabel|qid=Q6918608}}

gives Mott, Hay and Anderson

{{#invoke:WikidataIB|getValue|qid=Q940078|P287|fwd=ALL|osd=0}}

gives Mott, Hay and Anderson Edit this on Wikidata (now fixed, was just Mott)

For some reason the label is truncated, presumably because of the comma. How can I override this? — Martin (MSGJ · talk) 13:10, 23 September 2020 (UTC)

@Martin: That's a tough one, because the module prefers the local sitename (where it exists) to avoid using the label because of vandalism. Unfortunately, enwiki article titles commonly contain parenthetical or comma separated disambiguators, so it strips anything in parentheses or after a comma, e.g. John Smith (cricketer)John Smith and Hayes, Middlesex → Hayes. I could create another parameter to switch to using the label instead of the sitename, but it would leave the field much more vulnerable to vandalism. I'll knock up some code in the sandbox to check it out. --RexxS (talk) 17:09, 23 September 2020 (UTC)
@Martin: In the sandbox, I've implemented a new parameter |uselabel= (alias uselbl, defaults to false) that forces the call to display the label instead of displaying the disambiguated sitelink:
  • {{#invoke:WikidataIB/sandbox|getValue|qid=Q940078|P287|fwd=ALL|osd=n}}Mott, Hay and Anderson Edit this on Wikidata (now fixed, was just Mott)
  • {{#invoke:WikidataIB/sandbox|getValue|qid=Q940078|P287|fwd=ALL|osd=n |uselbl=y}}Mott, Hay and Anderson Edit this on Wikidata
See if that does the job for you and we can update the main module if so. --RexxS (talk) 17:43, 23 September 2020 (UTC)
That would be perfect. I think using the label would be better in most cases, although if vandalism is a real problem then I can understand reluctance. — Martin (MSGJ · talk) 17:47, 23 September 2020 (UTC)
@Martin: I'm afraid that vandalism of labels on Wikidata is a huge problem, while it's near impossible to vandalise a sitelink – hence the effort I put in to using the sitelink by default. I often look at the Wikidata vandalism dashboard and remain discouraged by the amount of vandalism that occurs. The root cause is that there are only about 46 articles per active user on the English Wikipedia, while there are 3747 articles per active user on Wikidata. I've updated the main module now. --RexxS (talk) 18:45, 23 September 2020 (UTC)
  • {{#invoke:WikidataIB|getValue|qid=Q940078|P287|fwd=ALL|osd=n}}Mott, Hay and Anderson Edit this on Wikidata (now fixed, was just Mott)
  • {{#invoke:WikidataIB|getValue|qid=Q940078|P287|fwd=ALL|osd=n |uselbl=y}}Mott, Hay and Anderson Edit this on Wikidata
Thanks, I have used it for that particular property to avoid the original problem. But unless I use |uselbl=y for every property, there is no way to ensure it won't happen with another property. How about the following: if the sitelink equals the label or one of the aliases (up to case differences) then do not truncate the commas. — Martin (MSGJ · talk) 19:52, 23 September 2020 (UTC)
@Martin: That's looks like a good improvement. Aliases are another can of worms, so I've left that out for the moment, but skipping the sitelink processing altogether if the the label and sitelink are the same (apart from case) should clearly be more efficient. The implementation in the sandbox looks good enough and simple enough for me to be confident in updating the main module. It should all work now without using the |uselbl= parameter. Thank you. --RexxS (talk) 14:22, 24 September 2020 (UTC)