move some settings into a config file
This commit is contained in:
parent
1636bffd71
commit
8aee12fee3
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,8 @@
|
||||
node_modules
|
||||
lib
|
||||
config.json
|
||||
|
||||
npm-debug.log
|
||||
|
||||
media/*
|
||||
!media/.do_not_delete
|
||||
|
5
config.json.sample
Normal file
5
config.json.sample
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"port": "80",
|
||||
"tag_reader": ["./lib/bin/python", "tag-reader.py"],
|
||||
"mpg321": ["/usr/bin/mpg321", "-R", "-"]
|
||||
}
|
21
player.js
21
player.js
@ -1,7 +1,10 @@
|
||||
|
||||
const config = require('./config.json')
|
||||
|
||||
const glob = require('glob');
|
||||
const spawn = require('child_process').spawn;
|
||||
const tag_reader = spawn('/home/annika/rfid/run-tag-reader');
|
||||
const player = spawn('/usr/bin/mpg321', ['-R', '-']);
|
||||
const tag_reader = spawn(config.tag_reader[0], config.tag_reader.slice(1));
|
||||
const player = spawn(config.mpg321[0], config.mpg321.slice(1));
|
||||
|
||||
const express = require('express');
|
||||
const logger = require('morgan')
|
||||
@ -130,9 +133,10 @@ app.use(express.static(__dirname + '/static'))
|
||||
app.get('/', function (req, res, next) {
|
||||
try {
|
||||
var html = template({
|
||||
title: 'Home',
|
||||
last_tag: last_tag,
|
||||
play_log: play_log
|
||||
title: 'Home'
|
||||
, last_tag: last_tag
|
||||
, play_log: play_log
|
||||
, config: config
|
||||
})
|
||||
res.send(html)
|
||||
} catch (e) {
|
||||
@ -157,7 +161,8 @@ wss.on('connection', function (ws) {
|
||||
|
||||
server.on('request', app);
|
||||
|
||||
var server_port = process.env.PORT || 80;
|
||||
server.listen(server_port, function () {
|
||||
console.log('[http] listening on http://localhost:' + server_port)
|
||||
server.listen(config.port, function () {
|
||||
console.log('[http] listening on http://localhost:' + config.port)
|
||||
})
|
||||
|
||||
// vim:ts=2 sw=2 et:
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo -n /home/annika/rfid/lib/bin/python tag-reader.py
|
@ -3,7 +3,6 @@ html
|
||||
head
|
||||
link(rel='stylesheet', href='/css/index.css')
|
||||
title jukebox.stop.wtf
|
||||
script(src='/jukebox.js')
|
||||
body
|
||||
.header
|
||||
h1.page-title jukebox.stop.wtf
|
||||
@ -19,3 +18,5 @@ html
|
||||
|
||||
.footer
|
||||
p made with love by annika
|
||||
|
||||
script(src='/jukebox.js')
|
||||
|
@ -6,3 +6,8 @@ block content
|
||||
span#last_tag #{last_tag}
|
||||
ul#play-log
|
||||
include log
|
||||
|
||||
script.
|
||||
var jukebox = {
|
||||
port: #{config.port}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ window.onload = function() {
|
||||
}
|
||||
|
||||
var host = window.document.location.host.replace(/:.*/, '');
|
||||
var ws = new WebSocket('ws://' + host + ':80');
|
||||
var ws = new WebSocket('ws://' + host + ':' + jukebox.port);
|
||||
ws.onmessage = function (event) {
|
||||
console.log(event.data);
|
||||
updateLog(JSON.parse(event.data));
|
||||
|
Loading…
Reference in New Issue
Block a user