Onebox and whitelist


(ABiS) #1

Hi there,

for my first attempt at hacking discourse I wanted to add a few websites relevant to my audience to the onebox whitelist (most seems to be Open graph compliant too) as explained in various older posts.

But it turns out that whitelist.rb is not where it used to be ( https://github.com/discourse/discourse/blob/master/lib/oneboxer/whitelist.rb ) and in fact it is nowhere to be found anymore :smile:

So I guess the way this works has changed considerably over the last few months. Any hints?

At one point I thought I had found the right place:

#{Rails.root}/lib/onebox/engine/*_onebox.rb"]

but there is only one file so that cannot be it

Thanks
Marco


(Régis Hanol) #2

The onebox now lives in its own gem: dysania/onebox.

@eviltrout has worked a lot on it recently but I don’t know if he added an easy way to override the whitelist.


(ABiS) #3

thanks, I had seen the gem but couldn’t quite work out whether it was used already or not.


(Claus Strasburger) #4

@radq summarized the onebox-plugin-interface nicely here:

basically, add a folder plugins/my-pluginname/plugin.rb
with this content:

# name: Some more whitelist entries
# version: 0.1
# authors: Me

Onebox::Engine::WhitelistedGenericOnebox.whitelist.push "someWebsite.net"

(Robin Ward) #5

There’s also going to be an admin UI for adding to it at some point.


(Geoff Bowers) #6

@eviltrout I can see the onebox whitelist in settings. I’ve added github.com and that appears to work just fine.

What is the default list of whitelisted domains that ships with Discourse now? For example, I notice that YouTube embeds are automatic, but then I’d assumed GitHub ones were too.

Many thanks.


(Robin Ward) #7

We already had some custom oneboxes for github (gists, commits) which should have worked out of the box. It’s possible you found a type of github link that we didn’t support, but the oembed/opengraph code path supported it.

The full list is available here:

(see! that oneboxed!)