Custom Onebox engine

AI-generated summary

skoota inquired about developing a custom Onebox engine to embed content from their own website, initially considering forking the official Onebox repository. vinothkannans advised against forking, suggesting instead that skoota create a Discourse plugin, providing links to existing examples. skoota appreciated this clarification, realizing a plugin was a simpler approach. fefrei shared their own plugin example which uses an iframe to serve an embed-friendly view from their website, noting it requires minimal Ruby code. fefrei also reminded skoota to test notification emails. skoota acknowledged their limited Ruby knowledge but expressed confidence in learning from sample code. fefrei highlighted that their approach is advantageous for those less familiar with Ruby, as most logic resides on the external website. skoota concluded by thanking fefrei for the helpful guidance.

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

Repository search results · GitHub

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

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

You might want to take a look at this plugin:

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.)

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:

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:

Awesome, thanks @fefrei :slight_smile: