Custom Onebox engine

I am interested in developing a Onebox engine to neatly display/embed content from one of my own websites in a custom format - similar to the GitHub custom engines.

Assuming that I fork the Onebox repo on GitHub, and push all my custom code and changes, how would I then go about telling my Discourse instance to use my modified version of Onebox, rather than the official version?

The engine I am looking at developing is fairly custom, so I doubt that I will file a PR to include it back into the main codebase.

You don’t have to create custom onebox engine. You can achieve it by creating a plugin for Discourse.

For examples, You can check some other onebox plugins below

https://github.com/search?p=1&q=discourse+onebox&type=Repositories&utf8=✓

Search results for 'onebox category:22' - Discourse Meta

5 Likes

Thanks @vinothkannans . I was reading the Onebox GitHub README without even thinking it could be a plugin for Discourse. Much easier :slight_smile:

2 Likes

You might want to take a look at this plugin:

https://github.com/fefrei/discourse-pseuco-onebox/blob/master/plugin.rb

I did that to enable oneboxing of one of my own sites. It simply replaces the onebox with an iframe with a specific URL, where my website delivers a special embed-friendly view of the target site.

I pretty clueless when it comes to Ruby, so this may not be state of the art, but it might be enough to get you started :slight_smile:

(Remember to also test what happens in notification mails containing the post.)

6 Likes

Thanks @fefrei . Yes, I am also pretty clueless about Ruby…but slowly picking up how things work from reading a heap of sample code :slight_smile:

1 Like

In that case, my approach has the advantage of needing only a tiny bit of ruby code, while most of the logic is happening on your website (which is responsible for producing the embed-view) :slight_smile:

2 Likes

Awesome, thanks @fefrei :slight_smile: