Permalink
Browse files

No more server-side templates for now.

  • Loading branch information...
1 parent e680736 commit 2bb22a5d7d20344df5d4fbd6ef6879edbf4815b9 @ringmaster committed Mar 13, 2012
Showing with 33 additions and 23 deletions.
  1. +18 −5 barchat.js
  2. BIN htdocs/avatar2.png
  3. +15 −18 views/index.html
View
@@ -1,19 +1,29 @@
var express = require('express')
, routes = require('./routes')
- , jqtpl = require("jqtpl")
, mongoose = require("mongoose")
, Schema = mongoose.Schema
, crypto = require('crypto');
var app = module.exports = express.createServer();
-// Configuration
-
+// App Configuration
app.configure(function(){
app.set("view engine", "html");
- app.register(".html", require("jqtpl").express);
+ app.set('view options', {layout: false});
+ // make a custom html template
+ app.register('.html', {
+ compile: function(str, options){
+ return function(locals){
+ return str;
+ };
+ }
+ });
app.use(express.bodyParser());
app.use(express.methodOverride());
+ app.use(express.errorHandler({
+ dumpExceptions:true,
+ showStack:true
+ }));
app.use(app.router);
app.use(express.static(__dirname + '/htdocs'));
app.enable("jsonp callback");
@@ -56,7 +66,10 @@ var Messages = mongoose.model('Messages', MessagesSchema);
// Routes
-app.get('/', routes.index);
+//app.get('/', routes.index);
+app.get('/', function(req,res) {
+ res.render('index.html');
+});
app.post("/api/v1.0/getUserToken", function(req, res) {
Users.findOne({username: req.body.username, password: crypto.createHash('md5').update(req.body.password).digest("hex")}, function(err, doc){
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -112,25 +112,22 @@
<h1>BarChat</h1>
</header>
-<script id="user_placard" type="text/html">
- <li class="user_placard">
- <span class="status"></span>
- <img class="avatar" src="{{ avatar }}" title="{{ nickname }}">
- </li>
+<script id="placard_group" type="text/html">
+ <div class="placards">
+ <label>{{name}}</label>
+ <ul>
+ {{#placards}}
+ <li class="user_placard">
+ <span class="status"></span>
+ <img class="avatar" src="{{avatar}}" title="{{nickname}}">
+ </li>
+ {{/placards}}
+ <ul>
+ </div>
</script>
<div id="wrap">
<div id="statusbar">
- <label>Online</label>
- <ul id="users_online">
- </ul>
- <label>Services</label>
- <ul id="users_services">
- </ul>
- <label>Offline</label>
- <ul id="users_offline">
- </ul>
-
</div>
<div id="stage">
@@ -190,9 +187,9 @@
});
// Initialize user sample content
- $('#users_online').append(ich.user_placard({avatar: 'avatar.png', nickname: 'Bill Jennings'}));
- $('#users_services').append(ich.user_placard({avatar: 'github.png', nickname: 'GitHub'}));
- $('#users_offline').append(ich.user_placard({avatar: 'avatar2.png', nickname: 'Sue Heron'}));
+ $('#statusbar').append(ich.placard_group({name: 'online', placards: [{avatar: 'avatar.png', nickname: 'Bill Jennings'}]}));
+ $('#statusbar').append(ich.placard_group({name: 'services', placards: [{avatar: 'github.png', nickname: 'GitHub'}]}));
+ $('#statusbar').append(ich.placard_group({name: 'offline', placards: [{avatar: 'avatar2.png', nickname: 'Sue Heron'}]}));
$('#loginform').submit(function(){

0 comments on commit 2bb22a5

Please sign in to comment.