Page MenuHomePhabricator

Display popups for annotated <math> tags without touching popups extension code
Closed, ResolvedPublic

Description

The container element of <math> may contain a "data-qid" attribute that refers to a Wikidata element (see Change 471772). We want to show a popup of some information from Wikidata, such as the description in the language $wgContLang.

photo_2019-12-13_11-50-09.jpg (720×1 px, 120 KB)

  • As a preliminary step, we have implemented a special page that is shown, if one clicks on annotated math tags.
  • We have developed a demo that uses the popup extension to display that information in the popups extension https://gerrit.wikimedia.org/r/c/527547. However, this code can not be merged in its current shape.
  • Enable JS unit tests in math (T288074)
  • Update the API to generate the content of the popup in HTML format independent of the mechanism that will be used to display the popup (T288076).
  • Decide if the Popups extension is best suitable for our use case or if we should consider alternatives.
  • Fix API between Math and Page-previews (T233099)

Related Objects

StatusSubtypeAssignedTask
ResolvedPhysikerwelt
ResolvedPhysikerwelt
InvalidAndreg-p
ResolvedAndreg-p
DeclinedBUG REPORTNone
ResolvedAndreg-p
ResolvedPhysikerwelt
ResolvedPRODUCTION ERRORAndreg-p
Resolvedovasileva
ResolvedPhysikerwelt
OpenNone
ResolvedBUG REPORTovasileva
ResolvedBUG REPORTovasileva
ResolvedBUG REPORTovasileva
ResolvedPhysikerwelt
ResolvedAndreg-p
ResolvedAndreg-p
ResolvedPhysikerwelt

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Andreg-p changed the task status from Stalled to Open.Oct 18 2019, 8:20 AM

Change 527556 merged by jenkins-bot:
[mediawiki/extensions/Math@master] Add special page and API endpoint that show information from math Wikibase items

https://gerrit.wikimedia.org/r/527556

Change 551180 had a related patch set uploaded (by Physikerwelt; owner: Physikerwelt):
[operations/mediawiki-config@master] Enable links from math formulae on beta

https://gerrit.wikimedia.org/r/551180

Change 551215 had a related patch set uploaded (by AndreG-P; owner: AndreG-P):
[mediawiki/extensions/Math@master] Delete Wikibase repository dependency in Math extension

https://gerrit.wikimedia.org/r/551215

Change 551215 merged by jenkins-bot:
[mediawiki/extensions/Math@master] Delete Wikibase repository dependency in Math extension

https://gerrit.wikimedia.org/r/551215

Change 551180 merged by jenkins-bot:
[operations/mediawiki-config@master] Enable links from math formulae on beta

https://gerrit.wikimedia.org/r/551180

Mentioned in SAL (#wikimedia-operations) [2019-11-19T07:33:31Z] <mobrovac@deploy1001> Synchronized wmf-config/CommonSettings-labs.php: Enable math links in Beta - T208758 (duration: 00m 53s)

Physikerwelt renamed this task from Extend Popups-Extension to render popups for annotated <math> to Display popups annotated <math> tags.Dec 11 2019, 6:31 PM
Physikerwelt updated the task description. (Show Details)
Physikerwelt renamed this task from Display popups annotated <math> tags to Display popups for annotated <math> tags.Dec 11 2019, 6:42 PM

To me, it sounds most reasonable to switch the API as outlined in T240458 as the next step. From there we can decide if we continue with the popups extension or just use a custom solution. This could then start as a gadget or beta feature. I liked tippy a lot, which I used for a research project. But the API is very handy and its really easy to implement.

image.png (1×1 px, 225 KB)
,
image.png (1×1 px, 231 KB)

@Physikerwelt following up from our email, here is some design feedback:

Visual treatment on links
Imagine you are reading this section and you would like to see definitions for the equations. Some equations you can hover and the preview will appear, others will not show a preview because they have not been linked. The math equations that are linked should have some kind of visual treatment that indicates to people that you can hover over it and a preview will appear. I understand that you do not want to turn all math equations blue. Is there some other treatment you could explore here?

Interactivity
This goes along with the point above — when someone is hovering over a linked math equation there should be some visual indication (aside from the cursor changing) that the link is being hovered. As you can see with normal blue links when they are hovered an underline appears. This gives valuable feedback to the person using the website about what is happening, or what will happen if they click.

Layout of preview
Where can I see the latest example of how the preview will look? I've found this image on T239357 but I'm not sure if that's accurate.

In T208758#5853590, @alexhollender wrote:

@Physikerwelt following up from our email, here is some design feedback:

Visual treatment on links
Imagine you are reading this section and you would like to see definitions for the equations. Some equations you can hover and the preview will appear, others will not show a preview because they have not been linked. The math equations that are linked should have some kind of visual treatment that indicates to people that you can hover over it and a preview will appear. I understand that you do not want to turn all math equations blue. Is there some other treatment you could explore here?

Interactivity
This goes along with the point above — when someone is hovering over a linked math equation there should be some visual indication (aside from the cursor changing) that the link is being hovered. As you can see with normal blue links when they are hovered an underline appears. This gives valuable feedback to the person using the website about what is happening, or what will happen if they click.

Those two issues are important, but I think independet of the popup. I would move them to a seperate issue, ok?

Layout of preview
Where can I see the latest example of how the preview will look? I've found this image on T239357 but I'm not sure if that's accurate.

Yes. This is the current proposal.

@Physikerwelt ok, is there a separate task that exists? I think we should think of the visual treatment on links and interactivity as design requirements for this feature.

@alexhollender the two issues on the link are independent of the goodwill of the page preview team. We can just fix these drawbacks of the current implementation. For the popup itself, we need a commitment of the page preview team to that feature. Therefore I suggest we fix the hard things first and decide on an implementation plan for the popup feature. Or do you have other thoughts? I think it is important to join forces and move together in the same direction.

@alexhollender yes the picture is up to date.
I updated the picture in the issue description also.

The design is experimental. I split the textual description and the mathematical components and organized the components as a table on the right. It might look a bit squeezed.

If you have any suggestions about the design, we can easily change that.

photo_2019-12-13_11-50-09.jpg (720×1 px, 120 KB)

@Andreg-p would it be possible for you to show me a few other examples of equation previews? I would like to make some layout suggestions and having other examples would be helpful.

Also, what possibilities do you have for styling the hover state of the equation itself? I think it would be appropriate to add an underline when you hover over it if it has a preview available.

@alexhollender, I'm sorry for my late response. I have trouble setting up my new system to the point when I created the popups. So let me explain the concept a bit more in detail. Clicking on the popup will lead to a special page with all information, e.g. for the mass-energy equivalence it is this page: Special:MathWikibase&qid=Q35875

ScreenshotSpecialPage.png (510×779 px, 28 KB)

In the popup, we want to show essentially a preview of this SpecialPage, i.e., the name of the formula, the type, the description text, and the elements of the formula. The current popup does exactly this.

Explained.jpg (233×425 px, 48 KB)

The popup contains two columns side by side (blue and green frame). The left column (blue frame) contains the name (in bold) followed by the type and the description text. The right side (green frame) is the list of the elements with their names (yellow frames).

Since we tried to take advantage of the existing popup extension, the content of the popup is just simple HTML. The real problem is the space limitation since some expressions are just very complex and may contain a bunch of elements, e.g., Special:MathWikibase&qid=Q1899432. I had the idea to show ellipsis at the end, if the content does not fit the popup, but I was not able to implement that yet. We were also not yet sure how the preview should change if the content is a right-left language.

Also, what possibilities do you have for styling the hover state of the equation itself? I think it would be appropriate to add an underline when you hover over it if it has a preview available.

I think it is a very nice idea to change the styling just for the hover state. However, since some browsers still only support pictures of an equation (no MathML), it would be difficult to change the style of the font itself (e.g., bold equations or colored equations). Borders of the equation (e.g., underlines or box frames) would be possible to support all browsers. @Physikerwelt might say more about the limitations.

By the way, please note that the system will also support inline math (i.e., math that is in the text rather than separated from the text).

@Andreg-p @alexhollender I am not sure if this process fruitful. Can you imagine some other way to bypass the regular popups extension and just use some well established JS library to create a custom popup? I think for example https://atomiks.github.io/tippyjs/ could be copied to the math extensions lib folder. See the visual editor repo for an example https://github.com/wikimedia/VisualEditor/blob/master/lib/jquery/jquery.js (here the jquery library). I think with this approach we could generate even more specific popups.

@Physikerwelt @alexhollender This seems to be a valid option for me. However, somebody should confirm that an additional pop-up library is acceptable. Otherwise, we run into a dead-end again.

@Andreg-p @alexhollender I am not sure if this process fruitful. Can you imagine some other way to bypass the regular popups extension and just use some well established JS library to create a custom popup? I think for example https://atomiks.github.io/tippyjs/ could be copied to the math extensions lib folder. See the visual editor repo for an example https://github.com/wikimedia/VisualEditor/blob/master/lib/jquery/jquery.js (here the jquery library). I think with this approach we could generate even more specific popups.

Hey @Physikerwelt — can you explain what limitations you are running into with the current popup extension? Design limitations? Code/engineering limitations? In T208758#5971171 @Andreg-p mentioned the space limitation, however I think it should be fine to use a larger size for the popup if needed here. Regarding using a different popup library I think @Jdlrobson would be a good person to consult about that.

There is nothing wrong with the code or capabilities of the popups extension itself. However, human coordination between popup extensions development and our own timeline seems impossible. @Andreg-p has uploaded the functional change https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Popups/+/527547 over a year ago and there is no real progress. Thus it might be wise to decouple things here, and just find a suitable way that can be implemented without dependencies to the popups extension.

Physikerwelt renamed this task from Display popups for annotated <math> tags to Display popups for annotated <math> tags without touching popups extension code.Sep 20 2020, 8:57 AM

To be honest I'm somewhat confused. What I see in the patch https://gerrit.wikimedia.org/r/527547 looks fine, based on what I learned about the Popups extension when my team worked on Reference Previews. It's not perfect, sure, but good enough for what's needed here and now. Further changes (i.e. introducing a way to register new popup types instead of hard-coding them in multiple places) can be done any time later. But:

  • The patch is in conflict.
  • It misses tests.
  • No reviewers are assigned.
  • This task here explains the patch "can not be merged in its current shape". The bullet point is checked off, as if the patch is not relevant any more.
  • I don't see a response to what Alex wrote above (might be that it happened via another channel). One actual limitation I'm aware of is that the popup windows shown by the Popups extension can be as high as you want, but are limited to a very specific width. Is this an issue for you?

My team doesn't own the extension (only the parts related to reference previews). I'm not in a position where I can make decisions. But: I believe it should be fine to do the same with math previews as WMDE did with reference previews. Back then we realized that the domain-specific code for our Reference Previews feature (i.e. code exclusively needed for this one popup type) is rather tiny. Sure, it would be a nice tech challenge to find a way to register new popup types from another extension – from Cite in our case, from Math in yours (T233099). But the resources needed to make something like this possible would be huge, compared to just adding a few dozen lines directly to the Popups codebase. And that's what we did. We synched with WMF regularly, but did code reviews and merges within the WMDE team. Can't you do the same?

@thiemowmde thank you. I think originally we tried to follow the example of Reference Previews. (cf, https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Popups/+/527547/2/src/index.js) I have discussed this with @Andreg-p toady and we will just fix the points you mention, and see how to proceed from there. I don't think we are in a position where I would feel comfortable with merging something into the popups extension as you did here https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Popups/+/487352 Keep in mind, we are researchers doing some coding from time to time. Maybe, we just a communication problem related to T239357. We can implement both the new or the old API. However, the new API would require more change in the Popups repo (which I suggest is unlikely to happen).

@Physikerwelt @alexhollender This seems to be a valid option for me. However, somebody should confirm that an additional pop-up library is acceptable. Otherwise, we run into a dead-end again.

@thiemowmde @alexhollender @Physikerwelt Can we shortly discuss on this matter before I actually move on and try to push new code to the popups extension again?

I see two options.

  1. Either we implement our own popup and put it into the Math extension, e.g., via the mentioned JS library https://atomiks.github.io/tippyjs/ (@Jdlrobson other suggestions are very much welcome).
  2. Or, we try to push our popup-layout into the existing popup extension and make it workable for math.

Please let me know which option is acceptable.

I see two options.

  1. Either we implement our own popup and put it into the Math extension, e.g., via the mentioned JS library https://atomiks.github.io/tippyjs/ (@Jdlrobson other suggestions are very much welcome).

I think this is the very last emergency option if diplomacy fails completely. Maintaining this extra addon is conceptually a undesirable option since it somehow duplicates functionally if one regards mediawiki as ONE product.

  1. Or, we try to push our popup-layout into the existing popup extension and make it workable for math.

I don't really understand who is blocking this and why? If we need to render formulae in blue we can just do it, wait until the community freaks out and change it back to black again. Eventually this would result in completing the mission, but I would also try to avoid that at all costs.

Please let me know which option is acceptable.

Change 818294 had a related patch set uploaded (by AndreG-P; author: AndreG-P):

[mediawiki/extensions/Math@master] Enable popups for annotated math formulae

https://gerrit.wikimedia.org/r/818294

Change 818294 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Enable popups for annotated math formulae

https://gerrit.wikimedia.org/r/818294

@Physikerwelt - we're interested in testing this on the beta cluster prior to next week's train. Is there any way we can test this and do QA?

This could be related to the RESTBase sunset. CC @daniel

This could be related to the RESTBase sunset. CC @daniel

Nothing comes to mind, maybe @Jgiannelos or @hnowlan have an idea.

From restbase node:

mathoid_uri: http://deployment-docker-mathoid02.deployment-prep.eqiad.wmflabs:10044
curl "http://deployment-docker-mathoid02.deployment-prep.eqiad.wmflabs:10044"
curl: (6) Could not resolve host: deployment-docker-mathoid02.deployment-prep.eqiad.wmflabs

I think restbase on beta cluster has mathoid configured with legacy hostnames for CloudVPS.
The right URI is:

http://deployment-docker-mathoid02.deployment-prep.eqiad1.wikimedia.cloud:10044

Same think happened lately with wikifeeds so maybe there is some CloudVPS hostname deprecation happening lately?

Change 865578 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[operations/puppet@production] beta-cluster: Fix restbase mathoid URI

https://gerrit.wikimedia.org/r/865578

Change 865578 merged by Hnowlan:

[operations/puppet@production] beta-cluster: Fix restbase mathoid URI

https://gerrit.wikimedia.org/r/865578

@Physikerwelt - we're interested in testing this on the beta cluster prior to next week's train. Is there any way we can test this and do QA?

@ovasileva an example can be viewed in the beta cluster's article about the mass-energy equivalence: https://en.wikipedia.beta.wmflabs.org/wiki/Mass%E2%80%93energy_equivalence.
Hovering over the formula should reveal the new popup. Here is a screenshot:

BetaClusterScreenshot-09-12-2022.jpg (942×1 px, 77 KB)

Change 527547 abandoned by Jdlrobson:

[mediawiki/extensions/Popups@master] Add popup support for annotated math

Reason:

I don't think this is needed now as we have defined this in the Math extension. Please correct me if I'm wrong.

https://gerrit.wikimedia.org/r/527547