From 878c3f9a0f4769a4ebda305c866d4ca4f4dffcbc Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Wed, 20 Dec 2017 10:49:15 -0800 Subject: [PATCH 1/3] Add room descriptions to player view --- views/layout.jade | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/views/layout.jade b/views/layout.jade index f7b924cc..27b9fced 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -121,8 +121,11 @@ html(lang="en-US", ng-app="soundtrack-io") a.btn(href="/register") Register » .container.module - if (typeof(flash) != 'undefined') - .messages + .messages + if (room) + .alert.alert-info #{room.description} + + if (typeof(flash) != 'undefined') if (typeof(flash.error) != 'undefined') for error in flash.error .alert.alert-error !{error} From fb4128f5b81795c9fd95a3651764a2967799de34 Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Wed, 20 Dec 2017 11:57:09 -0800 Subject: [PATCH 2/3] Add initial test case, import Fabric --- package.json | 1 + test/Soundtrack.integration.js | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7b9ebc62..462c55e3 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "escape-html": "^1.0.3", "express": "^4.11.2", "express-session": "^1.10.2", + "fabric": "github:martindale/fabric#resources", "flashify": "~0.1.2", "heapdump": "^0.3.5", "jade": "~0.32.0", diff --git a/test/Soundtrack.integration.js b/test/Soundtrack.integration.js index be37f8b3..61b2ade6 100644 --- a/test/Soundtrack.integration.js +++ b/test/Soundtrack.integration.js @@ -1,13 +1,33 @@ -var assert = require('assert'); +'use strict'; -before(function() { - var app = require('../soundtrack'); +const assert = require('assert'); + +const Oracle = require('fabric').Oracle; +const Remote = require('fabric').Remote; + +const Soundtrack = require('../lib/soundtrack'); +const soundtrack = new Soundtrack({}); + +const remote = new Remote({ + host: 'localhost:9200', + secure: false }); describe('Soundtrack', function() { - describe('web server', function() { - it('should run', function() { - assert('ok'); + /*describe('web server', function() { + it('should run', function(done) { + app.start(function() { + app.stop(); + done(); + }); + }); + });*/ + + describe('Resources', function () { + it('should retrieve Rooms', async function () { + var rooms = await remote._GET('/rooms'); + console.log('rooms: ', rooms.toString()); + assert.ok(rooms); }); }); }); From 3a26d8011fea2ba9978910351ebbd3951b78a924 Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Sat, 19 Oct 2019 12:38:47 -0700 Subject: [PATCH 3/3] Initial snapshot of basic `soundtrack` Contract --- assets/index.html | 63 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- scripts/build.js | 19 ++++++++++++++ scripts/server.js | 0 types/soundtrack.js | 44 +++++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 assets/index.html create mode 100644 scripts/build.js create mode 100644 scripts/server.js create mode 100644 types/soundtrack.js diff --git a/assets/index.html b/assets/index.html new file mode 100644 index 00000000..a8a93901 --- /dev/null +++ b/assets/index.html @@ -0,0 +1,63 @@ + + + + + Making beautiful apps a breeze. · @fabric/maki + + + + + + +
+ +
+
+ +

@fabric/maki

+

Making beautiful apps a breeze.

+
+
+
+
+ + + +
+
+
+ +
+

Preparing content...

+

The application is compiling your document. Unless you've enabled JavaScript or are using the Fabric Browser, this message should not remain visible for long.

+
+
+
+
+
+ + + +
+
+
+
+
+
+ +
+
+ + + + +
+ + \ No newline at end of file diff --git a/package.json b/package.json index 462c55e3..af0b6397 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "soundtrack.io", - "version": "0.0.0", + "version": "0.2.0-develop", "description": "soundtrack.io is a collaborative online jukebox.", "main": "soundtrack.js", "scripts": { @@ -12,6 +12,7 @@ "author": "Eric Martindale", "license": "MIT", "dependencies": { + "@fabric/core": "FabricLabs/fabric#fabric-0.1.0-develop", "async": "~0.2.9", "body-parser": "^1.11.0", "connect-redis": "^2.2.0", diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 00000000..a398400c --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,19 @@ +'use strict'; + +const config = require('../config'); + +const SPA = require('@fabric/http/types/spa'); +const Compiler = require('@fabric/http/types/compiler'); + +async function main () { + let spa = new SPA(config); + let compiler = new Compiler({ + document: spa + }); + + compiler.compileTo('assets/index.html'); + + process.exit(); +} + +main(); diff --git a/scripts/server.js b/scripts/server.js new file mode 100644 index 00000000..e69de29b diff --git a/types/soundtrack.js b/types/soundtrack.js new file mode 100644 index 00000000..d6044a2f --- /dev/null +++ b/types/soundtrack.js @@ -0,0 +1,44 @@ +'use strict'; + +const package = require('../package'); +const Fabric = require('@fabric/core'); + +class Soundtrack extends Fabric.Service { + constructor (settings = {}) { + this.settings = Object.assign({ + name: 'soundtrack', + version: package.version + }, settings); + + this.documents = new Fabric.Collection(); + this.rooms = new Fabric.Collection(); + + this.swarm = new Fabric.Swarm(); + this.worker = new Fabric.Worker(); + + this.state = {}; + } + + async _getState () { + return { + documents: await this.documents.list(), + rooms: await this.documents.list() + } + } + + async stop () { + this.status = 'stopping'; + await this.swarm.stop(); + await this.worker.stop(); + this.status = 'stopped'; + } + + async start () { + this.status = 'starting'; + await this.worker.start(); + await this.swarm.start(); + this.status = 'started'; + } +} + +module.exports = Soundtrack; \ No newline at end of file