Template talk:Taginfo2

From OpenStreetMap Wiki
Jump to navigation Jump to search

Code review

@ZeLonewolf: I took the liberty of making a couple messages and numbers localizable. Apart from that, here are a couple things that need attention before going live:

  • Template:TaginfoAJAX and User:ZeLonewolf/taginfo.js appear to rely pretty heavily on ids, which makes it risky to embed a template for the same tag multiple times on the same page. (IDs are supposed to be unique.) Let's try to rely on classes or relative selectors as much as possible. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Templates/scripts have all been converted to class-based selectors --ZeLonewolf (talk) 02:29, 4 January 2021 (UTC)
  • The taginfo-hidden spans add some hidden text to the page. If CSS happens to be turned off for some reason, these strings will show. It also isn't great for screen reader accessibility, to the extent that we're concerned about it. MediaWiki supports HTML5 data attributes, so you can store this text in e.g. data-ti-error="…" on the outermost tag, which is cleaner and avoids these issues. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Error messages have been converted to use HTML5 data items --ZeLonewolf (talk) 00:16, 9 January 2021 (UTC)
  • I replaced Number.prototype.toLocaleString() with mw.language.convertNumber(), so if your browser is set to English but your wiki preferences are set to French, you'll see French-formatted numbers alongside the French-language messages. Unfortunately, this library doesn't provide percentage formatting (which differs between English and French and other languages). Fortunately, MediaWiki:Percent provides the percentage format, but we'll have to stuff it in one of those data attributes on one of the tags. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Percentages now use the i18n percent template! --ZeLonewolf (talk) 00:16, 9 January 2021 (UTC)
  • User:ZeLonewolf/taginfo.js uses an arrow function, which isn't supported by Internet Explorer 11. MediaWiki still supports IE 11 at grade A (meaning it loads JavaScript), but this unsupported syntax will prevent any JavaScript-based features from working. I don't know how much this wiki specifically cares about IE 11; we haven't really needed to think about browser compatibility before, because we haven't done extensive gadget and user script development here. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Arrow functions have been replaced with traditional function calls. --ZeLonewolf (talk) 02:40, 4 January 2021 (UTC)
How's this? Taginfo route master.png --ZeLonewolf (talk) 02:27, 4 January 2021 (UTC)
@ZeLonewolf: Looks good! I created MediaWiki:Taginfo-empty-role so that bit can be localized too. – Minh Nguyễn 💬 10:10, 4 January 2021 (UTC)
Resolved: Empty roles are implemented --ZeLonewolf (talk) 20:29, 9 January 2021 (UTC)

Displaying

First of all a big thank you for the effort to create an improving replacement for taginfo template! Two first impressions:
I notice, the new displays need more space than old ones. That leeds to once more longer tables. Perhaps the layout or formating could be tuned again to save space.
In mobile view of the Wiki there occur some issues for me (Firefox Android): large whitespaces, not all % symbols are shown, overlapping text if rotating device. Chris2map (talk) 14:36, 3 January 2021 (UTC)

Thanks for the review! I was thinking that we could make the tag name, "powered by taginfo", and "all types count" suppressible, which would give you up to 3 rows back. I'll have to take a look on mobile to see what's going on re: strange display artifacts. --ZeLonewolf (talk) 14:42, 3 January 2021 (UTC)
These optional parameters would be good. Maybe one to show the "all types count" only? --Chris2map (talk) 17:31, 3 January 2021 (UTC)
Done. Each part of this (tag link, taginfo link, percentages, node/way/relation/all counts) can be individually disabled.
Layout should look good on mobile, I switched all of the sizings to em. --ZeLonewolf (talk) 02:08, 4 January 2021 (UTC)
Perfect! Works fine now on mobile, too. And the options are top! --Chris2map (talk) 19:26, 4 January 2021 (UTC)
When the box is only showing the grand total and not the header, it should still have a link to taginfo as a courtesy and a way to get the full details. – Minh Nguyễn 💬 00:19, 5 January 2021 (UTC)

That is a point. Perhaps the icons could link to the tag on taginfo (rather hidden). Or the "all counts" is in bold text and works as link at the same time.
I suggest to rename parameter taginfoLink into footer. It's clearer / easier to understand IMO. -- Chris2map (talk) 12:49, 5 January 2021 (UTC)

The link parameter is now "footer" --ZeLonewolf (talk) 00:24, 9 January 2021 (UTC)
Resolved: footer is implemented, and icons now link to taginfo. --ZeLonewolf (talk) 20:29, 9 January 2021 (UTC)

Alternative Taginfo instances

Would it be an idea to be able to report national statistics from separate instances of Taginfo? --Andrew (talk) 20:20, 4 January 2021 (UTC)

Can you describe what you mean by that? Are there multiple instances of taginfo? It would certainly be possible to parameterize a URL for an alternative taginfo instance. --ZeLonewolf (talk) 20:23, 4 January 2021 (UTC)
For example https://taginfo.openstreetmap.org.uk/ reports a British subset of the data, Taginfo/Sites has more. --Andrew (talk) 21:41, 4 January 2021 (UTC)
Resolved: The url parameter allows you to specify a different taginfo instance. --ZeLonewolf (talk) 03:23, 9 January 2021 (UTC)

How it works?

Looking at the template code I have no idea at all how it works or even where API is called. Is it maybe possible to document it a bit? At least the part that it makes API calls on each page load (it works this way, right?) What #tag:osmtaginfo is doing and where it is defined and so on would be also nice. Mateusz Konieczny (talk) 10:05, 11 January 2021 (UTC)

How's this? Template:Taginfo2/doc#See_also. The code for osmtaginfo is here. --ZeLonewolf (talk) 03:25, 12 January 2021 (UTC)
Taginfo/Embedding describes iframe method that was used in the old template, not here (as far as I know/remember). Or is iframe used in both? Mateusz Konieczny (talk) 09:09, 12 January 2021 (UTC)