Onebox (deprecated) gem question on allowed domains & settings

I was playing with the old onebox gem here discourse/onebox: (DEPRECATED) A gem for turning URLs into website previews (github.com) (I see it is deprecated, just trying to understand it a bit more) and couldn’t see how to set up options for it. I think there is a cache: value to set but didn’t see anything else.

When I use it with this

url = 'https://meta.discourse.org/t/upgrading-v2-2-0-beta4-
forum-with-unknown-local-changes/310241'
Onebox.preview(url).to_s

…it works fine, gives a onebox. When I use it with an og site like this:

url = 'https://bonnieplants.com/blogs/garden-fundamentals/v
egetable-garden-care-tips'
Onebox.preview(url).to_s

…it doesn’t, e.g. returns empty.

The same links in Discourse onebox ok of course. I suspect there is some sort of AllowedDomainsList regex (?) that opens it up via config and was wondering how I could use that with this gem? Can I pass that option somehow, or use it as an engine some how? I am hunting around the specs but think I am missing it.

Appreciate any insights, even if this is a deprecated gem. Thanks! :heart:

I was being lazy, but stepping through the code the old onebox can allow this with using the allowed_domains on the generic onebox e.g.

Onebox::Engine::AllowlistedGenericOnebox.allowed_domains << hostname
preview = Onebox.preview(url, onebox_options).to_s
1 Like

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