Skip to content

Commit

Permalink
v0.9
Browse files Browse the repository at this point in the history
Merge branch 'dev'
  • Loading branch information
Zé Bateira committed May 6, 2014
2 parents 70d7281 + 157aaa8 commit 3041aac
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 49 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Installation

Execute the installer script.

```sh
$ wget --no-check-certificate https://raw.githubusercontent.com/carsy/rama-spotify/master/install.sh -O - | sh
```
or with curl
```sh
$ curl -L https://raw.githubusercontent.com/carsy/rama-spotify/master/install.sh | sh
```
Expand All @@ -34,12 +30,14 @@ These are the contents of the script:
```sh
$ mkdir ~/Spotify ; cd ~/Spotify
$ rm -rf rama
$ rm -rf rama-spotify
$ wget https://github.com/carsy/rama-spotify/releases/download/v0.8/rama_v0.8.tar.gz
$ tar -xvf rama_v0.8.tar.gz
$ rm rama_v0.9.tar.gz
$ curl https://github.com/carsy/rama-spotify/releases/download/v0.9/rama_v0.9.tar.gz
$ tar -xvf rama_v0.9.tar.gz
$ open spotify:app:rama
```

You should now be in the app and seeing a graph thingy.
If not, restart Spotify (open the app by typing spotify:app:rama in the search bar).

Alternatively, If you happen to have commandlinephobia (I get that every other month... might be a thing):

Expand All @@ -52,7 +50,7 @@ Now open Spotify and type in the search bar:
```sh
spotify:app:rama
```
You should now be in the app and seeing a graph thingy.
You should now be in the app and seeing a graph thingy. If not, restart Spotify

### GNU/Linux Support

Expand All @@ -61,6 +59,9 @@ With no official release for the Spotify Desktop Client, there's nothing I can d
[Releases]
----

[v0.9] - Exploring the graph
- Expand control button added.

[v0.8] - UX update
- Look and feel of nodes and buttons updated
- [bugfix] on double click node does not refresh graph
Expand Down
8 changes: 5 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh

version="v0.8"
version="v0.9"

