- commit
- 94b7ac69ad32d8f3ba65905ecb564ca8325b469f
- parent
- 0a24d4f3eca239921e61be993dcf9a9189521dcf
- Author
- Tobias Bengfort <tobias.bengfort@liqd.de>
- Date
- 2016-09-15 13:09
Merge branch 'master' of https://github.com/dwt/voterunner into dwt-master
Diffstat
| A | .gitignore | 2 | ++ |
| M | README.md | 16 | ++++++++-------- |
| M | app.js | 1 | - |
| A | bin/initialize_db.sh | 10 | ++++++++++ |
| A | bin/watch.py | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | watch_requirements.txt | 2 | ++ |
6 files changed, 74 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,2 @@ -1 1 node_modules -1 2 data
diff --git a/README.md b/README.md
@@ -69,14 +69,14 @@ Voterunner is a [node.js](http://nodejs.org/) app using 69 69 [PostgreSQL](http://www.postgresql.org/) as a database so the following 70 70 lines will bring it up: 71 7172 -1 $ git clone https://git.gitorious.org/electomat/voterunner.git-1 72 $ git clone https://github.com/xi/voterunner 73 73 $ cd voterunner 74 74 $ npm install75 -1 $ export PORT=500076 -1 $ export DATABASE_URL='postgresql://user:password@host/database'77 -1 $ node app.js78 -1 info - socket.io started79 -1 info - Listening on 5000-1 75 $ pip install -r watch_requirements.txt -1 76 $ bin/initialize_db.sh -1 77 $ bin/watch.py -1 78 $ open http://localhost:5000/ # introduction -1 79 $ open http://localhost:5000/my-topic/ # discuss on a topic 80 80 81 81 82 82 Development @@ -102,7 +102,7 @@ The communication is done using socket.io sockets. 102 102 ... 103 103 }); 104 104105 -1 ### setup-1 105 ### Setup 106 106 107 107 These messages are used to set up the connection between client and 108 108 server: @@ -110,7 +110,7 @@ server: 110 110 `register(topic, id)` 111 111 : register for id and topic. needs to be done before anything else. 112 112113 -1 ### change the Graph-1 113 ### Change the Graph 114 114 115 115 These messages will be broadcasted to all sockets which are registered 116 116 to the same topic as the one emitting in. The emitting socket must omit
diff --git a/app.js b/app.js
@@ -79,7 +79,6 @@ var tpl = function(file, data, res) {
79 79 }
80 80
81 81 });
82 -1
83 82 res.send(html);
84 83 });
85 84 };
diff --git a/bin/initialize_db.sh b/bin/initialize_db.sh
@@ -0,0 +1,10 @@ -1 1 #!/bin/sh -1 2 -1 3 cd "$(dirname "$0")/.." -1 4 mkdir -p data/postgres -1 5 if test ! -d data/postgres/base; then -1 6 pg_ctl initdb -D data/postgres -1 7 pg_ctl start -w -D data/postgres -o "-h localhost" -1 8 createdb voterunner -1 9 pg_ctl stop -D data/postgres -1 10 fi
diff --git a/bin/watch.py b/bin/watch.py
@@ -0,0 +1,52 @@
-1 1 #!/usr/bin/env python
-1 2
-1 3 # install dependencies via `pip install -r watch_requirements.txt`
-1 4 # install browser extension from http://livereload.com/extensions/
-1 5
-1 6 from __future__ import print_function
-1 7
-1 8 from livereload import Server, shell
-1 9 import formic
-1 10
-1 11 EXCLUDES = ['**/vendor/**', '**/node_modules/**', '**/data/**']
-1 12 UNCOMPILED_FILES = formic.FileSet(include=['**.css', '**.html', '**.md'], exclude=EXCLUDES)
-1 13 JS_APP_FILES = formic.FileSet(include=['**.js'], exclude=EXCLUDES +['/app.js', '/static/voterunner.js'])
-1 14 COMBINED_JS_APP_FILES = formic.FileSet(include=['/static/voterunner.js'])
-1 15 NODE_APP_FILES = formic.FileSet(include=['app.js'])
-1 16 SCSS_FILES = formic.FileSet(include=['**.scss'], exclude=EXCLUDES)
-1 17 CSS_FILES = formic.FileSet(include=['**.css'], exclude=EXCLUDES)
-1 18
-1 19 server = Server()
-1 20
-1 21 def watch(file_set, shell_command=None, delay=None):
-1 22 for path in file_set:
-1 23 server.watch(path, shell_command, delay=delay)
-1 24
-1 25 def show(file_set):
-1 26 map(print, file_set)
-1 27
-1 28 # show(NODE_APP_FILES)
-1 29
-1 30 watch(JS_APP_FILES, shell('echo FIXME: how does the combining work? dependency missing?'), delay='forever')
-1 31 watch(COMBINED_JS_APP_FILES)
-1 32 watch(UNCOMPILED_FILES)
-1 33 watch(SCSS_FILES, shell('echo FIXME: which scss compilere shold be used? dependency missing?'), delay='forever')
-1 34 watch(CSS_FILES)
-1 35
-1 36 shell('pg_ctl start -w -D data/postgres -o "-h localhost" -l /dev/null')()
-1 37
-1 38 import os
-1 39 SERVER_SETTINGS = dict(
-1 40 PORT='5000',
-1 41 DATABASE_URL='postgresql://%s:@localhost/voterunner' % os.environ['USER'],
-1 42 )
-1 43 ENV = ' '.join(map('='.join, SERVER_SETTINGS.items()))
-1 44 NODE_COMMAND = shell('killall node; %(ENV)s nohup node app.js > /dev/null 2>&1 &' % locals(), shell='/bin/sh')
-1 45 NODE_COMMAND()
-1 46 watch(NODE_APP_FILES, NODE_COMMAND, delay=1)
-1 47
-1 48 server.serve(liveport=35729)
-1 49
-1 50 # Killing happens automatically
-1 51 # shell('pg_ctl stop -D data/postgres')()
-1 52 # shell('killall node')()
diff --git a/watch_requirements.txt b/watch_requirements.txt
@@ -0,0 +1,2 @@ -1 1 formic # only python2 compatibile -1 2 livereload