[from now] 2012/04/07 10:17:21

diff --git a/server/app.js b/server/app.js
index f5c01c6..c389e27 100644
--- a/server/app.js
+++ b/server/app.js
@@ -5,34 +5,54 @@ var http = require('http'),

 var router = new (require('router-line').Router),
     socketio = require('socket.io'),
-    fileServer = new(require('node-static').Server)(path.join(process.cwd(), '/../browser'));
+    fileServer = new(require('node-static').Server)(path.join(__dirname, '/../browser'));

 var mterm = new (require('../master_terminal'))(80, 30),
     app,
     io,
-    handlers = {};
-
-mterm.open();
+    controllers;

 function isObject(obj) {
   return typeof obj === 'object' && obj !== null;
 }

+// routes
+router.GET('/', {
+  controller: controllers.top,
+  action: 'index'
+});
+router.GET('/about', {
+  controller: controllers.top,
+  action: 'about'
+});
+
 /*
- * Routing Table
+router.GET('/auth/:provider', {
+  controller: controllers.auth,
+  action: 'show'
+});
+router.GET('/auth/:provider/callback', {
+  controller: controllers.auth,
+  action: 'create'
+});
  */

-function Helper(req, res, params) {
-  this.request = req;
-  this.response = res;
-  this.params = params;
-  var parsedUrl = url.parse(this.request.url, true);
-  if (isObject(parsedUrl) && isObject(parsedUrl.query)) {
-    for (var key in parsedUrl.query) {
-      this.params[key] = parsedUrl.query[key];
-    }
-  }
-}
+router.GET('/channels', {
+  controller: controllers.terms,
+  action: 'index'
+});
+router.POST('/channels', {
+  controller: controllers.terms,
+  action: 'create'
+});
+router.GET('/channels/new', {
+  controller: controllers.terms,
+  action: 'new'
+});
+router.GET('/channels/:id', {
+  controller: controllers.terms,
+  action: 'show'
+});

 app = http.createServer(function (req, res) {
   var reqUrl = url.parse(req.url);
@@ -43,11 +63,15 @@ app = http.createServer(function (req, res) {
       fileServer.serve(req, res);
     });
   } else {
-    var handler = new Helper(req, res, target.params);
-    target.value.call(handler);
+    var Controller = target.value.controller;
+    var action = target.value.action;
+    var controller = new Controller(req, res, target.params);
+    controller[action]();
   }
 });

