var express = require('express');
var app = express();
var stylus = require('stylus');
var format = require('util').format;
var uuid = require('node-uuid');
require('js-yaml');

var MongoClient = require('mongodb').MongoClient;
var Grid = require('gridfs-stream');

var database = require(__dirname + '/config/database.yaml');
database.mongodb_uri = process.env['MONGOHQ_URL'];

app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.locals.pretty = true;

app.use(stylus.middleware(__dirname + '/public'));
app.use(express.static(__dirname + '/public'));

app.use(express.cookieParser());
app.use(express.session({secret: uuid.v4()}));

app.use(express.bodyParser());

app.get('/', function(req, res) {
  res.render('clock');
});

app.get('/admin', function(req, res) {
  res.render('admin', {
    loggedIn: req.session.loggedIn,
    version: '0.1.0'
  });
});

app.get('/admin/logout', function(req, res) {
  req.session.loggedIn = false;
  res.redirect('/admin');
});

var port = process.env.PORT || 3000;
app.listen(port, function() {
  console.log('Listening on port ' + port);
});

MongoClient.connect(database.mongodb_uri, function(err, db) {
  if (err) throw err;
});

app.post('/admin/login', function(req, res) {
  if (req.body.password == 'penguins') {
    req.session.loggedIn = true;
  }
  res.redirect('/admin');
});
@@ -167,24 +167,26 @@
 js-yaml');%0A%0A
+/*
 var MongoCli
@@ -372,16 +372,18 @@
 Q_URL'%5D;
+*/
 %0A%0Aapp.se
@@ -1106,16 +1106,18 @@
 );%0A%7D);%0A%0A
+/*
 MongoCli
@@ -1191,24 +1191,26 @@
 row err;%0A%7D);
+*/
 %0A%0Aapp.post('

Disable MongoDB