mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
cleaned up merge
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,4 +5,3 @@ npm-debug.log
|
||||
.project
|
||||
*.pyc
|
||||
*.komodoproject
|
||||
node_modules
|
||||
@@ -1,29 +0,0 @@
|
||||
// This program is to be used with NodeJS run Blockly headless. It loads
|
||||
// Blockly XML from `input.xml` and outputs python code on `stdout`.
|
||||
|
||||
global.DOMParser = require('xmldom').DOMParser;
|
||||
|
||||
global.Blockly = require('./blockly_uncompressed.js');
|
||||
|
||||
require('./blocks_compressed.js');
|
||||
require('./python_compressed.js');
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
//the contents of './input.xml' are passed as the `data` parameter
|
||||
fs.readFile('./input.xml', function (err, data) {
|
||||
if (err) throw err;
|
||||
|
||||
var xmlText = data.toString(); //convert the data buffer to a string
|
||||
try {
|
||||
var xml = Blockly.Xml.textToDom(xmlText);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return;
|
||||
}
|
||||
// Create a headless workspace.
|
||||
var workspace = new Blockly.Workspace();
|
||||
Blockly.Xml.domToWorkspace(workspace, xml);
|
||||
var code = Blockly.Python.workspaceToCode(workspace);
|
||||
console.log(code);
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<block type="colour_picker" id="11" x="93" y="12">
|
||||
<field name="COLOUR">#ff0000</field>
|
||||
</block>
|
||||
</xml>
|
||||
@@ -1,16 +0,0 @@
|
||||
# Blockly Headless
|
||||
|
||||
Running Blockly headless is valuable to allow for server side code generation.
|
||||
|
||||
The NodeJS program `app.headless.js` loads Blockly XML from `input.xml` and outputs python code on `stdout`.
|
||||
|
||||
### Prerequisites
|
||||
Be sure to have these installed on your system:
|
||||
- NodeJS -- http://nodejs.org/
|
||||
- NPM -- (Bundled with NodeJS)
|
||||
- closure-library -- http://developers.google.com/blockly/hacking/closure
|
||||
|
||||
## Getting Started
|
||||
1. run `npm install` in the blockly root directory(in the same location as the package.json).
|
||||
2. run `./build.py` to update the compressed files, as `build.py` **has changed**.
|
||||
3. run `node app.headless.js`
|
||||
Reference in New Issue
Block a user