Discourse Blocks

AI-generated summary

jgujgu introduces the discourse-blocks plugin, a tool designed to render interactive data visualizations and HTML content from GitHub Gists directly within Discourse posts. The plugin functions similarly to Bl.ocks and Blockbuilder, requiring installation via Git and the configuration of GitHub API credentials in the app.yml file. While initially focused on data visualization, it supports any content that can be packaged as an HTML block. The announcement includes a live demo link and invites users to join the Graphme community. mitchellk and ChrisBeach praise the plugin’s potential but raise security concerns regarding the execution of arbitrary code by regular members. In response to sam’s suggestion to use a onebox instead, jgujgu acknowledges the idea for future implementation but explains the current focus was on proper iframe packaging. Addressing security fears, jgujgu clarifies that the plugin utilizes iframe sandboxing with only the allow-scripts attribute enabled, explicitly avoiding allow-same-origin to prevent users from accessing the parent page’s data, citing HTML5 security documentation to support this approach.

If you’d like to display interactive data visualizations in your Discourse’s posts, do I have the plugin for you. :dosequis:

###Introducing…
#[:chart_with_upwards_trend: discourse-blocks :chart_with_downwards_trend:] (https://graphme.io/t/how-does-life-expectancy-correlate-with-a-countrys-gdp-per-capita/204/3) :point_left: Live demo

To install, add this, as normal, to app.yml:

- git clone https://github.com/jgujgu/discourse-blocks.git

:exclamation: But also please add these under env by the other variables in app.yml. You can generate them if you have a Github account:

GITHUB_CLIENT_ID: "a_github_client_id"
GITHUB_SECRET_KEY: "a_longer_github_secret_key"

Visit Github for a full list of screenshots:
https://github.com/jgujgu/discourse-blocks

I am currently running 1.8+, but it worked just fine on ~1.6 as well.

What does this plugin really do? (since you didn’t click the live demo :yuno:)

If a poster inserts a link to a Github Gist with an index.html file, this plugin will render it and any code + files that run alongside it. Essentially, anything that bl.ocks made famous and blockbuilder makes convenient to create will render through this plugin. The bulk of examples are data visualizations, but a block need not be.

If you have a question or feedback, feel free to post it here or here.

Alongside this plugin, I would also like to invite you to join graphme, answers that show not tell
:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:page_facing_up::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:page_facing_up::chart_with_downwards_trend::chart_with_downwards_trend:|:chart_with_downwards_trend::chart_with_downwards_trend::chart_with_downwards_trend:
:chart_with_upwards_trend::page_facing_up::chart_with_upwards_trend:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:chart_with_upwards_trend::page_facing_up::chart_with_upwards_trend:|:chart_with_upwards_trend::page_facing_up::chart_with_upwards_trend:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:chart_with_downwards_trend::page_facing_up::page_facing_up:|:chart_with_downwards_trend::page_facing_up::page_facing_up:
:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:page_facing_up::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:page_facing_up::chart_with_downwards_trend::chart_with_downwards_trend:|:chart_with_downwards_trend::chart_with_downwards_trend::chart_with_downwards_trend:
:page_facing_up::page_facing_up::chart_with_upwards_trend:|:page_facing_up::page_facing_up::page_facing_up:|:page_facing_up::page_facing_up::page_facing_up:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:chart_with_upwards_trend::page_facing_up::chart_with_upwards_trend:|:chart_with_downwards_trend::page_facing_up::page_facing_up:|:chart_with_downwards_trend::page_facing_up::page_facing_up:
:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend:|:page_facing_up::page_facing_up::page_facing_up:|:page_facing_up::page_facing_up::page_facing_up:|:chart_with_upwards_trend::page_facing_up::page_facing_up:|:chart_with_upwards_trend::page_facing_up::chart_with_upwards_trend:|:page_facing_up::chart_with_downwards_trend::chart_with_downwards_trend:|:chart_with_downwards_trend::chart_with_downwards_trend::chart_with_downwards_trend:

This is (ahem will be) a Q&A site that welcomes interactive graphs, diagrams, and infographics as answers. If you have a potentially graphical question needling you in the back, please do ask it there. I’m sure it is interesting if it’s doing that.

15 likes

That is awesome, well done and thank you for contributing a great plugin.

2 likes

Wondering why not simply implement a onebox here?

4 likes

I’ll look into doing this at some point. With my current implementation, I was so focused on correctly packaging up the iframe (and nudging the user to do so) that I didn’t think about using Github’s oEmbed API.

I’ve just spotted this and it looks excellent.

Are there enough safeguards in place to allow regular members to use this feature? Allowing arbitrary code to run on my site is a pretty scary concept :grimacing:

From what I know, the different options in iframe sandboxing can safely prevent a user from accessing information on your site.

Whitelisting both allow-scripts and allow-same-origin is probably the most dangerous thing to do, as it allows running javascript and access to the parent page. However, I have allowed only allow-scripts in my iframes.

1 like