Skip to content
Browse files

some indentation fixes

  • Loading branch information...
1 parent 727f20f commit 56070ea64116edb9ca48605acc9b7e10ddf6c3ec @Shogun147 committed Oct 19, 2012
Showing with 59 additions and 76 deletions.
  1. +12 −25 lib/bootstrap.js
  2. +1 −3 lib/request.js
  3. +8 −8 lib/session/index.js
  4. +0 −1 lib/session/memory.js
  5. +0 −1 lib/session/redis.js
  6. +37 −37 lib/view/jade.js
  7. +1 −1 modules.json
View
37 lib/bootstrap.js
@@ -1,71 +1,58 @@
-/**
- * Extend EventEmitter, add series and parallel emit methods with done handler
- */
var EventEmitter = require('events').EventEmitter;
var Async = require('async');
-// Call all EventListener's in parallel and callback on all done
EventEmitter.prototype.parallel = function(event, callback) {
emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'parallel');
}
-// Call all EventListener's in order they are added and callback on last done
EventEmitter.prototype.series = function(event, callback) {
emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'series');
}
-// Listener wrapper
var fn = function(listener, args) {
return function(callback) {
- args = args.concat(callback);
+ args = args.concat(callback);
- listener.apply(listener, args);
+ listener.apply(listener, args);
}
}
-// Custom Event emit which allow to run event listeners in parallel or series
-// also we could listen all event listeners complete with callback
function emit(event, callback, args, type) {
- // Get all listeners for this event added with standart addListener or on methods
var listeners = this.listeners(event);
- // Prepared list of listeners
var list = [];
if (args.length) {
- for (var i=0; i<listeners.length; i++) {
- // Wrap listener
- var f = fn(listeners[i], args);
+ for (var i=0; i<listeners.length; i++) {
+ var f = fn(listeners[i], args);
- list.push(f);
- }
+ list.push(f);
+ }
} else {
- list = listeners;
+ list = listeners;
}
- // Parallel or Series
var method = type === 'parallel' ? Async.parallel : Async.series;
method(list, callback || function(error, results) {
- if (error) { throw error; }
+ if (error) { throw error; }
});
}
-// Methods call wrapper, around builder with regexp selector
Joose.Managed.Builder.meta.addMethod('call', function(targetMeta, info) {
targetMeta.addMethodModifier('initialize', function() {
var methods = {};
var around = {};
this.meta.getMethods().eachOwn(function(fn, name) {
- methods[name] = fn;
+ methods[name] = fn;
});
Joose.O.each(info, function (value, name) {
for (method in methods) {
- if (new RegExp(name).test(method)) {
- around[method] = value;
- }
+ if (new RegExp(name).test(method)) {
+ around[method] = value;
+ }
}
});
View
4 lib/request.js
@@ -14,9 +14,7 @@ Class('Katana.Core.Request', {
request: null, response: null,
method: 'get', url: null, uri: '/', routed_uri: '',
module: '', directory: '', controller: '', action: '', arguments: [], params: {},
- client: {}, form: null, data: {}, files: {}, query: {}, cookie: {}, session: {},
-
- methods: ['get', 'post', 'put', 'delete']
+ client: {}, form: null, data: {}, files: {}, query: {}, cookie: {}, session: {}
},
methods: {
View
16 lib/session/index.js
@@ -9,9 +9,9 @@ var Session = {
store: null,
create: function(session_id, callback) {
- new Session.store(session_id, function(sess) {
- callback(sess);
- });
+ new Session.store(session_id, function(sess) {
+ callback(sess);
+ });
}
};
@@ -27,19 +27,19 @@ App.on('run', function(callback) {
App.on('request', function(Request, Response, callback) {
new Store(Request.cookie.get(config.key_name), function(Session) {
- Request.session = Session;
+ Request.session = Session;
- callback();
+ callback();
});
});
App.on('cookie.send', function(Response, Request, callback) {
Request.session.save(function(error) {
- if (error) { Log.error('Error saving session: ' + Request.session.id); return callback(); }
+ if (error) { Log.error('Error saving session: ' + Request.session.id); return callback(); }
- Request.cookie.set(config.key_name, Request.session.id, { lifetime: config.lifetime });
+ Request.cookie.set(config.key_name, Request.session.id, { lifetime: config.lifetime });
- callback();
+ callback();
});
});
View
1 lib/session/memory.js
@@ -3,7 +3,6 @@ var config = App.Config().session;
var Memory = App.Store(config.store);
require('./store');
-require('joose');
Class('Katana.Core.Session.Memory', {
does: Katana.Core.Session.Store,
View
1 lib/session/redis.js
@@ -3,7 +3,6 @@ var config = App.Config().session;
var Redis = App.Store(config.store);
require('./store');
-require('joose');
Class('Katana.Core.Session.Redis', {
does: Katana.Core.Session.Store,
View
74 lib/view/jade.js
@@ -10,36 +10,36 @@ Class('Katana.Core.View.Jade', {
does: Katana.Core.View.Engine,
have: {
- jade: null
+ jade: null
},
methods: {
- initialize: function() {
- this.jade = Jade;
- },
-
- render: function(template, data) {
- template = template.replace('.', '/');
- data = data || {};
-
- var module = 'application';
-
- if (m = template.match(/(.*)\:(.*)/i)) {
- module = m[1];
- template = m[2];
- }
-
- data = extend(this.data, data);
-
- if (this.views[module] && this.views[module][template]) {
- var fn = this.jade.compile(this.views[module][template], config.options || {});
-
- return fn(data);
- } else {
- // handle no view exception...
- return '';
- }
- }
+ initialize: function() {
+ this.jade = Jade;
+ },
+
+ render: function(template, data) {
+ template = template.replace('.', '/');
+ data = data || {};
+
+ var module = 'application';
+
+ if (m = template.match(/(.*)\:(.*)/i)) {
+ module = m[1];
+ template = m[2];
+ }
+
+ data = extend(this.data, data);
+
+ if (this.views[module] && this.views[module][template]) {
+ var fn = this.jade.compile(this.views[module][template], config.options || {});
+
+ return fn(data);
+ } else {
+ // handle no view exception...
+ return '';
+ }
+ }
}
});
@@ -53,20 +53,20 @@ Jade.Parser.prototype.parseInclude = function() {
var non_jade = template[0] == '#';
if (non_jade) {
- template = template.substr(1);
+ template = template.substr(1);
}
if (m = template.match(/(.*)\:(.*)/i)) {
- module = m[1];
- template = m[2];
+ module = m[1];
+ template = m[2];
}
if (global.App.View.views[module][template] === undefined) {
- throw new Error('Template '+ template +' for module '+ module +' does not exists!');
+ throw new Error('Template '+ template +' for module '+ module +' does not exists!');
}
if (non_jade) {
- return new Jade.nodes.Literal(global.App.View.views[module][template]);
+ return new Jade.nodes.Literal(global.App.View.views[module][template]);
}
var parser = new Jade.Parser(global.App.View.views[module][template], module +':'+ template, this.options);
@@ -95,12 +95,12 @@ Jade.Parser.prototype.parseExtends = function() {
var module = 'application';
if (m = template.match(/(.*)\:(.*)/i)) {
- module = m[1];
- template = m[2];
+ module = m[1];
+ template = m[2];
}
if (global.App.View.views[module][template] === undefined) {
- throw new Error('Template '+ template +' for module '+ module +' does not exists!');
+ throw new Error('Template '+ template +' for module '+ module +' does not exists!');
}
var parser = new Jade.Parser(global.App.View.views[module][template], module +':'+ template, this.options);
@@ -119,8 +119,8 @@ Jade.runtime.rethrow = function(err, filename, lineno){
var module = 'application';
if (m = filename.match(/(.*)\:(.*)/i)) {
- module = m[1];
- template = m[2];
+ module = m[1];
+ template = m[2];
}
var context = 3
View
2 modules.json
@@ -1,6 +1,6 @@
{
"auth": {
- "description": "Base authorization and authentication module with roles and rights",
+ "description": "Basic authorization and authentication module with roles and rights",
"author": {
"name": "Shogun147",

0 comments on commit 56070ea

Please sign in to comment.
Something went wrong with that request. Please try again.