Permalink
Browse files

fix error syntax

error and warning color
fix exports for client side
fix method already declared between client and server
  • Loading branch information...
jspdown
jspdown committed Mar 3, 2014
1 parent 8e15cd3 commit 7f04c6425478c37c9aac6f5bb49a3faebc156755
Showing with 62 additions and 98 deletions.
  1. +28 −41 bin/wkc
  2. +1 −1 example/basic/index.wk
  3. +0 −3 lib/client/webkool.js
  4. +0 −3 sources/client/webkool.ts
  5. +0 −5 sources/templates/webkool.wk
  6. +33 −45 sources/wkc.ts
View
69 bin/wkc
@@ -39,8 +39,6 @@ var Webkool;
*/
var version = '0.4.1';
var webkool = require('../lib/client/webkool.js');
var templateEngine = {
'square': require('../lib/square'),
'mustache': require('../lib/mustache')
@@ -65,7 +63,7 @@ var Webkool;
var async = require('async');
var stream = require('stream');
var simApp = { client: new webkool.Application(), server: new webkool.Application() };
var simApp;
var logger;
var outputJS, outputCSS, pr, options = {
@@ -480,6 +478,31 @@ var Webkool;
return BufferManager;
})();
var Router = (function () {
function Router() {
this.client = {};
this.server = {};
}
Router.prototype.addHandler = function (side, method, url, file, line, column) {
var sideHandler = side == 2 /* CLIENT */ ? this.client : this.server;
if (!sideHandler.hasOwnProperty(url))
sideHandler[url] = {};
if (sideHandler[url].hasOwnProperty(method)) {
var info = sideHandler[url][method];
var filename = pr.resolveCheck(file, options.includes);
var filenamePrev = pr.resolveCheck(info.file, options.includes);
logger.warning(filename, line, column, ' method already defined in file ' + filenamePrev + ':' + info.line + ':' + info.column);
}
sideHandler[url][method] = {
file: file,
line: line,
column: column
};
};
return Router;
})();
/*
** Nodes
*/
@@ -885,12 +908,8 @@ var Webkool;
}
}
Handler.prototype.printHeader = function (buffers, side) {
var sideStr = side == 2 /* CLIENT */ ? 'client' : 'server';
var filename = pr.resolveCheck(this.location.file, options.includes);
simApp.addHandler(side, this.attrs.method || 'ALL', this.attrs.url, this.location.file, this.location.line, this.location.col);
if (simApp[sideStr].addHandler(this.attrs.method || 'ALL', this.attrs.url, {}) == false) {
logger.warning(filename, this.location.line, 0, 'handler ' + (this.attrs.method || 'ALL') + ' ' + this.attrs.url + ' has been already defined');
}
var data = '';
data += 'application.addHandler(';
@@ -1270,43 +1289,11 @@ var Webkool;
});
}
function unitPath() {
var paths = [
'/plop/lal/toto',
'/plop/lal/',
'toto',
'./',
'',
'../plop/',
'../plop',
'plop/lal/toto',
'plop/lal/toto/'
];
paths.forEach(function (itm) {
console.log('---------------------------');
console.log('output: <' + itm + '>');
var p = new PathRes(itm);
console.log('root: <' + p.getRoot() + '>');
console.log('file: <' + p.getFile() + '>');
console.log('out: <SERVER><' + p.getOutputName(1)[1] + '>');
console.log('out: <CLIENT><' + p.getOutputName(2)[0] + '>');
console.log('out: <BOTH><' + p.getOutputName(0) + '>');
console.log('sourcemap: <' + p.getSourceMap() + '>');
console.log('resolve: <plop.js><' + p.resolve(p.getRoot(), 'plop.js') + '>');
console.log('resolve: <../plop.js><' + p.resolve(p.getRoot(), '../plop.js') + '>');
console.log('resolve: <plop/plop.js><' + p.resolve(p.getRoot(), 'plop/plop.js') + '>');
console.log('resolve: <../plop/plop.js>' + p.resolve(p.getRoot(), '../plop/plop.js') + '>');
console.log('resolve: <><' + p.resolve(p.getRoot(), '') + '>');
console.log('resolve: <plap/><' + p.resolve(p.getRoot(), 'plap/') + '>');
});
}
function run() {
logger = new Logger(process.stdout);
doParseArguments(options);
pr = new PathRes(options.output);
simApp = new Router();
options.includes.push(pr.getRoot());
var entryFile = pr.resolveCheck(options.inputs.shift(), options.includes);
View
@@ -29,7 +29,7 @@
<template><![CDATA[GET USER]]></template>
</handler>
<handler method='POST' url='/user' type='text/html'>
<handler method='GET' url='/user' type='text/html'>
<template><![CDATA[POST USER]]></template>
</handler>
View
@@ -621,6 +621,3 @@ var Server = (function (_super) {
};
return Server;
})(Application);
if (exports)
exports.Application = Application;
@@ -642,6 +642,3 @@ class Server extends Application {
}
}
if (exports)
exports.Application = Application;
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://www.webkool.net/1.0/">
<client>
<script>
/*jshint -W079 */
var exports = exports || {};
/*jshint +W079 */
</script>
<script href='webkool.js'></script>
<script href='hogan-2.0.0.js'></script>
<script>
View
@@ -43,8 +43,6 @@ module Webkool {
var version = '0.4.1'; //current version
var webkool = require('../lib/client/webkool.js');
var templateEngine = {
'square': require('../lib/square'), //internal square templating module
'mustache': require('../lib/mustache') //internal mustache(hogan.js) templating module
@@ -69,7 +67,7 @@ module Webkool {
var async = require('async');
var stream = require('stream');
var simApp = { client: new webkool.Application(), server: new webkool.Application() };
var simApp;
var logger;
var outputJS,
@@ -135,6 +133,8 @@ module Webkool {
return (feedback.error === 0);
}
/*
** Logger
*/
@@ -514,6 +514,33 @@ module Webkool {
}
}
class Router {
client;
server;
constructor() {
this.client = {};
this.server = {};
}
addHandler(side, method, url, file, line, column) {
var sideHandler = side == SideType.CLIENT ? this.client : this.server;
if (!sideHandler.hasOwnProperty(url))
sideHandler[url] = {};
if (sideHandler[url].hasOwnProperty(method)) {
var info = sideHandler[url][method];
var filename = pr.resolveCheck(file, options.includes);
var filenamePrev = pr.resolveCheck(info.file, options.includes);
logger.warning(filename, line, column, ' method already defined in file ' + filenamePrev + ':' + info.line + ':' + info.column);
}
sideHandler[url][method] = {
file: file,
line: line,
column: column
};
}
}
/*
** Nodes
@@ -940,17 +967,12 @@ module Webkool {
if (attrs.method) {
if (this.methodName.indexOf(attrs.method) == -1)
logger.warning(filename, this.location.line, 0, '<' + attrs.method + '> unknow method');
}
}
}
printHeader(buffers: BufferManager, side: SideType) {
var sideStr = side == SideType.CLIENT ? 'client' : 'server';
var filename = pr.resolveCheck(this.location.file, options.includes);
simApp.addHandler(side, this.attrs.method || 'ALL', this.attrs.url, this.location.file, this.location.line, this.location.col);
if (simApp[sideStr].addHandler(this.attrs.method || 'ALL', this.attrs.url, {}) == false) {
logger.warning(filename, this.location.line, 0, 'handler ' + (this.attrs.method || 'ALL') + ' ' + this.attrs.url + ' has been already defined');
}
var data = '';
data += 'application.addHandler(';
@@ -1356,45 +1378,11 @@ module Webkool {
});
}
function unitPath() {
var paths = [
'/plop/lal/toto',
'/plop/lal/',
'toto',
'./',
'',
'../plop/',
'../plop',
'plop/lal/toto',
'plop/lal/toto/'
];
paths.forEach(function (itm) {
console.log('---------------------------');
console.log('output: <' + itm + '>');
var p = new PathRes(itm);
console.log('root: <' + p.getRoot() + '>');
console.log('file: <' + p.getFile() + '>');
console.log('out: <SERVER><' + p.getOutputName(1 /* SERVER */)[1] + '>');
console.log('out: <CLIENT><' + p.getOutputName(2 /* CLIENT */)[0] + '>');
console.log('out: <BOTH><' + p.getOutputName(0 /* BOTH */) + '>');
console.log('sourcemap: <' + p.getSourceMap() + '>');
console.log('resolve: <plop.js><' + p.resolve(p.getRoot(), 'plop.js') + '>');
console.log('resolve: <../plop.js><' + p.resolve(p.getRoot(), '../plop.js') + '>');
console.log('resolve: <plop/plop.js><' + p.resolve(p.getRoot(), 'plop/plop.js') + '>');
console.log('resolve: <../plop/plop.js>' + p.resolve(p.getRoot(), '../plop/plop.js') + '>');
console.log('resolve: <><' + p.resolve(p.getRoot(), '') + '>');
console.log('resolve: <plap/><' + p.resolve(p.getRoot(), 'plap/') + '>');
});
}
export function run() {
logger = new Logger(process.stdout);
doParseArguments(options);
pr = new PathRes(options.output);
simApp = new Router();
options.includes.push(pr.getRoot());
var entryFile = pr.resolveCheck(options.inputs.shift(), options.includes);

0 comments on commit 7f04c64

Please sign in to comment.