mkdir ~/Spotify ; cd ~/Spotify
rm -rf rama-spotify
rm -rf rama
wget https://github.com/carsy/rama-spotify/releases/download/"$version"/rama_"$version".tar.gz
tar -xvf rama_"$version".tar.gz
rm rama_"$version".tar.gz
rm rama_"$version".zip
curl -L -O https://github.com/carsy/rama-spotify/releases/download/"$version"/rama_"$version".tar.gz
tar -xf rama_"$version".tar.gz
open spotify:app:rama
115 changes: 88 additions & 27 deletions js/controllers/artistmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ require([
return;
}

this.updateView(models.player.track.artists[0]);

this.updateView(this.artist);

this.jelement.find(this.selectors.controls).show();
this.jelement.find(this.selectors.control_new).show();
this.jelement.find(this.selectors.control_expand).hide();
});
},
onClickNode: function(data) {
Expand All @@ -162,13 +163,13 @@ require([
this.jelement.find(this.selectors.controls).show();
}

// if (node.isLeaf) {
// // this.jelement.find(this.selectors.control_expand).show();
// this.jelement.find(this.selectors.control_delete).show();
// } else {
// // this.jelement.find(this.selectors.control_expand).hide();
// this.jelement.find(this.selectors.control_delete).hide();
// }
if (node.isLeaf) {
this.jelement.find(this.selectors.control_expand).show();
// this.jelement.find(this.selectors.control_delete).show();
} else {
this.jelement.find(this.selectors.control_expand).hide();
// this.jelement.find(this.selectors.control_delete).hide();
}

this.updateView(node.artist);
},
Expand All @@ -178,32 +179,92 @@ require([
// then add nodes and edges
// create new graph with updated nodes and edges
// setPosition(savedPositions)

var node = _.findWhere(
this.graphcontroller.artistGraph.data.nodes, {
id: this.artist.nodeid
});

node.color = {
border: '#7fb701',
background: '#313336'
};

this.artist.load('related').done(this, function(artist) {
var rootArtist = artist;
artist.related.snapshot(0,
this.graphcontroller.artistGraph.branching).done(this,
function(snapshot) {
snapshot.loadAll(['name', 'uri']).each(this, function(artist) {
var artistGraph = this.graphcontroller.artistGraph;

var duplicated = _.findWhere(artistGraph.data.nodes, {
label: artist.name
});

if (duplicated && artist.name !== rootArtist.name) {
var inverseEdgeExists = _.findWhere(artistGraph.data.edges, {
from: duplicated.id,
to: rootArtist.nodeid
});
var edgeExists = _.findWhere(artistGraph.data.edges, {
to: duplicated.id,
from: rootArtist.nodeid
});

if (!inverseEdgeExists && !edgeExists) {
var extraEdge = {
from: rootArtist.nodeid,
to: duplicated.id,
};

artistGraph.extraEdges.push(extraEdge);

if (!artistGraph.treemode)
artistGraph.data.edges.push(extraEdge);
}
} else {
var nodeid = ++artistGraph.index;

artistGraph.data.nodes.push({
id: nodeid,
label: artist.name,
artist: artist,
isLeaf: true
});

artistGraph.data.edges.push({
from: rootArtist.nodeid,
to: nodeid
});

artistGraph.relatedArtists.push(artist);

artist.nodeid = nodeid;
}
}).done(this, function() {

this.graphcontroller.updateData();

});
});
});

this.jelement.find(this.selectors.control_expand).hide();
},
onBtnNewClick: function(event) {
this.graphcontroller.updateArtist(this.artist);
this.jelement.find(this.selectors.control_new).hide();
this.jelement.find(this.selectors.control_delete).hide();
},
onBtnDeleteClick: function(event) {
// TODO delete node from graph
// save nodes' positions
// delete node from graph
// create new graph from updated data
//
var node = _.findWhere(
this.graphcontroller.artistGraph.data.nodes, {
id: this.artist.nodeid
});

var edges = _.where(this.graphcontroller.artistGraph.data.edges, {
to: this.artist.nodeid
});
// var node = _.findWhere(
// this.graphcontroller.artistGraph.data.nodes, {
// id: this.artist.nodeid
// });

var index = this.graphcontroller.artistGraph.data.nodes.indexOf(node);
this.graphcontroller.artistGraph.graph.setData(this.graphcontroller.artistGraph.data);
// this.graphcontroller.updateGraph();
console.log(this.artist);
console.log(this.artist.nodeid);
// var index = this.graphcontroller.artistGraph.data.nodes.indexOf(node);
// this.graphcontroller.updateData();
}

});
Expand Down
3 changes: 3 additions & 0 deletions js/controllers/graphcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ require([

this.bindAllEvents();
},
updateData: function() {
this.artistGraph.graph.setData(this.artistGraph.data);
},
showThrobber: function() {
if (this.artistGraph.throbber)
this.artistGraph.throbber.hide();
Expand Down
4 changes: 2 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ spotify.require([
color: '#3e3e40',
highlight: '#dfe0e6'
}
},
stabilize: true
}
//, stabilize: true
//, clustering: true
},
},
Expand Down
11 changes: 5 additions & 6 deletions js/models/artistgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ var ArtistGraph = function(element, artist, config) {
this.graph = new vis.Graph(this.element, this.data, this.options);

var graph = this.graph;
this.graph.on('stabilized', function(iterations) { // Y U NO WORK
// graph.zoomExtent();
console.log(iterations);
// this.storePosition();
});
// this.graph.on('stabilized', function(iterations) { // Y U NO WORK
// // graph.zoomExtent();
// console.log(iterations);
// // this.storePosition();
// });
};

ArtistGraph.DEFAULT_BRANCHING = 4;
Expand Down Expand Up @@ -155,7 +155,6 @@ ArtistGraph.prototype = {
});

this.graph.start();
this.graph.storePosition();

this.bindAllEvents();

Expand Down
5 changes: 2 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"track"
],
"BundleType": "Application",
"BundleVersion": "0.8",
"BundleVersion": "0.9",
"Dependencies": {
"api": "1.0.0",
"views": "1.0.0",
Expand All @@ -21,6 +21,5 @@
"SupportedLanguages": [
"en"
],
"VendorIdentifier": "pt.inescporto",
"RequiredPermissions": ["https://ssl.google-analytics.com", "http://fonts.googleapis.com"]
"VendorIdentifier": "pt.inescporto"
}

0 comments on commit 3041aac

Please sign in to comment.