Skip to content

Commit

Permalink
Merge pull request #48 from Soundnode/window-frame
Browse files Browse the repository at this point in the history
GUI actions - about page - code refactoring
  • Loading branch information
weblancaster committed May 30, 2014
2 parents 39ae105 + 67f5811 commit 9200213
Show file tree
Hide file tree
Showing 20 changed files with 490 additions and 227 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ Built with Node-Webkit, Node.js, Angular.js and consuming Soundcloud API.

![alt tag](https://raw.githubusercontent.com/Soundnode/soundnode-app/master/Soundnode-app.png)

## Features

- Free
- Your Stream/Likes/Tracks/Playlists
- Simple main features (play-pause/prev-next song)
- No Ads (no noise on the UI)

## beta Developer release

Since the core is done I figured release a beta version just for devs/community to receive feedback/contributions.
Expand Down
Binary file removed Soundnode-app.png
Binary file not shown.
30 changes: 27 additions & 3 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,31 @@
</head>

<body data-isVisible="false" ng-controller="AppCtrl">

<div class="topBorder"></div>

<header class="topFrame">
<ul class="windowAction">
<li class="windowAction_item " id="closeApp">
<i class="fa fa-times"></i>
</li>
<li class="windowAction_item " id="minimizeApp">
<i class="fa fa-minus"></i>
</li>
<li class="windowAction_item " id="expandApp">
<i class="fa fa-plus"></i>
</li>
</ul>

<ul class="appInfo">
<li class="appInfo_item ">
<a ui-sref="about">about</a>
</li>
<li class="appInfo_item updateAvailable">
<a href=""> update available! </a>
</li>
</ul>

<h1 class="topFrame_title">Soundnode App</h1>
</header>

<!-- loading gif -->
<div class="box-loader loading">
Expand Down Expand Up @@ -137,7 +160,7 @@ <h4 id="playerUser" class="player_user"></h4>
<script src="public/js/vendor/angular-ui-router.min.js"></script>

<!-- app -->
<script src="public/js/system/api.js"></script>
<script src="public/js/system/core.js"></script>
<script src="public/js/app.js"></script>

<!-- services/factories -->
Expand All @@ -155,6 +178,7 @@ <h4 id="playerUser" class="player_user"></h4>
<script src="public/js/tracks/tracksCtrl.js"></script>
<script src="public/js/playlists/playlistsCtrl.js"></script>
<script src="public/js/following/followingCtrl.js"></script>
<script src="public/js/about/aboutCtrl.js"></script>

<!-- directives -->
<script src="public/js/common/songDirective.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"window": {
"title": "Soundnode App",
"toolbar": false,
"frame": true,
"frame": false,
"width": 1152,
"height": 585,
"height": 885,
"min_width": 1152,
"min_height": 585,
"min_height": 885,
"resizable": true,
"position": "mouse",
"single-instance": true,
Expand Down
20 changes: 20 additions & 0 deletions app/public/js/about/aboutCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

app.controller('AboutCtrl', function ($scope, $http) {
var url = 'https://api.github.com/repos/Soundnode/soundnode-about/readme'
, config = { headers: {
'Accept': 'application/vnd.github.v3.raw+json'
}
};

$scope.title = 'About Soundnode App';
$scope.content = '';

$http.get(url, config)
.success(function (data) {
$scope.content = data;
})
.error(function (error) {
console.log('Error', error)
});
});
5 changes: 5 additions & 0 deletions app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ app.config(function ($stateProvider, $urlRouterProvider) {
url: '/search?q',
templateUrl: 'views/search/search.html',
controller: 'searchCtrl'
})
.state('about', {
url: '/about',
templateUrl: 'views/about/about.html',
controller: 'AboutCtrl'
});
});
5 changes: 5 additions & 0 deletions app/public/js/common/playerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ app.factory('playerService', function($rootScope) {
* Add event listener "on ended" to player
*/
$(player.elPlayer).off().on('ended', function() {
$rootScope.isSongPlaying = false;
player.playNextSong();
});

/**
* Add event listener "time update" to song bar progress
* and song timer progress
*/
$(player.elPlayer).bind('timeupdate', function() {

var rem = parseInt(player.elPlayer.duration - player.elPlayer.currentTime, 10),
Expand Down
2 changes: 1 addition & 1 deletion app/public/js/following/followingCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

app.controller('FollowingCtrl', function ($scope, $http) {
$scope.title = 'Following view';
})
});
65 changes: 0 additions & 65 deletions app/public/js/system/api.js

This file was deleted.

101 changes: 101 additions & 0 deletions app/public/js/system/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
var gui = require('nw.gui')
, uiFrame = {}
, OAuthVerification = {};

// Iframe hosting the OAuth
var elemIframe = document.getElementById('elIframe');

/**
* Responsible to enable all UI frame actions
*/
uiFrame.init = function() {
this.OpenDevTools();
this.addGUIeventHandlers();
}

uiFrame.OpenDevTools = function() {
var guiWin = gui.Window.get();
guiWin.showDevTools();
}

uiFrame.addGUIeventHandlers = function() {
// Get the current window
var guiWin = gui.Window.get()
, elCloseApp = document.getElementById('closeApp')
, elMinimizeApp = document.getElementById('minimizeApp')
, elExpandApp = document.getElementById('expandApp');

// Close App
$(elCloseApp).on('click', function() {
guiWin.close(true);
});

// Minimize App
$(elMinimizeApp).on('click', function() {
guiWin.minimize();
});

// Expand App
$(elExpandApp).on('click', function() {
guiWin.maximize()
});

}

/**
* Responsible to verify if user was verified
*/
OAuthVerification.init = function() {
var that = this;

elemIframe.onload = function() {
OAuthVerification = window.setInterval( that.verification, 1500);
}
}

OAuthVerification.verification = function() {
var iframeDocument = elemIframe.contentDocument
, elIframeBody = iframeDocument.body
, isOAuthDone = elIframeBody.getAttribute('data-isOAuth-done');

console.log('verification called');

if (isOAuthDone === 'true') {
// Expose Soundcloud API to node-webkit object window
window.SC = elemIframe.contentWindow.SC;
window.scAccessToken = window.SC.accessToken();
window.scClientId = window.SC.options.client_id;
// stop verification
window.clearInterval(OAuthVerification);

// Start the App
document.body.setAttribute('data-isVisible', 'true');
angular.bootstrap(document, ['App']);

console.log('verification done')
}
}

// Initialize all
uiFrame.init();
OAuthVerification.init();

/**
* API SOUNDCLOUD ENDPOINTS
* https://developers.soundcloud.com/docs/api/reference#me
*/

// GET /users/{id} a user
// GET /users/{id}/tracks list of tracks of the user
// GET /users/{id}/playlists list of playlists (sets) of the user
// GET /users/{id}/followings list of users who are followed by the user
// GET, PUT, DELETE /users/{id}/followings/{id} a user who is followed by the user
// GET /users/{id}/followers list of users who are following the user
// GET /users/{id}/followers/{id} user who is following the user
// GET /users/{id}/comments list of comments from this user
// GET /users/{id}/favorites list of tracks favorited by the user
// GET, PUT, DELETE /users/{id}/favorites/{id} track favorited by the user
// GET /users/{id}/groups list of joined groups
// GET, PUT, DELETE /users/{id}/web-profiles list of web profiles
// GET /me/{id}/activities list dashboard activities
// GET, POST /me/{id}/connections list of connected external profiles
Loading

0 comments on commit 9200213

Please sign in to comment.