Beginner's Guide to Creating Discourse Plugins - Part 1

plugins

(Sudaraka Jayathilaka) #87

Hi,

Is this url correct? Shouldn’t this be ,

I’m new here. please correct me if im wrong :slight_smile:


(Vinoth Kannan) #88

In Discourse, mainly there are two big JavaScript sections “discourse” and “admin”. Also you can see few more in discourse/app/assets/javascripts at master · discourse/discourse · GitHub.

In plugins, to differentiate admin & normal user section JavaScript files we use “discourse” and “admin” keywords in between like below

plugins/basic-plugin/assets/javascripts/discourse/initializers/alert.js.es6
plugins/basic-plugin/assets/javascripts/admin/initializers/alert.js.es6


Also it will just work even without identification keywords like you mentioned :slight_smile:


(Sudaraka Jayathilaka) #89

@vinothkannans Thank you a lot for the explanation. :slight_smile:


(kaja santro) #90

our JS doesn’t seem to work, although we followed every step precisely. We neither have a modal popping from our basic-plugin nor any console.log visible when we pass one :cry:

ideas anyone?


(David Taylor) #91

Difficult to help without being able to see what you’ve got so far. Can you post a link to a github repo showing what you’ve got?


(kaja santro) #92

We found the mistake! Before restarting the rails server, we deleted the temporary files first with $ rm -rf tmp and suddenly it worked.


(Robin Ward) #93

Good to know! I’ve added a reminder piece of text after asking people to restart the server to see the “My changes weren’t picked up” heading if things aren’t working. Hopefully that will help future people avoid getting stuck.


(Clay Heaton) #94

I was having trouble with Discourse seeing the plugin when I used a symlink (on MacOS High Sierra). I deleted the symlink and moved the plugin folder into the Discourse hierarchy and everything worked as expected. Maybe this will help others who run into a similar issue.


(Robin Ward) #95

It should work in High Sierra with a symlink (I use High Sierra at home). I’m not sure why you needed to do the above!


(Clay Heaton) #96

I’m not sure what the issue was. I double-checked the permissions for access and execution of the folder & all looked good when I examined permissions from within the VM. I deleted the tmp directory multiple times but nothing worked until I moved the plugin folder into the discourse directory.


(Sam Saffron) #97

On Linux when I do this the file watcher does not work so bin/rake autospec is less useful. Not sure if kqueue is better here and still notifies.


(Cheng Zheng) #99

It work! 2018-4-28.:grin:

at first it doesn’t work(the alert box don’t come out),
I just delete entire tmp/ folder as some comment suggest.
and then it work perfectly!

1. Code

2. Result


it pop up every time I refresh the page

Thanks!