Onebox not working

frc-docs is in the process of adding Open Graph support. When I tried the test site (link below), it did not generate a Onebox. Is there a setting to only enable Oneboxes on certain sites? It does work on other sites that support Open Graph.

https://frc-docs--711.org.readthedocs.build/en/711/docs/getting-started/getting-started-frc-control-system/intro.html

It has description set, which per below is the the only thing needed for Onebox to work.

1 Like

Looking at this: https://github.com/discourse/onebox/tree/master,
it appears that domains have to be whitelisted.

I think it needs to be added to whitelisted_generic_onebox.rb: https://github.com/discourse/onebox/blob/master/lib/onebox/engine/whitelisted_generic_onebox.rb.

It would suggest adding

  • docs.wpilib.org
  • frcdocs.wpi.edu
  • frc-docs.readthedocs.io

I’ve added these 3 … let me know if it works or needs updating.

6 Likes

Could you try adding wpilib.org?
And, could you add a second copy with https:// prepended? -> https://wpilib.org

Also,
I found discourse specific info: Quickly explain what Onebox is? - feature - Discourse Meta

edit:
Does it need https:// for all of the previous three urls too?
curl on http://docs.wpilib.org/en/latest/ is rejected but works on https://docs.wpilib.org/en/latest/.

Looking through the source code in the above posted github link, they seem to handle urls that need to change http to https differently

I added them in with https also, no dice. Not sure, without digging in further, why it’s not showing. Found some more discussion about it not working on every site, here:

I just got openbox with wpilib docs working on a local Discourse instance. Now I just have to figure out why and how.

Ok. I think I’ve cracked it.

First, testing woes:

Discourse caches onebox requests for 24 hours so trying the same url doesn’t work. So to test, urls have to be appended with garbage/unique query strings. (https://url.html?q=anger, https://url.html?q=entireminuteswasted, …)

The frc docs issue:

If the requested page contains a <link rel="canonical" ...>, then Onebox uses that and ignores the actual url that was passed in. The frc docs canonical points to the stable version of the docs; The opengraph data only exists in the latest version. So, onebox never sees the opengraph data.

Fixes

Fix 1

Once the opengraph version of frc docs makes its way from latest to stable, it should work.

Fix 2

Onebox ran into this same issue with instagram.

So, they have an override for this.

In the onebox gem’s lib/onebox/helpers.rb, IGNORE_CANONICAL_DOMAINS (line 8 ish) should change from:

 IGNORE_CANONICAL_DOMAINS ||= ['www.instagram.com']

to:

 IGNORE_CANONICAL_DOMAINS ||= ['www.instagram.com', 'wpilib.org']
1 Like

I’d like to avoid editing any of the core code (or libraries).

If you wanted to write a Discourse plugin to modify this behavior I would consider installing. (Or submit a pull request to onebox on github to add wpilib.org to their code)

3 Likes

I had started to work on the plugin but onebox looks for an undocumented html property that ignores the canonical url.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.