Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review for Fritz #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,33 @@ Please refer to the [./doc](./doc) for features, architecture, contributing, etc

## Quick Start

Install:

$ npm install
Run:

$ npm start
###Install:

cd puddle-server
npm install
cd ..
cd puddle-editor
npm install

###Run:
Two terminal windows:

One:

cd puddle-server
npm run develop # Ctrl-C to stop

Two:

cd puddle-editor
npm run develop # Ctrl-C to stop

Then navigate to <http://localhost:34934/>

## Develop mode:

$ npm run develop-editor # Ctrl-C to stop

In another terminal
## Deploy mode:

Same as above but you can use `npm start` istead of `npm run develop`

$ npm run develop-server # Ctrl-C to stop



Expand Down
173 changes: 63 additions & 110 deletions doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
* [Server socket.io API](#server-socketio)
* [Client `TODO.js`](#todojs)
* [Client `assert.js`](#assertjs)
* [Client `log.js`](#logjs)
* [Client `keycode.js`](#keycodejs)
* [Client `test.js`](#testjs)
* [Client `trace.js`](#tracejs)
* [Client `corpus.js`](#corpusjs)
* [Client `navigate.js`](#navigatejs)
* [Client `forest.js`](#forestjs)
* [Client `cursor.js`](#cursorjs)
* [Client `view.js`](#viewjs)
* [Client `menu.js`](#menujs)
* [Client `editor.js`](#editorjs)
* [Client `main.js`](#mainjs)
* [Client `menu-builder.js`](#menubuilder)
* [Client `menu-renderer.js`](#menurenderer)

Related documentation:

* [puddle-syntax](https://github.com/fritzo/puddle-syntax)
* [pomagma client](https://github.com/fritzo/pomagma/blob/master/doc/client.md)
* [puddle-syntax](https://github.com/pomagma/puddle-syntax)
* [pomagma client](https://github.com/pomagma/blob/master/doc/client.md)

## Server

Expand Down Expand Up @@ -131,118 +129,73 @@ Related documentation:
var assert = require('./assert');
assert(condition, message);
assert.equal(actual, expected);
assert.forward(fwd, listOfPairs); // fwd(x) === y for each pair [x, y]
assert.backward(bwd, listOfPairs); // x === bwd(y) for each pair [x, y]
assert.inverses(fwd, bwd, listOfPairs); // fwd(x) === y && x === bwd(y)

### `log.js` <a name="logjs"/>
### `trace.js` <a name="tracejs"/>

var log = require('./log');
log('just like console.log, bug works in web workers');
Convenience method for debugging.
Allows to quikly show trace and arguments passed into function.

### `keycode.js` <a name="keycodejs"/>

Just a static dictionary of ascii key codes.

{
'backspace': 8,
'tab': 9,
'enter': 13,
'shift': 16,
...
}

### `test.js` <a name="testjs"/>

Unit testing library.

var test = require('./test');

test('test title', callback); // declares synchronous test
test.async('test title', callback); // declares async test
test.runAll(); // run all unit tests

console.log(test.testing()); // prints whether tests are being run
console.log(test.hasRun()); // prints whether tests have finished
console.log(test.testCount()); // prints cumulative test count
console.log(test.failCount()); // prints cumulative failed test count

Utilities for performing functions on trees.

var root = arborist.getRoot(indexed);
var varList = arborist.getBoundAbove(term); // -> ['a', 'b']
var varSet = arborist.getVars(term); // -> {'a': null, 'b': null}
var name = arborist.getFresh(term); // -> 'c'
var debug = require('debug')('puddle:editor');
var trace = require('./trace')(debug);

//Will output to console 'puddle:editor Hello'
//arguments converted to array.
//if third parameter is true will do console.trace() as well.
//Second and third arguments are optional
trace('Hello', arguments, true)


### `corpus.js` <a name="corpusjs"/>

Uses puddle-socket to fetch data from server
Stores corpus as `lines` internally
Provides knowledge of defenitions/occurrences
Fetches validities, emits 'updateValidity' event.
Exposes CRUD API and emits CRUD events for corpus lines.
Handles checkin/checkout of lines (w/o real blocking on server yet)
Does not care about any other modules.


### `forest.js` <a name="forestjs"/>

Stores corpus as trees internally
Keeps trees sorted
Listens for CRUD events from Corpus and reemits them as trees


### `cursor.js` <a name="cursorjs"/>

Stores/shares pointer to node in a Forest.
Does not affect nodes in any way.
Exposes various methods to move itself between nodes of Forest
Notifies corpus of check-ins, check-outs
Exposes .replaceBelow to alter trees.
Listens to Forest changes to avoid being in orphan nodes.
Emits `move` event.

Editor's view of the server-side corpus.
Each client stores an in-memory copy.

var corpus = require('./corpus');
corpus.ready(cb); // calls cb after client loads corpus from server
corpus.validate(); // validates corpus, throws AssertError if invalid
var line = corpus.findLine(id);
var lines = corpus.findAllLines();
var names = corpus.findAllNames();
var id = corpus.findDefinition(name);
if (corpus.canDefine(name)) {
// we can create a new definition of name
}
var ids = corpus.findOccurrences(name);
if (corpus.hasOccurrences(name)) {
// we cannot delete the definition of name
}
corpus.insert(line, done, fail);
corpus.update(newLine);
corpus.remove(id);

### `navigate.js` <a name="navigatejs"/>

var navigate = require('./navagate');
navigate.on(name, callback, description); // add callback
navigate.off(); // clear callbacks
navigate.trigger(event);

// search for global variable
navigate.search(rankedStrings, acceptMatch, cancel, renderString);

// create new global variable name
navigate.choose(isValidFilter, acceptName, cancel);

### `view.js` <a name="viewjs"/>

The view object is the pane on the left showing the corpus.

var view = require('./view');
view.init({
getLine: ...,
getValidity: ...,
lines: ...
});

view.insertAfter(prevId, id);
view.update(id);
view.remove(id);

### `menu.js` <a name="menujs"/>

The menu object is the pane on the right.
It rebuilds itself at every action.
The menu is the sole form of input to puddle, by design.
The view object is the pane on the left showing the corpus.
Renders corpus using trees from Forest
Listens for forest CRUD events.
Listens for cursor moves.
Listens for validities update.
Uses DOM as internal state.
Does not have API

var menu = require('./menu');
menu.init({
actions = {...}, // callbacks bound to actions
getCursor = function () {...} // returns cursor
});

### `editor.js` <a name="editorjs"/>
### `menu-builder.js` <a name="menubuilder"/>

Aware of cursor position in a forest
Knows mapping of keys <=> UI actions
Builds UI action functions using Forest and Cursor API and module.exports them
Logs every user action to server via socket.io
Does not have internal state.

var editor = require('./editor');
editor.main(); // start puddle editor

### `main.js` <a name="mainjs"/>
### `menu-renderer.js` <a name="menurenderer"/>

Main entry point, either starts unit tests or starts editor,
depending on whether `location.hash === '#test'`.
Takes array of actions/keys from menu-builder and renders it into HTML with onKeyPress events.
Listens for Cursor 'move' event to rerender menu.
Does not have internal state or API
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"description": "A responsive editor built on Pomagma",
"main": "",
"scripts": {
"test": "cd $MODULE; npm install; npm test;",
"start": "cd puddle-server; npm start",
"develop-server": "cd puddle-server; DEBUG='puddle:*' npm run develop",
"develop-editor": "cd puddle-editor; npm run develop"
"test": "cd $MODULE; npm install; npm test;"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion puddle-editor/.jshintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
coverage
build
source/lib/puddle-syntax-0.1.2/node_modules
source/lib
2 changes: 1 addition & 1 deletion puddle-editor/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gulp.task('copyHtml', function () {
});

gulp.task('browserify', function () {
return gulp.src('./source/app.js')
return gulp.src('./source/app/main.js')
.pipe(browserify({
exclude: ['mocha'],
debug: true
Expand Down
4 changes: 2 additions & 2 deletions puddle-editor/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ HTML app to be served by puddle-server

###Features:

[ ] Working version of editor, navigator using same render as before
[ ] Built on top of puddle-hub
[X] Working version of editor, navigator using same render as before
[X] Built on top of puddle-hub


###Installation:
Expand Down
7 changes: 0 additions & 7 deletions puddle-editor/source/app.js

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading