Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 47b92dad54
Fetching contributors…

Cannot retrieve contributors at this time

79 lines (65 sloc) 2.142 kb
express = require 'express'
stylus = require 'stylus'
fs = require 'fs'
path = require 'path'
runner = require './runner'
jobs = require './jobs'
app = module.exports = express.createServer()
app.configure ->
app.set 'views', __dirname + '/views'
app.set 'quiet', yes
# use coffeekup for html markup
app.set 'view engine', 'coffee'
app.register '.coffee', require('coffeekup')
app.set 'view options', {
layout: false
# This must be BEFORE other app.use
app.use stylus.middleware
debug: false
src: __dirname + '/views'
dest: __dirname + '/public'
compile: (str)->
stylus(str).set 'compress', true
coffeeDir = __dirname + '/views'
publicDir = __dirname + '/public'
app.use express.compiler src: coffeeDir, dest: publicDir, enable: ['coffeescript']
app.use express.logger()
app.use app.router
app.use express.static __dirname + '/public'
app.configure 'development', ->
app.use express.errorHandler dumpExceptions: on, showStack: on
app.configure 'production', ->
app.use express.errorHandler dumpExceptions: on, showStack: on
app.get '/', (req, res) ->
jobs.getAll (jobs)->
res.render 'index',
project: path.basename process.cwd()
jobs: jobs
app.get '/jobs', (req, res) ->
jobs.getAll (jobs)->
res.json jobs
app.get '/job/:id', (req, res) ->
jobs.get, (job) ->
res.json job
app.get '/job/:id/:attribute', (req, res) ->
jobs.get, (job) ->
if job[req.params.attribute]?
# if req.xhr...
res.json job[req.params.attribute]
res.send "The job doesn't have the #{req.params.attribute} attribute"
app.get '/clear', (req, res) ->
jobs.clear ->
res.redirect '/jobs'
app.get '/add', (req, res) ->
jobs.addJob ->
res.redirect '/jobs' '/', (req, res) ->
jobs.addJob (job)->
if req.xhr
console.log job
res.json job
res.redirect '/'
Jump to Line
Something went wrong with that request. Please try again.