Hello World plugin

(Maestro Magnifico) #1

Can someone create one? :smile: Just “Hello World” on blank page as a legit Discourse plugin.

I don’t code Ruby and have no time to learn it now (have to learn Node.js at the moment). But I need to add one very easy Discourse plugin that will output some var as json. I could use “Hello World” plugin as a template if there was one.

(Kane York) #2

The problem with a single “example” plugin is that there’s so many different places to poke at, some of which require boilerplate and some that don’t. It sounds like you’re trying to add some endpoints?

(Maestro Magnifico) #3

I need to get user’s session so I could check if user loged in or not and check he’s privileges. The reason why I need this inside container because this script will be called outside of container.
Discourse here: forum.example.com
I need to access Discourse session from here: example.com

(mountain) #4

You might not need a plugin for this if you only want to retrieve a user’s session so they have priviledges to do things away from your Discourse instance.

Check out this post as it might help you.

(Maestro Magnifico) #5

How the hell do I ajax “/session/current” from root domain? Do I need to ajax “http://forum.example.com/session/current”? Where’s that “end point” where I can send request exactly?

P.S. Using client JS to check user priviledges is a terrible idea.

(mountain) #6

It sounds like you’re going to have to roll up your sleeves and create a few extra points in between.

@elberet gave an answer that requires work in researching an equilavent for NGINX. While it’s not pretty it appears to get the job done if it works for him.

As to the answer for this topic my suggestion is to check out all the plugins available on GitHub. My starred list has a very comprehensive view of what’s available. Some are simple to pick apart and learn plugin basics (which I have done).

(Maestro Magnifico) #7

That’s the main reason I want this as a Discourse plugin - it’s a legit way of doing this and I will not have to install anything extra into container, and then have problems with rebuilding. It’s sounds to me that it’s easier to do this from scratch, that’s why I need blank plugin. Will have to try to use one of existing ones for this…

(mountain) #8

I do that too. I tend to ‘Frankenstein’ existing plugins for my needs. Not only does it get the job I want done but I also learn more about the app’s underlying structures for future use. :smiley: