Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ results
npm-debug.log
node_modules
public/index.html
public/main.css
public/main.css.map
public/main.js
public/style.css
public/style.css.map
public/script.js
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions clientSrc/TODO.js

This file was deleted.

41 changes: 41 additions & 0 deletions clientSrc/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'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 angular = require('angular');
var uiRouter = require('angular-ui-router');
var socket = global.io = require('socket.io-client')();
var debug = global.debug = require('debug');
var log = debug('puddle:client:init');

//this will register ng-modules into angular namespace.
require('angular-socket-io');
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) {
$urlRouterProvider.otherwise('/corpus');
});


socket.on('connect', function () {
log('Socket IO connection estabilished');
});
socket.on('corpus', function (method, args) {
log('Corpus API incoming call: ', method, args);
});

socket.emit('corpus', 'findAll');
socket.emit('corpus', 'findById', ['540448b62711b16e9a6c7132']);

log('Puddle init complete.');
47 changes: 47 additions & 0 deletions clientSrc/app/corpus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';


var log = require('debug')('puddle:client:corpus');
var angular = require('angular');
var _ = require('lodash');
var uiRouter = require('angular-ui-router');
var corpus = angular.module('corpus', [uiRouter, 'btford.socket-io']);

corpus.config(function ($stateProvider) {
$stateProvider
.state('corpus', {
url: '/corpus',
templateUrl: 'corpus.html',
controller: 'corpus'
});
});

corpus.factory('Socket', function (socketFactory) {
return socketFactory();
});

corpus.controller('corpus', function ($scope, CorpusDB) {
$scope.corpus = CorpusDB.corpus;
});

corpus.factory('CorpusDB', function (Socket) {
var codes = [];
Socket.on('corpus', function (method, args) {
switch (method) {
case 'findAll':
var corpus = args[0];
if (_.isArray(corpus)) {
codes.length = 0;
corpus.forEach(function (a) {
codes.push(a);
});
}
break;
}
});

return {corpus: codes};
});

log('Corpus module init complete');

30 changes: 0 additions & 30 deletions clientSrc/assert.js

This file was deleted.

19 changes: 13 additions & 6 deletions clientSrc/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<!DOCTYPE html>
<html>
<html ng-app="puddle">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Pomagma Editor</title>
<link rel="icon" type="image/x-icon" href="static/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="static/main.css"/>
<script src='static/main.js'></script>
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src='script.js'></script>

<script type="text/ng-template" id="corpus.html">
<div ng-repeat="line in corpus">{{line}}</div>
</script>


</head>
<body>
<div class=code id=code></div>
<div class=code id=navigate></div>
<a ui-sref='corpus'>Corpus editor</a>

<div ui-view></div>
</body>
</html>
Empty file added clientSrc/styles/style.less
Empty file.
9 changes: 6 additions & 3 deletions doc/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To start a server that:
- builds with JS sourcemaps


npm run dev # alias for gulp serve --dev=true
npm run dev # alias for gulp develop

## Debugging Puddle

Expand All @@ -24,9 +24,12 @@ To run headless unit tests in various debug modes:
npm test
DEBUG=* npm test
DEBUG=express:*,puddle:* npm test

## To debug browserside

To run in-browser unit tests, start Pomagam+Puddle servers as above and
navigate to http://localhost:34934#test
Run following command in console.

debug.enable('puddle:*')

## Continous testing and code quality

Expand Down
37 changes: 28 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var gulp = require('gulp');
var gulpif = require('gulp-if');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var gutil = require('gulp-util');
Expand All @@ -11,6 +12,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) {
Expand All @@ -19,7 +21,8 @@ var watcher = function (tasks, paths) {
gulp.watch(paths, tasks)
.on('change', function (event) {
gutil.log(
'File ' + event.path + ' was ' + event.type + ', refreshing'
'File ' + event.path + ' was ' + event.type +
', refreshing'
);
}).on('error', function swallowError() {
this.emit('end');
Expand All @@ -45,7 +48,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'));
});
Expand All @@ -58,13 +61,14 @@ 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(ngAnnotate())
.pipe(gulpif(!argv.dev, uglify()))
.pipe(rename('script.js'))
.pipe(gulp.dest('./public'));
});

Expand Down Expand Up @@ -99,20 +103,35 @@ gulp.task('startLiveReload', function () {

gulp.task('nodemon', function () {
nodemon({
script: 'server.js',
script: './server/server.js',
ext: 'js',
watch: ['./lib', 'server.js']
args: argv.dev ? ['--withLiveReload=true'] : null,
watch: ['./server']
}).on('restart', function () {
console.log('Restarted server');
});
});

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/**/*'])();
gulp.task('serve', ['default'], function () {
require('./server/server');
});

gulp.task('develop', function () {
argv.dev = true;
gulp.start('developStart');
});

gulp.task('developStart', ['startLiveReload', 'default' , 'nodemon'],
function () {
watcher(['trackLiveReload'], [
'./clientSrc/**/*.js',
'./clientSrc/**/*.html',
'./clientSrc/**/*.less'
])();
});
100 changes: 0 additions & 100 deletions lib/corpus.js

This file was deleted.

Loading