Onebox (deprecated) gem question on allowed domains & settings

AI-generated summary

The discussion revolves around the deprecated onebox gem and understanding its configuration for allowing domains. fearlessfrog experimented with the gem, finding that it worked for certain URLs like meta.discourse.org but not for others like bonnieplants.com. They suspected there might be an AllowedDomainsList regex or configuration option to allow additional domains.

Later, fearlessfrog discovered that the old onebox gem can allow additional domains by adding them to the allowed_domains option on the Onebox::Engine::AllowlistedGenericOnebox engine before previewing the URL.

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