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.
The npm command line tool is required, so make sure you have Node.js installed before you begin.
-
Navigate to the root
kinomajsblocks
folder. -
Install dependencies.
$ npm install
-
Check to confirm that a
typings
folder was created. If not, install it manually.$ npm run typings install
-
Install Bower.
$ npm install -g bower
-
Install Google Blockly.
$ bower install
-
Run the scripts task in
gulpfile.js
. This will minify and bundle resources and output them totsbuild/dist
andtsbuild/lib
.$ gulp scripts
-
Start a local server and run the application.
$ npm start
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.
-
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
git
from 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.git
Figure 1. Download ZIP
-
Copy the
appengine
folder from the blockly library and make it a standalone folder. -
Place the entire
kinomajsblocks
project folder inside the standaloneappengine
folder. -
Open
app.yaml
and make the following changes:-
Remove lines 1 and 2 (the ones that specify the
application
name andversion
). -
Replace the
handlers
section 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.py
and changeLocation
in 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.