Commit 043bba36 authored by Aral Balkan's avatar Aral Balkan
Browse files

Updated to use the new pulse-node. Updated license file. Fixed minor...

Updated to use the new pulse-node. Updated license file. Fixed minor whitespace linting issues and added empty lines to ends of all files. Removed index.js.
parent 4a1c2ec3
This diff is collapsed.
......@@ -25,7 +25,7 @@ class PublicTimelineWeaver
instance = null
publicTimeline: null
db: null
constructor: ->
......@@ -50,7 +50,7 @@ class PublicTimelineWeaver
# Save reference to the singleton instance.
instance = @
return instance
......@@ -94,7 +94,7 @@ class PublicTimelineWeaver
# arrayOfMessages = []
toArray = WriteStream.toArray (arrayOfMessages) =>
# console.log "Streamweaver: got the timeline messages!"
#
# We have the old messages in an array, fulfill the promise.
#
......@@ -107,6 +107,4 @@ class PublicTimelineWeaver
)
module.exports = PublicTimelineWeaver
......@@ -8,17 +8,17 @@
# This is independent technology. See ind.ie/manifesto
#
# Copyright © Aral Balkan. Copyright © Ind.ie
# Released under the GNU AGPLv3 license.
# Released under ind.ie/license
#
################################################################################
request = require 'superagent-as-promised'
path = require 'path-extra'
Promise = require 'bluebird'
path = require 'path-extra'
fs = Promise.promisifyAll(require 'fs-extra')
PublicTimelineWeaver = require './PublicTimelineWeaver'
request = require 'superagent-as-promised'
PublicTimelineWeaver = require './PublicTimelineWeaver'
TeleportationAPI = require './TeleportationAPI'
......
......@@ -27,7 +27,7 @@ class TeleportationAPI
instance = null
teleportationAPI: null
constructor: ->
# Singleton access
......@@ -42,7 +42,7 @@ class TeleportationAPI
# Save reference to the singleton instance.
instance = @
return instance
#
......@@ -53,7 +53,7 @@ class TeleportationAPI
# Confirms that a new device has been added.
#
confirmNewDevice: (toPerson, deviceID) =>
@sendMessage(toPerson, {deviceID: deviceID}, '__confirm_new_device')
@sendMessage(toPerson, {deviceID: deviceID}, '__confirm_new_device')
#
......@@ -104,4 +104,4 @@ class TeleportationAPI
return path.join(homeFolder, 'Pulse', 'Sync', handle)
module.exports = TeleportationAPI
\ No newline at end of file
module.exports = TeleportationAPI
#!/bin/sh
git push live master
\ No newline at end of file
git push live master
......@@ -64,4 +64,4 @@ $(boot2docker shellinit)
# Start the Waystone docker container using fig.
echo "\nStarting Waystone using fig…\n"
fig up waystone
\ No newline at end of file
fig up waystone
......@@ -19,27 +19,11 @@ set -e
npm install
#
# Live module: indie-pulse-config
# Live module: pulse-node
#
git clone https://source.ind.ie/project/pulse-config.git node_modules/indie-pulse-config
cd node_modules/indie-pulse-config
git clone git@source.ind.ie:project/pulse-node.git node_modules/pulse-node
cd node_modules/pulse-node
./install
cd ../..
#
# Live module: indie-pulse-api
#
git clone https://source.ind.ie/project/indie-pulse-api.git node_modules/indie-pulse-api
cd node_modules/indie-pulse-api
./install
cd ../..
#
# Live module: indie-pulse-process
#
git clone https://source.ind.ie/project/indie-pulse-process.git node_modules/indie-pulse-process
cd node_modules/indie-pulse-process
./install
cd ../..
echo 'Waystone’s Node dependencies successfully installed.\n'
\ No newline at end of file
echo "Waystone’s Node dependencies successfully installed.\n"
......@@ -26,4 +26,4 @@ generatepulse:
- .:/home/waystone/source
- ~:/root
build: .
command: coffee source/generate-pulse.coffee
\ No newline at end of file
command: coffee source/generate-pulse.coffee
$(boot2docker shellinit)
\ No newline at end of file
$(boot2docker shellinit)
......@@ -15,7 +15,7 @@
fs = require 'fs-extra'
path = require 'path-extra'
PulseConfig = require 'indie-pulse-config'
PulseConfig = (require 'pulse-node').Config
#
# To run under boot2docker / fig (and not have nodemon choke on the node_modules folder),
......@@ -28,7 +28,7 @@ PulseConfig = require 'indie-pulse-config'
#
# So, if we’re running in dev, we need to switch to the source folder.
#
if process.cwd() == '/home/waystone'
if process.cwd() == '/home/waystone'
process.chdir('source')
console.log 'Running in development container… changed working folder to ' + process.cwd()
......@@ -36,7 +36,7 @@ PulseProcess = require 'indie-pulse-process'
console.log 'Generating and configuring Waystone’s Pulse instance…'
pulseProcessDelegate =
pulseProcessDelegate =
pulseProcessRestApiIsReady: ->
console.log 'API is ready.'
# (This should never get called.)
......@@ -87,7 +87,7 @@ if ! (fs.existsSync pulseConfigDirectory)
console.log "Creating #{pulseConfigDirectory}"
fs.mkdirSync pulseConfigDirectory
if ! (fs.existsSync pulseSyncDirectory)
if ! (fs.existsSync pulseSyncDirectory)
console.log "Creating #{pulseSyncDirectory}"
fs.mkdirSync pulseSyncDirectory
......
......@@ -21,16 +21,21 @@
#
# Includes
#
express = require 'express'
set = require 'indie-set'
http = require 'http'
bodyParser = require 'body-parser'
Promise = require 'bluebird'
fs = Promise.promisifyAll(require 'fs-extra')
path = require 'path-extra'
bodyParser = require 'body-parser'
PulseAPI = require 'indie-pulse-api'
PulseProcess = require 'indie-pulse-process'
PulseConfig = require 'indie-pulse-config'
fs = Promise.promisifyAll(require 'fs-extra')
express = require 'express'
set = require 'indie-set'
Pulse = require 'pulse-node'
PulseAPI = Pulse.API
PulseProcess = Pulse.Process
PulseConfig = Pulse.Config
PulseEventHandler = require './PulseEventHandler'
root = exports ? this
......@@ -45,8 +50,8 @@ root.pulseProcess = null
# package.json
# /node_modules
# /source/(source is here)
#
if process.cwd() == '/home/waystone'
#
if process.cwd() == '/home/waystone'
process.chdir('source')
console.log 'Updated working folder to ' + process.cwd()
......@@ -97,15 +102,15 @@ welcomeMessage = """
/ /═╬═\\ /═╬═\\ \\
/ |_║_| |_║_| \\
/______________________\\
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
└───────┘ └───────┘
__ __ _
/ / /\\ \\ \\__ _ _ _ ___| |_ ___ _ __ ___
__ __ _
/ / /\\ \\ \\__ _ _ _ ___| |_ ___ _ __ ___
\\ \\/ \\/ / _\` | | | / __| __/ _ \\| '_ \\ / _ \\
\\ /\\ / (_| | |_| \\__ \\ || (_) | | | | __/
\\/ \\/ \\__,_|\\__, |___/\\__\\___/|_| |_|\\___|
|___/
|___/
“But mostly because it felt like the right thing to do,
and that is reason enough.”
......@@ -131,7 +136,7 @@ root.config = config
#
# Read the DeviceID and PulseAPIKey from the config and add them to a
# config object (this is used by the routes). Also save a reference to
# config object (this is used by the routes). Also save a reference to
#
# TODO: Get Pulse API key… (or just use indie-pulse-api?)
......@@ -143,7 +148,7 @@ root.config = config
# TODO: Stop it when exiting.
#
pulseProcessDelegate =
pulseProcessDelegate =
pulseProcessRestApiIsReady: ->
# console.log '************* PULSE PROCESS DELEGATE: PULSE PROCESS REST API IS READY ***************'
......@@ -181,7 +186,7 @@ pulseProcessDelegate =
config.DeviceID = deviceID
config.pulse = root.pulse
# Signal to any controlling processes (e.g., Heartbeat native client)
# Signal to any controlling processes (e.g., Heartbeat native client)
# that the API is ready. The log is part of the process API. Do not remove.
console.log 'API is ready.'
......@@ -235,7 +240,7 @@ post = (command) ->
console.log 'New POST route: /' + command + ' -> ' + route
app.post '/' + command, require(route)(app)
app.post '/' + command, require(route)(app)
#
# Set up Express with Set as the templating engine.
......@@ -283,7 +288,7 @@ server = http.createServer app
port = (process.env.PORT || 3000)
server.listen port, () ->
serverMessage = """
╔═════════════════════════════════════════════════════════╗
╔═════════════════════════════════════════════════════════╗
║ Waystone is running on http://192.168.59.103:3000 ║
╚═════════════════════════════════════════════════════════╝
"""
......
// Generated by CoffeeScript 1.8.0
(function() {
var Gaze, Promise, Pulse, PulseProcess, app, bodyParser, config, express, fs, get, homeFolder, homePathSlash, http, parameters, path, port, post, pulse, pulseAPIKey, pulseProcess, pulseProcessDelegate, server, set, waystoneExists, waystoneFolder;
express = require('express');
set = require('indie-set');
http = require('http');
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs-extra'));
path = require('path');
bodyParser = require('body-parser');
Pulse = require('indie-pulse-api');
PulseProcess = require('indie-pulse-process');
Gaze = require('gaze').Gaze;
homeFolder = process.platform === 'win32' ? process.env.HOMEPATH : process.env.HOME;
homePathSlash = function(path) {
return homeFolder + '/' + path;
};
waystoneFolder = homePathSlash('waystone');
waystoneExists = fs.existsSync(waystoneFolder);
if (!waystoneExists) {
console.log('Setting up Waystone.\n\n');
console.log('Creating: ' + waystoneFolder);
fs.mkdirSync(waystoneFolder);
}
config = JSON.parse(fs.readFileSync('config.json'));
config.homeFolder = homeFolder;
pulseAPIKey = config.PulseAPIKey;
pulseProcessDelegate = {
pulseProcessRestApiIsReady: function() {
var pulse;
console.log('API is ready.');
pulse = new Pulse(pulseAPIKey);
return config.pulse = pulse;
},
pulseProcessFailedToStartProcess: function(data) {
console.log('Delegate: pulseProcessFailedToStartProcess error with data:');
return console.log(data.toString());
},
pulseProcessDidSendData: function(data) {},
pulseProcessDidSendErrorData: function(data) {
console.log('Delegate: pulseProcessDidSendErrorData with data:');
return console.log(data.toString());
},
pulseProcessDidExitWithCode: function(code) {
process.stdout.write('.');
console.log('\nPulse did exit.');
return process.exit(0);
}
};
pulseProcess = new PulseProcess(pulseProcessDelegate);
pulseProcess.quiet = true;
pulseProcess.start();
pulse = null;
get = function(command, parameters) {
var parameter, route, _i, _len;
if (parameters == null) {
parameters = [];
}
route = './routes/rest-api/get/' + command + '.coffee';
for (_i = 0, _len = parameters.length; _i < _len; _i++) {
parameter = parameters[_i];
command += '/:' + parameter;
}
return app.get('/' + command, require(route)(app));
};
post = function(command) {
var route;
route = './routes/rest-api/post/' + command + '.coffee';
console.log('New POST route: /' + command + ' -> ' + route);
return app.post('/' + command, require(route)(app));
};
app = express();
app.engine('html', set.__express);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.set('config', config);
app.use(express["static"]('views'));
app.use(bodyParser.urlencoded({
extended: false
}));
get('getDeviceId');
get('isHandleAvailable', parameters = ['handle']);
post('addPerson');
server = http.createServer(app);
port = process.env.PORT || 3000;
server.listen(port);
console.log('\nWaystone running at http://localhost:' + port + '/. Pipi\n');
}).call(this);
......@@ -6,8 +6,8 @@
#
# Gets your development environment ready to run Waystone.
#
# Copyright (c) 2014 Aral Balkan. All Rights Reserved.
# Copyright (c) 2014 Ind.ie.
# Copyright (c) 2014-15 Aral Balkan. All Rights Reserved.
# Copyright (c) 2014-15 Ind.ie.
#
######################################################################
......@@ -20,15 +20,15 @@ echo "
/ /═╬═\ /═╬═\ \\
/ |_║_| |_║_| \\
/______________________\\
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
└───────┘ └───────┘
__ __ _
/ / /\ \ \__ _ _ _ ___| |_ ___ _ __ ___
__ __ _
/ / /\ \ \__ _ _ _ ___| |_ ___ _ __ ___
\ \/ \/ / _\` | | | / __| __/ _ \| '_ \ / _ \\
\ /\ / (_| | |_| \__ \ || (_) | | | | __/
\/ \/ \__,_|\__, |___/\__\___/|_| |_|\___|
|___/
|___/
“But mostly because it felt like the right thing to do,
and that is reason enough.”
......@@ -59,7 +59,7 @@ installReason="out of date"
boot2docker version > /dev/null 2>&1
isInstalled=$?
if [ "$isInstalled" -eq 127 ]; then
if [ "$isInstalled" -eq 127 ]; then
installReason="not installed"
fi
......
{
"name": "Waystone",
"version": "0.0.1",
"version": "1.0.0",
"description": "But mostly because it felt like the right thing to do, and that is reason enough.",
"main": "index.coffee",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Aral Balkan",
"license": "GNU GPLv3",
"license": "ind.ie/license",
"dependencies": {
"bluebird": "2.3.5",
"body-parser": "1.6.5",
......
......@@ -4,15 +4,15 @@
/ /═╬═\ /═╬═\ \
/ |_║_| |_║_| \
/______________________\
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
│ ╔╦╗ ┌──┐ ╔╦╗ │
│ ╚╩╝ │ │ ╚╩╝ │
└───────┘ └───────┘
__ __ _
/ / /\ \ \__ _ _ _ ___| |_ ___ _ __ ___
__ __ _
/ / /\ \ \__ _ _ _ ___| |_ ___ _ __ ___
\ \/ \/ / _` | | | / __| __/ _ \| '_ \ / _ \
\ /\ / (_| | |_| \__ \ || (_) | | | | __/
\/ \/ \__,_|\__, |___/\__\___/|_| |_|\___|
|___/
|___/
“But mostly because it felt like the right thing to do,
and that is reason enough.”
......@@ -132,7 +132,7 @@ On the deployment box:
### Home folder: ```/home/git/```
Contains LevelDB database, Pulse, and waystone files.
Contains LevelDB database, Pulse, and waystone files.
# Testing the API
......
#!/bin/sh
echo "Rebooting the server…"
shutdown -r 0
\ No newline at end of file
shutdown -r 0
......@@ -15,4 +15,3 @@ confirm () {
}
confirm "Are you sure, this will destroy all Waystone images in Docker?" && docker images -q wayst* | xargs sudo docker rmi -f
#!/bin/sh
# Do this if Waystone won’t start due to a locked Level
# Do this if Waystone won’t start due to a locked Level
echo "Removing locks for Waystone and Pulse’s LevelDB databases."
# Remove the Waystone LevelDB lock file
# Remove the Waystone LevelDB lock file
rm ~/db/LOCK
# Remove the Pulse LevelDB lock file
......
......@@ -3,4 +3,4 @@
echo 'Signing into a shell on the latest docker container…'
$(boot2docker shellinit)
docker exec -it $(docker ps -q) bash
\ No newline at end of file
docker exec -it $(docker ps -q) bash
......@@ -2,4 +2,3 @@
# Run as the Git user so that it uses the same $HOME as the post-receive hook.
su git -c ./__start-deployment-server
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment