KinomaJS Blocks
October 15, 2016 ยท View on GitHub
KinomaJS Blocks is a visual code editor designed to help developers build starter projects for Kinoma Create and Kinoma Element.

The project is built on Angular 2(RC7) and runs in a web browser. The live version is hosted using Google App Engine. Instructions for building and modifying it are provided below.
Build Instructions
The npm command line tool is required, so make sure you have Node.js installed before you begin.
Starting on the Command Line
-
Navigate to the root
kinomajsblocksfolder. -
Install dependencies.
$ npm install -
Check to confirm that a
typingsfolder was created. If not, install it manually.$ npm run typings install -
Install Bower.
$ npm install -g bower -
Install Google Blockly.
$ bower install
Running Locally
-
Run the scripts task in
gulpfile.js. This will minify and bundle resources and output them totsbuild/distandtsbuild/lib.$ gulp scripts -
Start a local server and run the application.
$ npm start
Notes
The Typescript compiler monitors changes to app/ and outputs .js, and .js.map files to tsbuild/app/. However, changes will not be reflected in your instance until the scripts task in gulpfile.js is run again.
If you are running the app locally and want changes to be reflected immediately upon saving, follow the instructions in the comments of index.html. You simply need to comment out the minified files and uncomment the local library dependencies. Note that this will not work when deploying remotely on Google App Engine.
Running on Google App Engine
-
Download and install the Python SDK for App Engine.
-
Log into Google App Engine and create an application.
-
Make a local copy of the blockly library. You can do this using
gitfrom the command line, or by downloading a ZIP file by clicking Clone or Download->Download ZIP on the webpage, as shown in Figure 1.$ git clone https://github.com/google/blockly.gitFigure 1. Download ZIP

-
Copy the
appenginefolder from the blockly library and make it a standalone folder. -
Place the entire
kinomajsblocksproject folder inside the standaloneappenginefolder. -
Open
app.yamland make the following changes:-
Remove lines 1 and 2 (the ones that specify the
applicationname andversion). -
Replace the
handlerssection with the following:# Redirect for root directory. - url: / script: index_redirect.py secure: always # robot.txt - url: /robots\.txt static_files: robots.txt upload: robots\.txt secure: always # Storage API. - url: /storage script: storage.py secure: always # App Files - url: /kinomajsblocks static_dir: kinomajsblocks secure: always - url: /kinomajsblocks/media static_dir: /kinomajsblocks/media - url: /kinomajsblocks/modules static_dir: /kinomajsblocks/modules -
Add the following to the
skip_files:section:- ^(.*/)node_modules/(.*/)? - ^(.*/)bower_components/(.*/)? - ^(.*/)kinomajsblocks/app/(.*/)?
You may delete or add some others paths/file types, but these are the only necessary changes.
-
-
Open
index_redirect.pyand changeLocationin line 2 to/kinomajsblocks/index.html. -
Use the gcloud command line tool to deploy your application.
$ gcloud app deploy app.yaml index.yaml --project <YOUR-APP-ID-HERE>
###Notes
app/blocklycomponent/storage.service.ts is a custom implementation of the default storage.js (which adds cloud storage functionality) available for Blockly applications. This implementation makes the cloud storage more easily accessible to the KinomaJS Blocks application.