Developing with Discourse

Hello,

I am building an app that includes a full featured discussion board. Discourse has all the features required for the discussion board feature, so my plan is to use discourse as a starting point and to build features on top of it. I have followed guides to set up the official docker development environment locally and have added a couple features on top of it. I have also followed guides for the One Click Install of discourse on DigitalOcean. I am confused however, because in the process of deploying, I never connected the DigitalOcean instance to my repo. So my question is, how do connect my repo to the digital ocean instance so that I can begin deploying my new features?

I have read the following two links, but did not find an answer as I am not looking to just add plugins.

I have also read this topic, but the poster is using an unsupported setup.
https://meta.discourse.org/t/how-to-customize-your-own-discourse-and-deploy-it-to-production-on-ubuntu-for-beginners/23475

What is the official supported way to set up a discourse instance that I can push my own features to?

Thank you!

In your case you must learn about how to develop Discourse plugins.

Edit: Using plugins you can make whatever changes you need in Discourse. Everything is possible with it.

5 Likes

Unless you have a team of several full-time programmers to integrate upstream changes into Discourse, and you desire never, ever to get any help, whatsoever, here, what you want to do is “just add plugins.”

You should find those topics about plugin development and ask questions when you get stuck.

Or, if you want to run your own fork of Discourse. Good luck!

1 Like

Thanks guys. I have read through the guides for plugin development and I think that there is potential I can achieve my goals with plugin development. There are still a couple things that did not get answered from reading the guides, as the guides seems to focus more on adding UI elements and javascript.

  1. How can I extend the existing models to fit my needs?
  2. How can I add controller functions to add new features onto the discourse app?

It’s probably best to take a step back and ask how to solve your particular problem rather than assume that you know the solution.

I am pretty sure that extending models is covered in those documents. A good way to get started is to find a plugin that does something like what you want and use it as an example.

I am sorry if it came off as me assuming I know the solution, as the opposite is most definitely the case. I am just very confused at this point. Forgive me if I am missing something, I read all 6 parts the following link for “Beginner’s Guide to Creating Discourse Plugins” and I don’t see anything about extending models or adding controller functions. Maybe an example would help clarify things.

Ex: I want to add proximity search so users can optionally set a location and find/meet up with people nearby them. This can be done with the following gem (https://github.com/diogob/activerecord-postgres-earthdistance)

My typical approach.

  1. Add longitude and latitude attributes to the user model and migrate the db. (Lets assume all the users are seeded with a longitude and latitude)
  2. Install gem and follow the gem’s documentation for setup.
  3. Create a controller function that that takes three parameters (radius, longitude and latitude) and uses the parameters to query the postgres database (using the gem) and return users within the radius as json.
  4. Create a component in ember that allows users to enter in longitude, latitude and radius and then query the controller function created in step 3.
  5. Create a component that lists the results of the query in step 4.

From the guides I have read, I think I understand how to achieve steps 4 and 5, but not steps 1-3. The guides seem to be only dealing with javascript and not ruby code.

I hope this helps to clarify my questions. Thank you

While I cannot help you with the other questions (but I’m sure someone else can), I have a word of advice here: Never let the database scheme deviate from the one provided by Discourse, or you’ll be in pain as soon as Discourse updates start making updates to the scheme. :cloud_with_lightning_and_rain:

Instead, Discourse core has mechanisms for plugins to store data, for example the plugin_store_rows table: For each user, you could insert a row there, with a key containing their user id and value containing a JSON object with latitude and longitude, for example :slight_smile:

5 Likes

@drew0101 consider adopting and contributing to the Locations plugin instead of re-inventing the wheel :slight_smile:

2 Likes