diff --git a/assets/css/library.css.sass b/assets/css/library.css.sass
index 389a607..5c176c2 100644
--- a/assets/css/library.css.sass
+++ b/assets/css/library.css.sass
@@ -1,4 +1,4 @@
-#library
+mpd-library
background: white
position: absolute
top: 100%
@@ -40,7 +40,7 @@
@extend .list
ol.songs
@extend .song-list
- panel
+ mpd-panel
position: absolute
width: $interface-width
height: 100%
diff --git a/assets/css/queue.css.sass b/assets/css/queue.css.sass
index bd81097..ffe0e6b 100644
--- a/assets/css/queue.css.sass
+++ b/assets/css/queue.css.sass
@@ -1,7 +1,5 @@
-#queue
+mpd-queue
height: 100%
- overflow: auto
- padding: 2.5em 0 5.625em
header
z-index: 1
@extend .header
@@ -11,6 +9,9 @@
top: 8px
@include button
ol
+ padding: 2.5em 0 5.625em
+ height: 100%
+ overflow: auto
@extend .song-list
li.playing
.title
diff --git a/assets/js/application.js b/assets/js/application.js
index e6a9817..ed33fa2 100644
--- a/assets/js/application.js
+++ b/assets/js/application.js
@@ -1,26 +1,30 @@
// Set up necessary events and startup stuff
$(document).ready(function() {
- $.when(QueueSong.findAll(), Status.findOne()).then(function(queueSongs, status) {
+ //$.when(QueueSong.findAll(), Status.findOne()).then(function(queueSongs, status) {
- window.mpdClient = {
- status: status,
- queueSongs: queueSongs,
+ //window.mpdClient = {
+ //status: status,
+ //queueSongs: queueSongs,
- transport: new Transport('#transport', {
- status: status
- }),
+ //transport: new Transport('#transport', {
+ //status: status
+ //}),
- library: new Library('#library'),
+ //library: new Library('#library'),
- events: new Events(queueSongs, status),
+ //events: new Events(queueSongs, status),
- queue: new Queue('#queue', {
- queueSongs: queueSongs,
- status: status
- })
- };
+ //queue: new Queue('#queue', {
+ //queueSongs: queueSongs,
+ //status: status
+ //})
+ //};
- });
+ //});
+
+ // Render the application template. Components should take care of the rest.
+ var template = can.view.mustache("");
+ $(document.body).append(template());
});
diff --git a/assets/js/components/app.js b/assets/js/components/app.js
new file mode 100644
index 0000000..8c3e340
--- /dev/null
+++ b/assets/js/components/app.js
@@ -0,0 +1,30 @@
+can.Component.extend({
+
+ tag: 'mpd-client',
+
+ template: can.view('views/app.mustache'),
+
+ scope: {
+ queueSongs: new can.List(),
+ status: new can.Map()
+ },
+
+ events: {
+ init: function(element, options) {
+ this.scope.attr('events', new Events(this.scope.queueSongs, this.scope.status));
+ this.fetch();
+ },
+
+ fetch: function() {
+ var self = this;
+ QueueSong.findAll().then(function(songs) {
+ self.update(songs);
+ });
+ },
+
+ update: function(songs) {
+ this.scope.attr('queueSongs', songs);
+ }
+ }
+
+});
diff --git a/assets/js/components/library.js b/assets/js/components/library.js
new file mode 100644
index 0000000..1b5a831
--- /dev/null
+++ b/assets/js/components/library.js
@@ -0,0 +1,7 @@
+can.Component.extend({
+
+ tag: 'mpd-library',
+
+ template: can.view('views/library.mustache'),
+
+});
diff --git a/assets/js/components/panel.js b/assets/js/components/panel.js
index 8e55378..49249d0 100644
--- a/assets/js/components/panel.js
+++ b/assets/js/components/panel.js
@@ -1,15 +1,12 @@
can.Component.extend({
- init: function() {
- console.log('Initializing');
- },
-
- tag: 'panel',
+ tag: 'mpd-panel',
template: can.view('views/panel.mustache'),
scope: {
show: '@',
+ depth: '@',
artist: '@',
album: '@',
title: function() {
@@ -18,17 +15,13 @@ can.Component.extend({
},
fetchItems: {
root: new can.Map,
- artists: Artist.findAll({}),
- albums: Album.findAll({ artist: this.artist }),
- songs: Song.findAll({ artist: this.artist, album: this.album })
+ artists: function() { return Artist.findAll({}) },
+ albums: function() { Album.findAll({ artist: this.artist }) },
+ songs: function() { Song.findAll({ artist: this.artist, album: this.album }) }
}
},
- events: {
- inserted: function() {
- console.log('Panel inserted.');
- }
- },
+ events: {},
helpers: {
renderItems: function() {
diff --git a/assets/js/components/queue.js b/assets/js/components/queue.js
new file mode 100644
index 0000000..42d8661
--- /dev/null
+++ b/assets/js/components/queue.js
@@ -0,0 +1,7 @@
+can.Component.extend({
+
+ tag: 'mpd-queue',
+
+ template: can.view('views/queue.mustache')
+
+});
diff --git a/assets/js/constructs/events.js b/assets/js/constructs/events.js
index c164285..8834cbf 100644
--- a/assets/js/constructs/events.js
+++ b/assets/js/constructs/events.js
@@ -13,6 +13,7 @@ var Events = can.Construct.extend({
break;
case 'queue':
queue.replace(response.data);
+ debugger;
break;
case 'time':
status.attr('time', response.data);
@@ -22,6 +23,7 @@ var Events = can.Construct.extend({
status.bind('change', function(event, attr, how, newVal, oldVal) {
if (attr == 'song') {
+ debugger;
queue.updatePlaying(how, newVal, oldVal);
}
});
diff --git a/assets/js/controls/library.js b/assets/js/controls/library.js
index 80a1902..96ed192 100644
--- a/assets/js/controls/library.js
+++ b/assets/js/controls/library.js
@@ -2,12 +2,10 @@ var Library = can.Control.extend({
init: function(element, options) {
this.element = element;
- this.browser = new can.Model({ title: 'Library', currentPane: 0 });
+ this.browser = new can.Model({ title: 'Library', currentDepth: 0 });
element.html(
can.view('views/library.mustache', { browser: this.browser })
);
- var rootControl = new Pane('#library .root', { show: 'root' });
- this.panes = new can.List([rootControl]);
},
show: function() {
@@ -33,12 +31,9 @@ var Library = can.Control.extend({
},
addPane: function(data) {
- var newElement = document.createElement('div');
+ var newElement = document.createElement('panel');
$('.browser', this.element).append(newElement);
- data['pos'] = this.panes.length;
- var newPane = new Pane(newElement, data);
-
this.panes.push(newPane);
this.setTitle(newPane.title);
this.nextPane();
diff --git a/assets/js/mpd-client.js b/assets/js/mpd-client.js
index 5125c55..9971027 100644
--- a/assets/js/mpd-client.js
+++ b/assets/js/mpd-client.js
@@ -6,6 +6,6 @@
//= require_tree ./models/
//= require_tree ./helpers/
//= require_tree ./controls/
-//= require_tree ./components/
//= require_tree ./constructs/
+//= require_tree ./components/
//= require ./application.js
diff --git a/public/views/app.mustache b/public/views/app.mustache
new file mode 100644
index 0000000..53ad1d6
--- /dev/null
+++ b/public/views/app.mustache
@@ -0,0 +1,7 @@
+
diff --git a/public/views/library.mustache b/public/views/library.mustache
index 379f3c0..956a828 100644
--- a/public/views/library.mustache
+++ b/public/views/library.mustache
@@ -1,5 +1 @@
-
+
diff --git a/public/views/queue.mustache b/public/views/queue.mustache
new file mode 100644
index 0000000..e8cbc02
--- /dev/null
+++ b/public/views/queue.mustache
@@ -0,0 +1,13 @@
+
+
+ {{#each queueSongs}}
+ -
+
{{title}}
+ {{artist}}
+ {{formatLength length}}
+
+ {{/each}}
+
diff --git a/public/views/transport.mustache b/public/views/transport.mustache
new file mode 100644
index 0000000..5b7cdcf
--- /dev/null
+++ b/public/views/transport.mustache
@@ -0,0 +1,24 @@
+
+ {{#if status.playingOrPaused()}}
+
<%= formatLength(status.attr('time')[0]) %>
+
-<%= formatLength(status.attr('time')[1] - status.attr('time')[0]) %>
+ {{else}}
+
--:--
+
--:--
+ {{/if}}
+
+ {{#if playingOrPaused()}}
+
+ {{/if}}
+
+
+
diff --git a/views/index.erb b/views/index.erb
index 874fa04..fdbabbe 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -8,12 +8,5 @@
-