From eb116f339a3a5a95ebd8990b55a0eb839f008b34 Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 14:21:29 +0400 Subject: [PATCH 01/20] Angular scaffolding. --- .gitignore | 6 +-- {clientSrc => clientSrc-old}/corpus.js | 0 {clientSrc => clientSrc-old}/editor.js | 0 {clientSrc => clientSrc-old}/keycode.js | 0 {clientSrc => clientSrc-old}/log.js | 0 {clientSrc => clientSrc-old}/main.js | 0 {clientSrc => clientSrc-old}/main.less | 0 {clientSrc => clientSrc-old}/menu.js | 0 {clientSrc => clientSrc-old}/navigate.js | 0 {clientSrc => clientSrc-old}/render-term.js | 0 .../render-validity.js | 0 {clientSrc => clientSrc-old}/view.js | 0 clientSrc/TODO.js | 16 -------- clientSrc/app/app.js | 39 +++++++++++++++++++ clientSrc/assert.js | 30 -------------- clientSrc/index.html | 38 +++++++++++++++--- clientSrc/styles/style.less | 0 gulpfile.js | 15 ++++--- package.json | 5 ++- 19 files changed, 88 insertions(+), 61 deletions(-) rename {clientSrc => clientSrc-old}/corpus.js (100%) rename {clientSrc => clientSrc-old}/editor.js (100%) rename {clientSrc => clientSrc-old}/keycode.js (100%) rename {clientSrc => clientSrc-old}/log.js (100%) rename {clientSrc => clientSrc-old}/main.js (100%) rename {clientSrc => clientSrc-old}/main.less (100%) rename {clientSrc => clientSrc-old}/menu.js (100%) rename {clientSrc => clientSrc-old}/navigate.js (100%) rename {clientSrc => clientSrc-old}/render-term.js (100%) rename {clientSrc => clientSrc-old}/render-validity.js (100%) rename {clientSrc => clientSrc-old}/view.js (100%) delete mode 100644 clientSrc/TODO.js create mode 100644 clientSrc/app/app.js delete mode 100644 clientSrc/assert.js create mode 100644 clientSrc/styles/style.less diff --git a/.gitignore b/.gitignore index 9d80f26..13ccd15 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,6 @@ results npm-debug.log node_modules public/index.html -public/main.css -public/main.css.map -public/main.js \ No newline at end of file +public/style.css +public/style.css.map +public/script.js \ No newline at end of file diff --git a/clientSrc/corpus.js b/clientSrc-old/corpus.js similarity index 100% rename from clientSrc/corpus.js rename to clientSrc-old/corpus.js diff --git a/clientSrc/editor.js b/clientSrc-old/editor.js similarity index 100% rename from clientSrc/editor.js rename to clientSrc-old/editor.js diff --git a/clientSrc/keycode.js b/clientSrc-old/keycode.js similarity index 100% rename from clientSrc/keycode.js rename to clientSrc-old/keycode.js diff --git a/clientSrc/log.js b/clientSrc-old/log.js similarity index 100% rename from clientSrc/log.js rename to clientSrc-old/log.js diff --git a/clientSrc/main.js b/clientSrc-old/main.js similarity index 100% rename from clientSrc/main.js rename to clientSrc-old/main.js diff --git a/clientSrc/main.less b/clientSrc-old/main.less similarity index 100% rename from clientSrc/main.less rename to clientSrc-old/main.less diff --git a/clientSrc/menu.js b/clientSrc-old/menu.js similarity index 100% rename from clientSrc/menu.js rename to clientSrc-old/menu.js diff --git a/clientSrc/navigate.js b/clientSrc-old/navigate.js similarity index 100% rename from clientSrc/navigate.js rename to clientSrc-old/navigate.js diff --git a/clientSrc/render-term.js b/clientSrc-old/render-term.js similarity index 100% rename from clientSrc/render-term.js rename to clientSrc-old/render-term.js diff --git a/clientSrc/render-validity.js b/clientSrc-old/render-validity.js similarity index 100% rename from clientSrc/render-validity.js rename to clientSrc-old/render-validity.js diff --git a/clientSrc/view.js b/clientSrc-old/view.js similarity index 100% rename from clientSrc/view.js rename to clientSrc-old/view.js diff --git a/clientSrc/TODO.js b/clientSrc/TODO.js deleted file mode 100644 index 6ace329..0000000 --- a/clientSrc/TODO.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -/** @constructor */ -var TodoException = function (message) { - this.message = message || '(unfinished code)'; -}; - -TodoException.prototype.toString = function () { - return 'TODO: ' + this.message; -}; - -var TODO = function (message) { - throw new TodoException(message); -}; - -module.exports = TODO; diff --git a/clientSrc/app/app.js b/clientSrc/app/app.js new file mode 100644 index 0000000..ed406b7 --- /dev/null +++ b/clientSrc/app/app.js @@ -0,0 +1,39 @@ +'use strict'; + +var log = console.log.bind(console); +var angular = require('angular'); +var uiRouter = require('angular-ui-router'); +var puddle = angular.module('puddle', [uiRouter]); + + +puddle.config(function ($stateProvider, $urlRouterProvider) { + // + // For any unmatched url, redirect to /state1 + $urlRouterProvider.otherwise('/puddle'); + // + // Now set up the states + $stateProvider + .state('puddle', { + url: '/puddle', + templateUrl: 'puddle.html' + }) + .state('puddle.list', { + url: '/list', + templateUrl: 'puddle.list.html', + controller: function ($scope) { + $scope.items = ['A', 'List', 'Of', 'Items']; + } + }) + .state('d3', { + url: '/d3', + templateUrl: 'd3.html' + }) + .state('d3.list', { + url: '/list', + templateUrl: 'd3.list.html', + controller: function ($scope) { + $scope.things = ['A', 'Set', 'Of', 'Things']; + } + }); +}); +log('Puddle init complete.'); \ No newline at end of file diff --git a/clientSrc/assert.js b/clientSrc/assert.js deleted file mode 100644 index 7f84896..0000000 --- a/clientSrc/assert.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -var _ = require('underscore'); - -/** @constructor */ -var AssertException = function (message) { - this.message = message || '(unspecified)'; -}; - -AssertException.prototype.toString = function () { - return 'Assertion Failed: ' + this.message; -}; - -var assert = function (condition, message) { - if (!condition) { - throw new AssertException(message); - } -}; - -assert.Exception = AssertException; - -// This is better than node's builtin assert comparison -assert.equal = function (actual, expected, message) { - assert(_.isEqual(actual, expected), - (message || '') + - '\n actual = ' + JSON.stringify(actual) + - '\n expected = ' + JSON.stringify(expected)); -}; - -module.exports = assert; diff --git a/clientSrc/index.html b/clientSrc/index.html index b0207e6..c3b94ea 100755 --- a/clientSrc/index.html +++ b/clientSrc/index.html @@ -1,14 +1,42 @@ - + + Pomagma Editor - - + + + + + + -
- + +Puddle editor +D3 view + +
diff --git a/clientSrc/styles/style.less b/clientSrc/styles/style.less new file mode 100644 index 0000000..e69de29 diff --git a/gulpfile.js b/gulpfile.js index 77c5bc5..8092b54 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,6 +11,7 @@ var nodemon = require('gulp-nodemon'); var less = require('gulp-less-sourcemap'); var exec = require('child_process').exec; var LIVERELOAD_PORT = 34939; +var rename = require('gulp-rename'); var lr = require('tiny-lr')(); var watcher = function (tasks, paths) { @@ -45,7 +46,7 @@ gulp.task('mocha', function (cb) { gulp.task('less', function () { //process LESS -> CSS - return gulp.src('./clientSrc/main.less') + return gulp.src('./clientSrc/styles/style.less') .pipe(less()) .pipe(gulp.dest('./public')); }); @@ -58,13 +59,13 @@ gulp.task('copyHtml', function () { gulp.task('browserify', function () { //Browserify - return gulp.src('./clientSrc/main.js') + return gulp.src('./clientSrc/app/app.js') .pipe(browserify({ - insertGlobals: true, exclude: ['mocha'], debug: argv.dev })) .pipe(gulpif(!argv.dev, uglify())) + .pipe(rename('script.js')) .pipe(gulp.dest('./public')); }); @@ -109,10 +110,14 @@ gulp.task('nodemon', function () { gulp.task('trackLiveReload', ['default'], function () { lr.changed({body: { - files: ['main.js', 'index.html', 'main.css'] + files: ['static/script.js', 'static/index.html', 'static/style.css'] }}); }); gulp.task('serve', ['startLiveReload', 'default', 'nodemon'], function () { - watcher(['trackLiveReload'], ['./clientSrc/**/*'])(); + watcher(['trackLiveReload'], [ + './clientSrc/**/*.js', + './clientSrc/**/*.html', + './clientSrc/**/*.less' + ])(); }); diff --git a/package.json b/package.json index c5437a5..3513a85 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "A responsive editor built on Pomagma", "main": "server.js", "dependencies": { - "amdefine": "=0.1.0", + "angular": "^1.2.21", + "angular-ui-router": "^0.2.10", "body-parser": "^1.6.1", "debug": "^1.0.4", "express": "^4.8.3", @@ -15,7 +16,6 @@ "gulp-less-sourcemap": "^1.3.3", "gulp-nodemon": "^1.0.4", "gulp-uglify": "^0.3.1", - "jquery": "^2.1.1", "less": "^1.7.4", "mongoose": "~3.8.15", "pomagma": ">=0.1.8", @@ -28,6 +28,7 @@ "devDependencies": { "connect-livereload": "^0.4.0", "gulp-mocha": "^1.0.0", + "gulp-rename": "^1.2.0", "gulp-util": "^3.0.0", "jshint": "^2.5.4", "karma": "^0.12.22", From 40ac7b7cd206cb647d910b494cfd263a5ff0fe55 Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 14:23:28 +0400 Subject: [PATCH 02/20] Style --- clientSrc/index.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clientSrc/index.html b/clientSrc/index.html index c3b94ea..96426f0 100755 --- a/clientSrc/index.html +++ b/clientSrc/index.html @@ -7,30 +7,35 @@ + + + + + From d9f666b31b378fc2572410a01cd0bfde30ada742 Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 15:12:33 +0400 Subject: [PATCH 03/20] Corpus module scaffolding. --- clientSrc/app/app.js | 36 +++++++----------------------------- clientSrc/app/corpus.js | 18 ++++++++++++++++++ clientSrc/index.html | 33 +++------------------------------ 3 files changed, 28 insertions(+), 59 deletions(-) create mode 100644 clientSrc/app/corpus.js diff --git a/clientSrc/app/app.js b/clientSrc/app/app.js index ed406b7..47d45d0 100644 --- a/clientSrc/app/app.js +++ b/clientSrc/app/app.js @@ -3,37 +3,15 @@ var log = console.log.bind(console); var angular = require('angular'); var uiRouter = require('angular-ui-router'); -var puddle = angular.module('puddle', [uiRouter]); +require('./corpus.js'); +var puddle = angular.module('puddle', [uiRouter, 'corpus']); + puddle.config(function ($stateProvider, $urlRouterProvider) { - // - // For any unmatched url, redirect to /state1 - $urlRouterProvider.otherwise('/puddle'); - // - // Now set up the states - $stateProvider - .state('puddle', { - url: '/puddle', - templateUrl: 'puddle.html' - }) - .state('puddle.list', { - url: '/list', - templateUrl: 'puddle.list.html', - controller: function ($scope) { - $scope.items = ['A', 'List', 'Of', 'Items']; - } - }) - .state('d3', { - url: '/d3', - templateUrl: 'd3.html' - }) - .state('d3.list', { - url: '/list', - templateUrl: 'd3.list.html', - controller: function ($scope) { - $scope.things = ['A', 'Set', 'Of', 'Things']; - } - }); + // For any unmatched url, redirect to corpus + $urlRouterProvider.otherwise('/corpus'); }); + + log('Puddle init complete.'); \ No newline at end of file diff --git a/clientSrc/app/corpus.js b/clientSrc/app/corpus.js new file mode 100644 index 0000000..d97dee9 --- /dev/null +++ b/clientSrc/app/corpus.js @@ -0,0 +1,18 @@ +'use strict'; +var angular = require('angular'); +var uiRouter = require('angular-ui-router'); +var corpus = angular.module('corpus', [uiRouter]); + +corpus.config(function ($stateProvider) { + $stateProvider + .state('corpus', { + url: '/corpus', + templateUrl: 'corpus.html', + controller: 'corpus' + }); +}); + +corpus.controller('corpus', function ($scope) { + $scope.corpus =['1','2']; +}); + diff --git a/clientSrc/index.html b/clientSrc/index.html index 96426f0..9f1a6c1 100755 --- a/clientSrc/index.html +++ b/clientSrc/index.html @@ -1,47 +1,20 @@ - Pomagma Editor - - - - - - - -Puddle editor -D3 view - +Corpus editor
From aa6bb5a6f7a9b39c42d67c18924079cfabe4801b Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 15:50:25 +0400 Subject: [PATCH 04/20] Corpus factory --- clientSrc/app/corpus.js | 48 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/clientSrc/app/corpus.js b/clientSrc/app/corpus.js index d97dee9..331985d 100644 --- a/clientSrc/app/corpus.js +++ b/clientSrc/app/corpus.js @@ -1,7 +1,10 @@ 'use strict'; + +var log = console.log.bind(console); var angular = require('angular'); var uiRouter = require('angular-ui-router'); var corpus = angular.module('corpus', [uiRouter]); +var syntax = require('puddle-syntax'); corpus.config(function ($stateProvider) { $stateProvider @@ -12,7 +15,48 @@ corpus.config(function ($stateProvider) { }); }); -corpus.controller('corpus', function ($scope) { - $scope.corpus =['1','2']; +corpus.controller('corpus', function ($scope, CorpusDB) { + $scope.corpus = CorpusDB.corpus; +}); + +corpus.factory('CorpusDB', function () { + var codes = [ + 'ASSERT EQUAL APP APP C APP APP C VAR util.pair BOT VAR util.join I', + 'ASSERT EQUAL APP APP C APP VAR util.pair BOT VAR util.join I', + 'ASSERT EQUAL APP VAR types.div BOT BOT', + 'ASSERT EQUAL APP VAR types.div TOP TOP', + 'ASSERT EQUAL APP VAR types.semi BOT BOT', + 'ASSERT EQUAL APP VAR types.semi I I', + 'ASSERT EQUAL APP VAR types.semi TOP TOP', + 'ASSERT EQUAL APP VAR types.type I I', + 'ASSERT EQUAL APP VAR types.type TOP TOP', + 'ASSERT EQUAL APP VAR types.unit I I', + 'ASSERT EQUAL APP VAR types.unit TOP TOP', + 'ASSERT EQUAL COMP VAR types.forall.lower VAR types.forall.raise I', + 'ASSERT EQUAL COMP VAR types.forall.pull VAR types.forall.push I', + 'ASSERT EQUAL COMP VAR types.type VAR types.type VAR types.type', + 'ASSERT EQUAL VAR types.div APP VAR types.type APP CI TOP', + 'DEFINE VAR types.div APP VAR types.type K', + 'DEFINE VAR types.exp COMP COMP COMP COMP APP CB VAR ' + + 'types.type APP CB B CB CB VAR types.type', + 'DEFINE VAR types.forall JOIN APP APP VAR util.pair VAR ' + + 'types.forall.lower VAR types.forall.raise JOIN APP APP VAR ' + + 'util.pair VAR types.forall.pull VAR types.forall.push HOLE', + 'DEFINE VAR types.forall.lower APP APP C I TOP', + 'DEFINE VAR types.forall.pull COMP APP CB VAR types.div J', + 'DEFINE VAR types.forall.push APP APP C I TOP', + 'DEFINE VAR types.forall.raise K', + 'DEFINE VAR types.pow P', + 'DEFINE VAR types.semi APP VAR types.type APP VAR types.forall ' + + 'COMP APP CB B COMP CB COMP APP CB I CB', + 'DEFINE VAR types.type V', + 'DEFINE VAR types.unit APP VAR types.type JOIN APP K I VAR types.semi', + 'DEFINE VAR util.join J', + 'DEFINE VAR util.pair COMP C APP C I' + ]; + log('Compiler load:',syntax.compiler.load(codes[1])); + log('Compiler load:',syntax.compiler.load(codes[1])); + return {corpus: strings}; + }); From 2aa45a04c872d81732c7a8d1811a3b6f49d9462e Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 15:54:42 +0400 Subject: [PATCH 05/20] Lint fix --- clientSrc/app/corpus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clientSrc/app/corpus.js b/clientSrc/app/corpus.js index 331985d..8fe4ff8 100644 --- a/clientSrc/app/corpus.js +++ b/clientSrc/app/corpus.js @@ -55,8 +55,8 @@ corpus.factory('CorpusDB', function () { 'DEFINE VAR util.pair COMP C APP C I' ]; log('Compiler load:',syntax.compiler.load(codes[1])); - log('Compiler load:',syntax.compiler.load(codes[1])); - return {corpus: strings}; + log('Compiler load:',syntax.tree.load(syntax.compiler.load(codes[1]))); + return {corpus: codes}; }); From 3e4a06525923a06eaaa59ae3c0464082a9af1f26 Mon Sep 17 00:00:00 2001 From: yangit Date: Tue, 26 Aug 2014 16:03:13 +0400 Subject: [PATCH 06/20] Fix --- clientSrc/app/corpus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clientSrc/app/corpus.js b/clientSrc/app/corpus.js index 8fe4ff8..b450a34 100644 --- a/clientSrc/app/corpus.js +++ b/clientSrc/app/corpus.js @@ -54,8 +54,8 @@ corpus.factory('CorpusDB', function () { 'DEFINE VAR util.join J', 'DEFINE VAR util.pair COMP C APP C I' ]; - log('Compiler load:',syntax.compiler.load(codes[1])); - log('Compiler load:',syntax.tree.load(syntax.compiler.load(codes[1]))); + log('Term:', syntax.compiler.load(codes[1])); + log('Tree:', syntax.tree.load(syntax.compiler.load(codes[1]))); return {corpus: codes}; }); From f3c7acd3c53fbe60f22ca31e6a6a6a022da6d7fb Mon Sep 17 00:00:00 2001 From: yangit Date: Fri, 29 Aug 2014 08:56:40 +0800 Subject: [PATCH 07/20] Tabs -> spaces --- clientSrc/app/app.js | 4 +- clientSrc/app/corpus.js | 88 ++++++++++++++++---------------- clientSrc/index.html | 1 + test/server/corpusTest.js | 104 +++++++++++++++++++------------------- 4 files changed, 99 insertions(+), 98 deletions(-) diff --git a/clientSrc/app/app.js b/clientSrc/app/app.js index 47d45d0..ef3b33b 100644 --- a/clientSrc/app/app.js +++ b/clientSrc/app/app.js @@ -9,8 +9,8 @@ require('./corpus.js'); var puddle = angular.module('puddle', [uiRouter, 'corpus']); puddle.config(function ($stateProvider, $urlRouterProvider) { - // For any unmatched url, redirect to corpus - $urlRouterProvider.otherwise('/corpus'); + // For any unmatched url, redirect to corpus + $urlRouterProvider.otherwise('/corpus'); }); diff --git a/clientSrc/app/corpus.js b/clientSrc/app/corpus.js index b450a34..57657b2 100644 --- a/clientSrc/app/corpus.js +++ b/clientSrc/app/corpus.js @@ -7,56 +7,56 @@ var corpus = angular.module('corpus', [uiRouter]); var syntax = require('puddle-syntax'); corpus.config(function ($stateProvider) { - $stateProvider - .state('corpus', { - url: '/corpus', - templateUrl: 'corpus.html', - controller: 'corpus' - }); + $stateProvider + .state('corpus', { + url: '/corpus', + templateUrl: 'corpus.html', + controller: 'corpus' + }); }); corpus.controller('corpus', function ($scope, CorpusDB) { - $scope.corpus = CorpusDB.corpus; + $scope.corpus = CorpusDB.corpus; }); corpus.factory('CorpusDB', function () { - var codes = [ - 'ASSERT EQUAL APP APP C APP APP C VAR util.pair BOT VAR util.join I', - 'ASSERT EQUAL APP APP C APP VAR util.pair BOT VAR util.join I', - 'ASSERT EQUAL APP VAR types.div BOT BOT', - 'ASSERT EQUAL APP VAR types.div TOP TOP', - 'ASSERT EQUAL APP VAR types.semi BOT BOT', - 'ASSERT EQUAL APP VAR types.semi I I', - 'ASSERT EQUAL APP VAR types.semi TOP TOP', - 'ASSERT EQUAL APP VAR types.type I I', - 'ASSERT EQUAL APP VAR types.type TOP TOP', - 'ASSERT EQUAL APP VAR types.unit I I', - 'ASSERT EQUAL APP VAR types.unit TOP TOP', - 'ASSERT EQUAL COMP VAR types.forall.lower VAR types.forall.raise I', - 'ASSERT EQUAL COMP VAR types.forall.pull VAR types.forall.push I', - 'ASSERT EQUAL COMP VAR types.type VAR types.type VAR types.type', - 'ASSERT EQUAL VAR types.div APP VAR types.type APP CI TOP', - 'DEFINE VAR types.div APP VAR types.type K', - 'DEFINE VAR types.exp COMP COMP COMP COMP APP CB VAR ' + - 'types.type APP CB B CB CB VAR types.type', - 'DEFINE VAR types.forall JOIN APP APP VAR util.pair VAR ' + - 'types.forall.lower VAR types.forall.raise JOIN APP APP VAR ' + - 'util.pair VAR types.forall.pull VAR types.forall.push HOLE', - 'DEFINE VAR types.forall.lower APP APP C I TOP', - 'DEFINE VAR types.forall.pull COMP APP CB VAR types.div J', - 'DEFINE VAR types.forall.push APP APP C I TOP', - 'DEFINE VAR types.forall.raise K', - 'DEFINE VAR types.pow P', - 'DEFINE VAR types.semi APP VAR types.type APP VAR types.forall ' + - 'COMP APP CB B COMP CB COMP APP CB I CB', - 'DEFINE VAR types.type V', - 'DEFINE VAR types.unit APP VAR types.type JOIN APP K I VAR types.semi', - 'DEFINE VAR util.join J', - 'DEFINE VAR util.pair COMP C APP C I' - ]; - log('Term:', syntax.compiler.load(codes[1])); - log('Tree:', syntax.tree.load(syntax.compiler.load(codes[1]))); - return {corpus: codes}; + var codes = [ + 'ASSERT EQUAL APP APP C APP APP C VAR util.pair BOT VAR util.join I', + 'ASSERT EQUAL APP APP C APP VAR util.pair BOT VAR util.join I', + 'ASSERT EQUAL APP VAR types.div BOT BOT', + 'ASSERT EQUAL APP VAR types.div TOP TOP', + 'ASSERT EQUAL APP VAR types.semi BOT BOT', + 'ASSERT EQUAL APP VAR types.semi I I', + 'ASSERT EQUAL APP VAR types.semi TOP TOP', + 'ASSERT EQUAL APP VAR types.type I I', + 'ASSERT EQUAL APP VAR types.type TOP TOP', + 'ASSERT EQUAL APP VAR types.unit I I', + 'ASSERT EQUAL APP VAR types.unit TOP TOP', + 'ASSERT EQUAL COMP VAR types.forall.lower VAR types.forall.raise I', + 'ASSERT EQUAL COMP VAR types.forall.pull VAR types.forall.push I', + 'ASSERT EQUAL COMP VAR types.type VAR types.type VAR types.type', + 'ASSERT EQUAL VAR types.div APP VAR types.type APP CI TOP', + 'DEFINE VAR types.div APP VAR types.type K', + 'DEFINE VAR types.exp COMP COMP COMP COMP APP CB VAR ' + + 'types.type APP CB B CB CB VAR types.type', + 'DEFINE VAR types.forall JOIN APP APP VAR util.pair VAR ' + + 'types.forall.lower VAR types.forall.raise JOIN APP APP VAR ' + + 'util.pair VAR types.forall.pull VAR types.forall.push HOLE', + 'DEFINE VAR types.forall.lower APP APP C I TOP', + 'DEFINE VAR types.forall.pull COMP APP CB VAR types.div J', + 'DEFINE VAR types.forall.push APP APP C I TOP', + 'DEFINE VAR types.forall.raise K', + 'DEFINE VAR types.pow P', + 'DEFINE VAR types.semi APP VAR types.type APP VAR types.forall ' + + 'COMP APP CB B COMP CB COMP APP CB I CB', + 'DEFINE VAR types.type V', + 'DEFINE VAR types.unit APP VAR types.type JOIN APP K I VAR types.semi', + 'DEFINE VAR util.join J', + 'DEFINE VAR util.pair COMP C APP C I' + ]; + log('Term:', syntax.compiler.load(codes[1])); + log('Tree:', syntax.tree.load(syntax.compiler.load(codes[1]))); + return {corpus: codes}; }); diff --git a/clientSrc/index.html b/clientSrc/index.html index 9f1a6c1..3b0fb1f 100755 --- a/clientSrc/index.html +++ b/clientSrc/index.html @@ -15,6 +15,7 @@ Corpus editor +
diff --git a/test/server/corpusTest.js b/test/server/corpusTest.js index 87b800c..d620ad6 100644 --- a/test/server/corpusTest.js +++ b/test/server/corpusTest.js @@ -8,56 +8,56 @@ var corpus = rewire('../../lib/corpus'); describe('Server', function () { - describe('Corpus', function () { - var corpusFile = [ - '# this file is managed by corpus.js', - 'ASSERT EQUAL APP APP C APP APP C' + - ' VAR util.pair BOT VAR util.join I', - 'ASSERT EQUAL APP APP C APP VAR util.pair BOT VAR util.join I'] - .join('\n'); - - it('initialised with empty array', function () { - assert.equal(corpus.findAll().length, 0); - }); - - it('.load() tries to read from file', function () { - var spy = sinon.stub().returns(corpusFile); - var revert = corpus.__set__('fs', {readFileSync: spy}); - - corpus.load(); - assert(spy.calledOnce); - - revert(); - }); - - it('After .load(), findAll() returns right amount of lines', - function () { - assert.equal(corpus.findAll().length, 2); - }); - - describe('.dump()', function () { - var writeSpy = sinon.stub(); - var renameSpy = sinon.stub(); - var revert = corpus.__set__('fs', { - writeFileSync: writeSpy, - renameSync: renameSpy - }); - var lines; - - before(function () { - lines = corpus.dump(); - revert(); - }); - - it('writes to the file and moves it', function () { - assert(writeSpy.calledOnce); - assert(renameSpy.calledOnce); - }); - - it('writes correct data to the file', function () { - assert.equal(lines, corpusFile); - }); - - }); - }); + describe('Corpus', function () { + var corpusFile = [ + '# this file is managed by corpus.js', + 'ASSERT EQUAL APP APP C APP APP C' + + ' VAR util.pair BOT VAR util.join I', + 'ASSERT EQUAL APP APP C APP VAR util.pair BOT VAR util.join I'] + .join('\n'); + + it('initialised with empty array', function () { + assert.equal(corpus.findAll().length, 0); + }); + + it('.load() tries to read from file', function () { + var spy = sinon.stub().returns(corpusFile); + var revert = corpus.__set__('fs', {readFileSync: spy}); + + corpus.load(); + assert(spy.calledOnce); + + revert(); + }); + + it('After .load(), findAll() returns right amount of lines', + function () { + assert.equal(corpus.findAll().length, 2); + }); + + describe('.dump()', function () { + var writeSpy = sinon.stub(); + var renameSpy = sinon.stub(); + var revert = corpus.__set__('fs', { + writeFileSync: writeSpy, + renameSync: renameSpy + }); + var lines; + + before(function () { + lines = corpus.dump(); + revert(); + }); + + it('writes to the file and moves it', function () { + assert(writeSpy.calledOnce); + assert(renameSpy.calledOnce); + }); + + it('writes correct data to the file', function () { + assert.equal(lines, corpusFile); + }); + + }); + }); }); \ No newline at end of file From 704c9b6cc470dc21750ad21c3a1c8d241b900f92 Mon Sep 17 00:00:00 2001 From: yangit Date: Fri, 29 Aug 2014 17:30:07 +0800 Subject: [PATCH 08/20] Server: remove unused code --- clientSrc/app/app.js | 13 ++++++++++++- clientSrc/index.html | 6 +++--- server.js | 6 ++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/clientSrc/app/app.js b/clientSrc/app/app.js index ef3b33b..f235cfd 100644 --- a/clientSrc/app/app.js +++ b/clientSrc/app/app.js @@ -1,15 +1,26 @@ 'use strict'; +//This is an entry point into application. +//App consists of folowing modules: +//Corpus - corpus binding REST/Socket <=> HTML DOM + updates from either side. +//Logger - +//Navigator - + + var log = console.log.bind(console); var angular = require('angular'); var uiRouter = require('angular-ui-router'); + +//this will register ng-modules into angular namespace. require('./corpus.js'); +//require all modules. var puddle = angular.module('puddle', [uiRouter, 'corpus']); +//Define default route where to redirect all unknown URL's +//Outher routes defined witin other modules. puddle.config(function ($stateProvider, $urlRouterProvider) { - // For any unmatched url, redirect to corpus $urlRouterProvider.otherwise('/corpus'); }); diff --git a/clientSrc/index.html b/clientSrc/index.html index 3b0fb1f..b118f8f 100755 --- a/clientSrc/index.html +++ b/clientSrc/index.html @@ -3,9 +3,9 @@ Pomagma Editor - - - + + +