- Install the plugin according to this tutorial: https://meta.discourse.org/t/install-a-plugin/19157
- In admin settings, check that "code bytes enabled" is checked That's it!
- Click the "Create a Codebyte" button in the editor toolbar to insert a new, empty codebyte.
- The CodeByte editor will appear in the preview pane. Select the language you would like to use. This will automatically be saved to the markdown editor.
- You can type your code in the CodeByte editor itself. This allows you to execute your code as you go along, as well as take advantage of features such as autocomplete and syntax highlighting. The code will be auto-saved to markdown after a few seconds of inactivity. You can also click the "Save to post" button to manually save the contents of the CodeByte to markdown.
- If you prefer not to use the editor in the preview pane, you can use markdown directly to create a CodeByte using the [codebyte] tag.
- Add a
language
attribute to the opening tag, e.g. [codebyte language=python]. The currently supported options arecpp
(C++),csharp
,golang
,javascript
,php
,python
,ruby
. - Type your code in between the opening and closing tags.
- The opening and closing tags must each be be on their own line with no other text,
- First, set up a local Discourse development environment. See the guide here: https://meta.discourse.org/t/how-do-i-set-up-a-local-discourse-development-environment/182882
- Clone this repository:
git clone git@github.com:codecademy/discourse-codebytes-plugin.git
- Create a symlink between the CodeBytes plugin code and your Discourse plugin folder. From within your Discourse directory, run:
You will have to determine your
cd plugins ln -s <path to discourse-code-bytes-plugin>
<path to discourse-code-bytes-plugin>
. If your discourse-code-bytes-plugin directory is at your root, this will be~/discourse-codebytes-plugin
- Run Discourse. From within your Discourse directory, run:
You should now be able to run Discourse at http://localhost:3000/. Log-in with your admin account.
bundle exec rails server
- Create a new post. You should see the "Create a Codebyte" button in the editor toolbar.
Acceptance tests are run by qunit from the discourse root and are located in test/javascripts/acceptance
. Because discourse does not support unit testing for plugins, we have a separate suite of jest tests located in test/javascripts/unit
. In order for these tests to coexist the naming conventions are slightly different:
- for unit tests:
*.test.js
- for acceptance tests:
*-test.js
unit tests can be run via pnpm test
. The easiest way to run acceptance tests is to run the discourse server and go to http://localhost:3000/qunit?module=Acceptance%3A%20CodeBytes in your web browser