New Plugin spec: Discourse Dictionary

@members @tobiaseigen
Continuing the discussion from Propose a new project!:

Here is a very primary stage code I had put together which should act as a motivation for working on this further.

Here is an initial spec for the plugin.

  • Wrap a word in composer with [dict]word[/dict]. The meanings of the word will be fetched via a dictionary API (oxford or other) and the user will be asked to select one of the meanings which suits the context of the word in the post preview.

  • The user will select a meaning and when the post is created, hovering on the word will show a small speech bubble with the word’s meaning that the user chose.

  • The plugin will store the meaning of the word which will act as a cache to reduce the number of api calls over time.

  • This is not the final spec. It will go through multiple revisions to finalize what the spec will look like.

What I suggest here is, as this is a fresh plugin, we should start writing tests and think about versioning from the get-go.


This is a very interesting idea. I’m trying to do the same thing for a plugin I want to create as well. I did run the idea by angus. Instead of words from a dictionary, there are card names from a card game. I also have a backend api that will send an image given the name. Upon hovering the card name, it pops up an image and it linkifies the card name to a url where it will display more info.

The backend api hence is all that is needed given the card name. I would put a button on the composer window that says “insert card” and it would show an input window where a user types a single card name or even multiple separated by line breaks. Then it would be inserted in the post with [card] name [/card]. Basically a bbcode.

This is an example.

I believe I can achieve this through html/css/js, so I don’t need ruby. Therefore, I will use a theme component rather than a plugin. I can either reverse engineer the md composer theme-component or the formatting toolbar plugin.

I hope I can find some help and advice here. I really like the Discourse community!

1 Like

I think you’ll need a plugin. If you consider a couple of users, every user using this feature would cause many many requests which isn’t ideal. A better way is to use the db as a cache for the data. If the data doesn’t change, that’s even better.

1 Like

Here’s an example. GitHub - paviliondev/discourse-linkify-google-sheets
This plugin fetches data from google sheets which can be used by our fork of the linkify theme component.

1 Like

Thanks @fzngagan

I did look at the linkify plugin before but you would need to hardcode each word or phrase to linkify. I already have a sql database with the card names.

I also was looking at this theme component which managed to create tooltips which is what I’m trying to do here: GitHub - udan11/discourse-units: Convert durations, lengths and other units automatically from posts

The user hovers over a unit and then they see something. I’m trying to hover over a word or phrase and show an image.

@fzngagan Is right that if you’re accessing any third party resource like a dictionary api, or any other api, this needs to be a plugin. If the data is hardocded in a static format like JSON or CSV that you can include in the customisation itself, then you could have a theme component.