Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (47 sloc) 1.871 kb
PORT = 4000
require "sugar"
express = require "express"
fs = require "fs"
screenManager = require "./lib/screen_manager"
app = express()
app.configure () ->
app.use express.static(__dirname + '/public')
app.use express.logger()
app.configure "development", () ->
app.use express.errorHandler
dumpExceptions: true,
showStack: true
app.configure "production", () ->
basicAuth = express.basicAuth(process.env.STATUS_SCREEN_USERNAME, process.env.STATUS_SCREEN_PASSWORD)
app.use (req, res, next) ->
if req.ip.match /^192\.168\.0/
next()
else
basicAuth(req, res, next)
app.set "views", __dirname + "/views"
app.set "view engine", "jade"
app.set "view options", {layout: false}
app.get "/", (req, res) ->
screenManager.getCurrentScreen (html) ->
res.render "index.jade", { screen: html, freeze: false }
app.get "/test/:screen", (req, res) ->
screenManager.getScreen req.params.screen, req.query, (html) ->
res.render "index.jade", { screen: html, freeze: true }
app.get "/api/force/:screen", (req, res) ->
res.send "Forced screen #{req.params.screen}", 201
screenManager.forceScreen req.params.screen, req.query
server = app.listen PORT
io = require("socket.io").listen server, {"log level": if process.env.NODE_ENV == "production" then 2 else 3}
screenManager.init
sequence: [
{ screen: "welcome", duration: 15.seconds() }
{ screen: "menta-menu", duration: 30.seconds() }
{ screen: "clock", duration: 30.seconds() }
{ screen: "pi_day", duration: 15.seconds() } # only active on March 14 (see screens/pi_day.coffee), will be skipped on other days
]
defaultDurationForForcedScreens: 10.seconds()
onChangeScreen: (html) -> io.sockets.send html
# tell already connected clients to reload after the server has been (re)started
setTimeout () ->
io.sockets.emit "reload"
, 500
Jump to Line
Something went wrong with that request. Please try again.