Plugin development without a reference

For a week now I’ve tried to setup a custom route on my forum using a plugin. The route should be publicly accessible by anyone. I want the plugin to simply display HTML from a handlebar template at the specified route. I can’t get the template to render.

I’ve researched how to develop plugins for Discourse and can’t find any substantial documentation. Anytime someone ask a question About developing plugins the response is a link to a “guide” on developing an admin plugin that shows a purple tentacle. Anytime there’s a question about a template not showing we are simply referred to embers documentation on routers.

That guide is ok but there’s magic happening in the background that’s not explained so that we can take the information and run with it. What if we want to display a public route? How is the plugin.rb file consumed by discourse? What other discourse specific code/statements can I use in the plugin.rb file like “add_admin_route” to add routes to my application? Is there a certain file structure we have to use so the routes resolve?

Basically, all the developers building complex plugins, where are they looking at documentation to do so? I’m an experienced developer and simply adding a public route to my forum and rendering a template at that route is complicated given the current available guides/info on building plugins.

Any help is appreciated. Thanks! :heart:

1 Like

Michael the answer is: look at prior art as documentation can quickly get out of date and tends to only skim the surface. In contrast, popular plugins are often kept very up to date and cover more complex use cases.

Using existing repos to understand approaches is absolutely what I and my colleagues have learnt to do over the last few years.

I can recommend looking at those of core Discourse team (official), those of Pavilion (pavilion) and my repos for examples of how to do stuff (in that order! :sweat_smile: ).

As the platform evolves with newer versions of dependencies and new capabilities, official plugins leveraging the new technologies added to the platform, for example, can be really useful as starting points.

Look for a plugin that functionally does something similar to what you achieve and copy the approach.

Here’s an example of a plugin adding one route:

2 Likes