bootstrapworld / pyret-blocks

Block Language for the Pyret Programming Language
Apache License 2.0
3 stars 1 forks source link

dependencies Status devDependencies Status Code Climate

pyret-blocks

A screenreader-accessible, hybrid block and text editor for the Pyret programming language.

Usage

Export the pyret-blocks module using the normal npm run build mechanism, then include it in your favorite Pyret-using, CodeMirror-enabled project. You can now use the new CodeMirrorBlocks constructor to replace an existing CodeMirror instance with blocks. In other words, you'd replace code that looks like this:

// make a new CM instance inside the container elt, passing in CM ops
this.editor = CodeMirror(container, {/* CodeMirror options  */}});

With code that looks like this:

// make a new CMB instance inside the container elt, passing in CMB ops
this.editor = CodeMirrorBlocks(container, {/* CodeMirrorBlocks options  */});

NOTE: your IDE will need to load CodeMirror as an external dependency. We assume it already does (otherwise, why would you be here?), so you'll need to provide it yourself.

Development

To get your dev environment up and running, follow these steps. Note that to run tests, you will need either Chrome or Chromium and point the variable CHROME_BIN to the binary like this:

export CHROME_BIN=/usr/bin/chromium

You must enter the following command in every session before you run the test. Alternatively, you can put it in your .{bash,zsh}rc, which will run them automatically.

  1. Checkout the repository in your favorite manner

  2. install dependencies with npm

    npm install
  3. start the webpack development server:

    npm start
  4. browse to http://localhost:8080/ and fire away!

  5. while you work, be sure to run the unit tests (early and often!) with:

    npm run test

Language-specific code is in the src/languages/pyret/ directory. The files there include:

  1. you can generate local coverage reports in the .coverage/ folder by running:

    COVERAGE=true npm test
  2. you can generate a static, minified ball of JS and CSS in the dist/ folder by running:

    npm run build

Inserting New Themes

We have also given the option for you to add your own themes into the application during development. Style-specific code is in the src/languages/pyret/style-selection directory, where you will find:

Once you have your style compiled, all you need to insert a new style is to:

  1. Upload your file to the style directory mentioned above if you haven't already.

  2. Open up style-list.js, and insert a json of the following format:

    {
            displayName: STRING,
            themeName: STRING,
            id: STRING
    }
  1. In style.less referenced in Development, add the following to the less file:

    .[themeName]{
            @import "./style-selection/style/[file you uploaded]";
    }

TODO (Check off in commit when complete)