Best way to use Discourse for discussion of JSON data?


(Mike Shamblott) #1

I am new to Discourse and am planning to build a site that uses it to manage discussion of data. The data will be in JSON format served up through AJAX. I want some early advice on how to combine a dynamic HTML layout to display the data with Discourse. For example, imagine data in a spreadsheet. Below the sheet i’d like a discourse discussion of the data.

option 1
Paste discourse into an exisiting page

option 2
Modify discourse post HTML to grab and presents the data.

option 3
Use the wordpress plugin and do the layout by modifying wordpress. This seems pretty silly but I have used wordpress.

If the second option is preffered, what frameworks are best for display of JSON encoded information in a dynamically generated page. I dont use Ember but am happy to learn, and have used javascript + JQuery and PHP for other projects like this but lacking discourse. Iideally, I want to implement this as a discourse plugin, similar to the Google spreadsheet plugin but allows presentation of data in several formats such as image or video raw data linked to analyses in spreadheets and text.

Thanks in advance for takng the time to help a Discourse neophyte early in his development.


(Marcin Rataj) #2

Ok, so my understanding is that all you need is option 2: a custom onebox plugin which turns links to JSON data files from a specific domain/URLs into some kind of visualization inside of a cooked Discourse post.

For example link like this:

http://some-specific-host/api/stuff/data.json

with JSON data in WaveDrom format:

{ signal: [
  { name: "pclk", wave: 'p.......' },
  { name: "Pclk", wave: 'P.......' },
  { name: "nclk", wave: 'n.......' },
  { name: "Nclk", wave: 'N.......' },
  {},
  { name: 'clk0', wave: 'phnlPHNL' },
  { name: 'clk1', wave: 'xhlhLHl.' },
  { name: 'clk2', wave: 'hpHplnLn' },
  { name: 'clk3', wave: 'nhNhplPl' },
  { name: 'clk4', wave: 'xlh.L.Hx' },
]}

could get oneboxed/cooked into this:

WaveDrom is just an example, you could use different plotting library (quick search found Epoch, Chartist.js, but I am sure there is a lot more) or even create your own.

Sample discourse plugins you can look at (to understand the basic rules):


Hope this helps.


(Mike Shamblott) #3

This is very helpful. I’m beginning to see that Discourse code isn’t supposed to be hacked directly. Makes sense for upgradeability. Plugin with onebox seems like the best way to go.