+mterm.open();
+
 io = socketio.listen(app);

 io.sockets.on('connection', function (socket) {
diff --git a/server/controllers/auth.js b/server/controllers/auth.js
new file mode 100644
index 0000000..e69de29
diff --git a/server/controllers/base.js b/server/controllers/base.js
new file mode 100644
index 0000000..dd9c877
--- /dev/null
+++ b/server/controllers/base.js
@@ -0,0 +1,15 @@
+module.exports = (function () {
+  function BaseController(req, res, params) {
+    this.request = req;
+    this.response = res;
+    this.params = params;
+    var parsedUrl = url.parse(this.request.url, true);
+    if (isObject(parsedUrl) && isObject(parsedUrl.query)) {
+      for (var key in parsedUrl.query) {
+        this.params[key] = parsedUrl.query[key];
+      }
+    }
+  }
+
+  return BaseController;
+})();
\ No newline at end of file
diff --git a/server/controllers/top.js b/server/controllers/top.js
new file mode 100644
index 0000000..0a36448
--- /dev/null
+++ b/server/controllers/top.js
@@ -0,0 +1,19 @@
+var util = require('util'),
+    BaseController = require('./base');
+
+module.exports = (function () {
+  function TopController () {
+    BaseController.call(this);
+
+  }
+  util.inherits(TopController, BaseController);
+
+  TopController.prototype.index = function () {
+
+  };
+
+  TopController.prototype.about = function () {
+
+  };
+
+})();
\ No newline at end of file
[from now] 2012/04/07 12:54:41

diff --git a/browser/index.html b/browser/index.html
index 37e10c4..2644320 100644
--- a/browser/index.html
+++ b/browser/index.html
@@ -2,9 +2,14 @@
 <html>
 <head>
 <meta charset="UTF-8">
-<title>live term test</title>
+<title>liveterm</title>
+<link href="./style.css" rel="stylesheet" type="text/css">
+<script src="./socket.io/socket.io.js"></script>
+<script src="./term.js"></script>
+<script src="./main.js"></script>
 </head>
 <body>
-<iframe src="liveterm.html" width="600" height="400" style="border: none;"></iframe>
+  <div id="display">
+  </div>
 </body>
 </html>
diff --git a/browser/liveterm.html b/browser/liveterm.html
deleted file mode 100644
index 150ee77..0000000
--- a/browser/liveterm.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="UTF-8">
-<title>liveterm</title>
-<link href="./style.css" rel="stylesheet" type="text/css">
-<script src="./socket.io/socket.io.js"></script>
-<script src="./term.js"></script>
-<script src="./main.js"></script>
-</head>
-<body>
-
-</body>
-</html>
diff --git a/browser/main.js b/browser/main.js
index 6588cd8..de37b1f 100644
--- a/browser/main.js
+++ b/browser/main.js
@@ -1,21 +1,23 @@
 var noop = function () { /* do nothing */ };

-var socket = io.connect();
+window.onload = function () {
+  var socket = io.connect();

-var term = new Terminal(80, 30, noop);
+  var term = new Terminal(80, 30, noop);

-socket.on('connect', function () {
-  term.open();
-  socket.emit('create');
-});
+  socket.on('connect', function () {
+    term.open();
+    socket.emit('create');
+  });

-socket.on('input', function (data) {
-  term.write(data);
-});
+  socket.on('input', function (data) {
+    term.write(data);
+  });

-socket.on('snapshot', function (data) {
-  for (var prop in data) {
-    term[prop] = data[prop];
-  }
-  term.refresh(0, 29);
-});
\ No newline at end of file
+  socket.on('snapshot', function (data) {
+    for (var prop in data) {
+      term[prop] = data[prop];
+    }
+    term.refresh(0, 29);
+  });
+};
\ No newline at end of file
diff --git a/browser/style.css b/browser/style.css
index a25d596..ad770ed 100644
--- a/browser/style.css
+++ b/browser/style.css
@@ -18,9 +18,21 @@ html {
   background: #fff;
 }

+#display {
+  position: absolute;
+  top: 24px;
+  left: 24px;
+}
+
+.terminal {
+  position: absolute;
+  border: white 1px solid;
+  box-shadow: 0px 0px 10px #000;
+}
+
 .term {
   font-family: "DejaVu Sans Mono", monospace;
-  font-size: 11px;
+  font-size: 11pt;
   color: #f0f0f0;
   background: #000;
 }
diff --git a/browser/term.js b/browser/term.js
index 1d3cb06..5ea241e 100644
--- a/browser/term.js
+++ b/browser/term.js
@@ -128,7 +128,8 @@ Terminal.prototype.open = function() {
     this.children.push(div);
   }

-  document.body.appendChild(this.element);
+  var display = document.getElementById('display');
+  display.appendChild(this.element);

   this.refresh(0, this.rows - 1);

diff --git a/caster/index.js b/caster/index.js
index 1bca874..bb16877 100644
--- a/caster/index.js
+++ b/caster/index.js
@@ -2,7 +2,8 @@ var tty = require('tty'),
     pty = require('pty.js'),
     io = require('socket.io-client');

-var socket = io.connect('http://localhost:8124'),
+var url = process.env.DEVELOP ? 'http://localhost:8124' : 'http://pronama14.koba789.com',
+    socket = io.connect(url),
     term = pty.spawn(process.env.SHELL, [], {
       name: 'xterm',
       cols: 80,
@@ -15,7 +16,6 @@ term.on('data', function(data) {
   console.log(data);
 });
 */
-
 process.stdin.resume();
 tty.setRawMode(true);

diff --git a/server/app.js b/server/app.js
index c389e27..a6dc3c2 100644
--- a/server/app.js
+++ b/server/app.js
@@ -10,11 +10,10 @@ var router = new (require('router-line').Router),
 var mterm = new (require('../master_terminal'))(80, 30),
     app,
     io,
-    controllers;
+    controllers = {};

-function isObject(obj) {
-  return typeof obj === 'object' && obj !== null;
-}
+controllers.top = require('./controllers/top');
+controllers.channels = require('./controllers/channels');

 // routes
 router.GET('/', {
@@ -38,26 +37,26 @@ router.GET('/auth/:provider/callback', {
  */

 router.GET('/channels', {
-  controller: controllers.terms,
+  controller: controllers.channels,
   action: 'index'
 });
 router.POST('/channels', {
-  controller: controllers.terms,
+  controller: controllers.channels,
   action: 'create'
 });
 router.GET('/channels/new', {
-  controller: controllers.terms,
+  controller: controllers.channels,
   action: 'new'
 });
 router.GET('/channels/:id', {
-  controller: controllers.terms,
+  controller: controllers.channels,
   action: 'show'
 });

 app = http.createServer(function (req, res) {
   var reqUrl = url.parse(req.url);
   var target = router.route(req.method.toUpperCase(),
-                             reqUrl.pathname);
+                            reqUrl.pathname);
   if (target === undefined) {
     req.on('end', function () {
       fileServer.serve(req, res);
@@ -74,6 +73,10 @@ mterm.open();

 io = socketio.listen(app);

+io.configure(function () {
+  io.disable('log');
+});
+
 io.sockets.on('connection', function (socket) {
   socket.on('create', function () {
     socket.emit('snapshot', mterm.snapshot());
diff --git a/server/controllers/base.js b/server/controllers/base.js
index dd9c877..da6e095 100644
--- a/server/controllers/base.js
+++ b/server/controllers/base.js
@@ -1,3 +1,9 @@
+var url = require('url');
+
+function isObject(obj) {
+  return typeof obj === 'object' && obj !== null;
+}
+
 module.exports = (function () {
   function BaseController(req, res, params) {
     this.request = req;
diff --git a/server/controllers/top.js b/server/controllers/top.js
index 0a36448..9da4fd7 100644
--- a/server/controllers/top.js
+++ b/server/controllers/top.js
@@ -1,19 +1,31 @@
 var util = require('util'),
-    BaseController = require('./base');
+    fs = require('fs'),
+    path = require('path'),
+    hogan = require('hogan.js'),
+    BaseController = require('./base'),
+    templates = {},
+    basepath = function (filename) {
+      return path.join(__dirname, '../../browser/', filename);
+    };
+
+templates.index = '';
+fs.readFile(basepath('index.html'), 'utf-8', function (err, data) {
+  templates.index = data;
+});

 module.exports = (function () {
   function TopController () {
-    BaseController.call(this);
-
+    BaseController.apply(this, arguments);
   }
   util.inherits(TopController, BaseController);

   TopController.prototype.index = function () {
-
+    this.response.end(templates.index);
   };

   TopController.prototype.about = function () {
-
+
   };

+  return TopController;
 })();
\ No newline at end of file