[Bounty] - Discourse Plugin for Inserting Deck

The idea here is to add a button to the composer labeled “Insert Deck”. The user clicks this button and then has an input window where they can copy paste text inside a box. Then the user simply presses “ok” after inserting the text. Here is an example with the new button in composer toolbar:
image
image
After clicking the button:
image

The user input doesn’t matter. It’s just some base64 code which represents the contents of a deck of cards. You url encode that code and pass it through the api. For example, let’s use this code:

M+e6LjWfEYbv/L/MAMIXps0AY4kjoiww/PbQdlYYFuz7zgDDKmaXWGB4zsmPjCC8uMSeGYRfys5kheHgpcuZQXj3GXs4XnDhIQscP7oGx/ll7xlguPCSLrM1cx1L/+bXjKuufmK4K/mD4eN1Edbrk1ewTHtayryn/zTT0mXzGafd5WDwf/iGZesHRtZjxsnM7MfjWS02JrNocksxB33vYg4G4o3um8D4YcRcMAa5EeQmkJsB

The raw code after being url encoded:
M%2Be6LjWfEYbv%2FL%2FMAMIXps0AY4kjoiww%2FPbQdlYYFuz7zgDDKmaXWGB4zsmPjCC8uMSeGYRfys5kheHgpcuZQXj3GXs4XnDhIQscP7oGx%2Fll7xlguPCSLrM1cx1L%2F%2BbXjKuufmK4K%2FmD4eN1Edbrk1ewTHtayryn%2FzTT0mXzGafd5WDwf%2FiGZesHRtZjxsnM7MfjWS02JrNocksxB33vYg4G4o3um8D4YcRcMAa5EeQmkJsB

Then this is passed through the api with the imageify parameter if Image was selected via http://51.222.12.115:7000/imageify?list=code where code would be the above url encoded code like this:

http://51.222.12.115:7000/imageify?list=M%2Be6LjWfEYbv%2FL%2FMAMIXps0AY4kjoiww%2FPbQdlYYFuz7zgDDKmaXWGB4zsmPjCC8uMSeGYRfys5kheHgpcuZQXj3GXs4XnDhIQscP7oGx%2Fll7xlguPCSLrM1cx1L%2F%2BbXjKuufmK4K%2FmD4eN1Edbrk1ewTHtayryn%2FzTT0mXzGafd5WDwf%2FiGZesHRtZjxsnM7MfjWS02JrNocksxB33vYg4G4o3um8D4YcRcMAa5EeQmkJsB

You can open that above link in your browser and it should show an image. That image is basically what should be inserted into the post after pressing ok if Image was selected in the checkbox.

If List is also selected, then you can insert the list below the image. The url encoded code is again passed but this time through the convert parameter like this: http://51.222.12.115:7000/convert?pretty&to=names&list=code where code again is the url encoded code. You will get this now:

http://51.222.12.115:7000/convert?pretty&to=names&list=M%2Be6LjWfEYbv%2FL%2FMAMIXps0AY4kjoiww%2FPbQdlYYFuz7zgDDKmaXWGB4zsmPjCC8uMSeGYRfys5kheHgpcuZQXj3GXs4XnDhIQscP7oGx%2Fll7xlguPCSLrM1cx1L%2F%2BbXjKuufmK4K%2FmD4eN1Edbrk1ewTHtayryn%2FzTT0mXzGafd5WDwf%2FiGZesHRtZjxsnM7MfjWS02JrNocksxB33vYg4G4o3um8D4YcRcMAa5EeQmkJsB

If you put the above link in your browser, it will return a json response that looks like this:

Spoiler

"names": "3 Nibiru, the Primal Being\n2 Exodius the Ultimate Forbidden Lord\n2 The Winged Dragon of Ra - Sphere Mode\n3 Fire Hand\n3 Ice Hand\n3 Thunder Hand\n3 Ghostrick Jiangshi\n2 Nopenguin\n2 Ghostrick Yuki-onna\n3 Penguin Soldier\n2 Ghostrick Jackfrost\n3 Ghostrick Lantern\n3 Ghostrick Specter\n3 Recurring Nightmare\n3 Evenly Matched\n\n1 Ghostrick Angel of Mischief\n1 Ghostrick Alucard\n1 Ghostrick Socuteboss\n1 Mechquipped Angineer\n1 Number 49: Fortune Tune\n1 Super Quantal Mech Beast Grampulse\n1 Wind-Up Zenmaines\n1 Slacker Magician\n1 Ghostrick Dullahan\n1 Kikinagashi Fucho\n1 Daigusto Emeral\n1 Castel, the Skyblaster Musketeer\n1 Number 39: Utopia\n1 Number S39: Utopia the Lightning\n1 Number 35: Ravenous Tarantula\n\n\n1 Ghost Belle & Haunted Mansion\n1 Ghost Mourner & Moonlit Chill\n1 Ghost Ogre & Snow Rabbit\n1 Ghost Ogre & Snow Rabbit\n2 Ghost Reaper & Winter Cherries\n2 Ghost Sister & Spooky Dogwood\n1 Ghostrick Yuki-onna\n1 Ghostrick Jackfrost"

The \n here are line breaks. So in the composer it should just paste that list like so:

3 Nibiru, the Primal Being
2 Exodius the Ultimate Forbidden Lord

The “Paste YDK” is basically a button to copy paste the contents of a text file. YDK is simply a TXT. They click the button->they pick a text file from their explorer->the contents gets pasted in the window. Just another way of inserting the input instead of copy paste.

You don’t have to worry about the user input. Even if it’s invalid, the api will return invalid. The composer simply needs to paste whatever the api returns.

The challenge primarily here is learning how to receive user input from discourse and then pasting the output from the api. Documentation can be found here:

  1. A Simple Discourse Plugin - Get Started - SitePoint Forums | Web Development & Design Community
  2. Developing Discourse Plugins - Part 1 - Create a basic plugin - developers - Discourse Meta

I’ll likely work on this myself in the upcoming month if no one else wants to. Contact me if interested and we can negotiate the bounty.