Skip to content

Commit

Permalink
update to .24 level
Browse files Browse the repository at this point in the history
  • Loading branch information
sdetweil committed Sep 23, 2019
2 parents 71b0270 + e06c4e6 commit e70a77e
Show file tree
Hide file tree
Showing 17 changed files with 539 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/remote/jsonform/*
*.min.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ speech/snowboydetect.pyc
.vscode
keyfile.json
smart-mirror.log
jsonform
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
language: node_js
node_js:
- "6"
- "10"

before_install:
- npm i -g npm

# Cache node dependencies
cache:
directories:
- node_modules
- bower_components
- bower_components
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<p align="center">
<a href="https://discord.gg/EMb4ynW"><img src="https://discordapp.com/api/guilds/258802311298547713/widget.png" alt="Discord Chat"/></a>
<a href="https://waffle.io/evancohen/smart-mirror"><img src="https://img.shields.io/waffle/label/evancohen/smart-mirror/status%3A%20in%20progress.svg?label=in%20progress" alt="Stories in progress" /></a>
<a href='https://travis-ci.org/evancohen/smart-mirror'><img src='https://travis-ci.org/evancohen/smart-mirror.svg?branch=master' alt='Build Status'/></a>
</p>
<p align="center">
Expand Down
60 changes: 60 additions & 0 deletions app/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,67 @@ ul.calendar {
filter: grayscale(100%);
*/}

.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.top-right div div div .spotify-info {
float: left;
text-align: right;
margin-right: 15px;
}

.bottom-left div div div .spotify-info {
text-align: left;
margin-left: 15px;
}

.bottom-left div div div {
display: flex;
}

.spotify-container {
margin: auto;
-webkit-filter: grayscale(70%);
filter: grayscale(70%);
font-family: bold;
}

.pull-right {
float: right;
}

.pull-left {
float: left;
}

.spotify-info {
margin-top: -2px;
font-family: 'Open Sans', sans-serif;
}

.spotify-status-indicator i {
margin-top: 5px;
}

.spotify-info .em-85 {
font-size: 0.85em;
}

.spotify-track, .spotify-artist, .spotify-device {
margin: auto;
}

.spotify-art {
border: 3px solid white;
}

.sc-container {
display: flex;
padding: 10px;
margin: auto;
-webkit-filter: grayscale(70%);
filter: grayscale(70%);
Expand Down
35 changes: 35 additions & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@
"voice": "resume (the) timer",
"description": "Resume timer."
},
"spotify_play": {
"text": "play ________ on Spotify",
"voice": "(tell) spotify (to) play (*query)",
"description": "Resume/Play song on Spotify."
},
"spotify_pause": {
"text": "pause ________ spotify",
"voice": "(tell) spotify (to) pause (playback)",
"description": "Pause current song on Spotify."
},
"spotify_forward": {
"text": "play next song on spotify",
"voice": "(tell) spotify (to) (skip) (goto) next (song on) (song)",
"description": "Play next song on Spotify."
},
"spotify_back": {
"text": "play previous song on spotify",
"voice": "(tell) spotify (to) (skip) (goto) previous (song on) (song)",
"description": "Play previous song on Spotify."
},
"spotify_shuffle": {
"text": "shuffle music",
"voice": "(tell) spotify (to) (turn on) (turn off) shuffle (songs)",
"description": "Toggle shuffle on Spotify."
},
"spotify_repeat": {
"text": "shuffle music",
"voice": "(tell) spotify (to) (turn on) (turn off) repeat (song)",
"description": "Toggle repeat on Spotify."
},
"spotify_transfer": {
"text": "transfer playback to my ________",
"voice": "(tell) spotify (to) (transfer) (send) (move) to *query",
"description": "Transfer playback to a device by the name of ..."
},
"sc_play": {
"text": "SoundCloud play ________",
"voice": "SoundCloud play *query",
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<!-- Styles and Resources -->
<link rel="shortcut icon" href="favicon.ico" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,800,700' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" ng-href="app/css/{{ layoutName }}.css" />
<!-- bower:css -->
<!-- endbower -->
Expand Down
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ const BrowserWindow = electron.BrowserWindow
// Prevent the monitor from going to sleep.
const powerSaveBlocker = electron.powerSaveBlocker
powerSaveBlocker.start("prevent-display-sleep")
<<<<<<< HEAD
// process the plugin location info
const loader = require('./app/js/loader.js')
=======
>>>>>>> e06c4e65ff2f55f1a68c6590ee597db454e85574

// Launching the mirror in dev mode
const DevelopmentMode = process.argv.includes("dev")
Expand Down Expand Up @@ -44,7 +47,8 @@ try {
let mainWindow

function createWindow() {

app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
app.commandLine.appendSwitch('disable-http-cache');
// Get the displays and render the mirror on a secondary screen if it exists
var atomScreen = electron.screen
var displays = atomScreen.getAllDisplays()
Expand All @@ -56,7 +60,7 @@ function createWindow() {
}
}

var browserWindowOptions = { width: 800, height: 600, icon: "favicon.ico", kiosk: true, autoHideMenuBar: true, darkTheme: true }
var browserWindowOptions = { width: 800, height: 600, icon: "favicon.ico", kiosk: !DevelopmentMode, autoHideMenuBar: true, darkTheme: true }
if (externalDisplay) {
browserWindowOptions.x = externalDisplay.bounds.x + 50
browserWindowOptions.y = externalDisplay.bounds.y + 50
Expand Down
9 changes: 6 additions & 3 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smart-mirror",
"version": "0.0.22",
"version": "0.0.24",
"description": "The fairest of them all",
"main": "main.js",
"scripts": {
Expand All @@ -13,7 +13,8 @@
"update": "git pull && npm install",
"wiredep": "wiredep -s index.html",
"test": "eslint . --ignore-path .gitignore",
"test-fix": "eslint . --ignore-path .gitignore --fix"
"test-fix": "eslint . --ignore-path .gitignore --fix",
"postinstall":"bash scripts/copyjsonform"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,15 +44,17 @@
"alphavantage": "^1.2.0",
"angular-moment": "^1.0.1",
"annyang": "^2.6.0",
"cheerio": "^1.0.0-rc.3",
"cheerio": "^1.0.0-rc.3",
"electron-json-storage": "2.0.0",
"express": "^4.14.0",
"fitbit-oauth2": "0.0.1",
"humanize-duration": "^3.10.1",
"hyperion-client": "1.0.3",
"jsonform": "git://github.com/jsonform/jsonform.git",
"moment": "^2.17.1",
"rss-parser": "^3.6.3",
"socket.io": "^1.6.0",
"spotify-web-api-node": "^2.5.0",
"sonus": "^1.0.1"
},
"eslintConfig": {
Expand Down
86 changes: 86 additions & 0 deletions plugins/spotify/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"schema": {
"spotify": {
"type": "object",
"title": "Spotify Settings",
"properties": {
"timeout": {
"type": "number",
"title": "Default time in seconds to refresh spotify data",
"default":10000
},
"default_device": {
"type": "string",
"title": "Default device name to change playback route on request",
"default": "raspberry"
},
"position": {
"type": "string",
"title": "Default status indicator position ('top' or 'bottom')",
"default": "top"
},
"creds": {
"type": "object",
"properties": {
"clientID": {
"default": "",
"type": "string",
"title": "OAuth 2.0 Client ID"
},
"clientSecret": {
"default": "",
"type": "string",
"title": "Client Secret"
}
}
},
"authorization_uri": {
"type": "object",
"properties": {
"scope": {
"default": "user-read-private user-read-email streaming user-read-currently-playing user-modify-playback-state user-read-playback-state",
"type": "string",
"title": "Scope"
},
"state": {
"default": "3(#0/!~",
"type": "string",
"title": "State"
}
}
}
}
}
},
"form":[
{
"type":"fieldset",
"title":"Spotify Settings",
"expandable":true,
"order":0,
"items": [
"spotify.creds",
"spotify.authorization_uri",
{
"type": "help",
"helpvalue": "<p><b>Ensure the spotify API settings allow redirects from 'http://localhost:4000/spotify_auth_callback'</b> then navigate to <a href='http://localhost:4000/authorize_spotify/' target='_blank'>Authorize</a> from your mirror browser.</p>"
},
"spotify.timeout",
"spotify.default_device",
"spotify.position"
]
}
],
"value":{
"spotify":{
"timeout": 10000,
"default_device": "raspberry",
"position": "top",
"authorization_uri": {
"response_type": "code",
"scope": "activity nutrition profile settings sleep social weight heartrate",
"state": "3(#0/!~"
}
}
}
}
69 changes: 69 additions & 0 deletions plugins/spotify/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function Spotify($scope, $http, SpotifyService, SpeechService, Focus, $interval) {

SpotifyService.init(function () {
refreshAuth();
addVoiceControl();
currentStateInfo();
$interval(refreshAuth, 60000 * 30); // minutes
$interval(currentStateInfo, 1000 * config.spotify.timeout); // seconds
});

var refreshAuth = function () {
SpotifyService.refreshToken();
};

var currentStateInfo = function () {
SpotifyService.currentState().then(function (response) {
if (response) {
$scope.spDevice = response.device.name || 'unknown';
$scope.spTrack = response.item.name;
$scope.spArtist = response.item.artists[0].name;
$scope.spPlaying = response.is_playing || false;
$scope.spRepeat = response.repeat_state;
$scope.spShuffle = response.shuffle_state;
$scope.spThumb = response.item.album.images[0].url || 'http://i.imgur.com/8Jqd33w.jpg?1';

$scope.spActive = true;
} else {
$scope.spActive = false;
}

// console.debug("current state:", response, $scope);
});
};

var addVoiceControl = function() {
SpeechService.addCommand('spotify_play', function (query) {
SpotifyService.playTrack(query);
});

SpeechService.addCommand('spotify_pause', function () {
SpotifyService.pause();
});

SpeechService.addCommand('spotify_forward', function () {
SpotifyService.skipNext();
});

SpeechService.addCommand('spotify_back', function () {
SpotifyService.skipBack();
});

SpeechService.addCommand('spotify_repeat', function () {
var state = ($scope.spRepeat === 'track')? 'off': 'track';
SpotifyService.toggleRepeat(state);
});

SpeechService.addCommand('spotify_shuffle', function () {
var state = ($scope.spShuffle)? false: true;
SpotifyService.toggleShuffle(state);
});

SpeechService.addCommand('spotify_transfer', function (name) {
SpotifyService.sendToDevice(name);
});
};
}

angular.module('SmartMirror')
.controller('Spotify', Spotify);
16 changes: 16 additions & 0 deletions plugins/spotify/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div ng-controller="Spotify" ng-show="spActive">
<div class="spotify-container animate-grow">
<img class="spotify-art" ng-src="{{spThumb}}" width="96" height="96"/>
<span class="spotify-info">
<h2 class="spotify-track truncate" ng-bind="spTrack"></h2>
<h3 class="spotify-artist truncate em-85" ng-bind="spArtist"></h3>
<h3 class="spotify-device truncate em-85" ng-bind="spDevice"></h3>
<span class="spotify-status-indicator">
<i ng-show="spPlaying" class="material-icons">play_circle_outline</i>
<i ng-hide="spPlaying" class="material-icons">pause_circle_outline</i>
<i ng-show="spShuffle" class="material-icons">shuffle</i>
<i ng-show="spRepeat === 'track'" class="material-icons">repeat</i>
</span>
</span>
</div>
</div>
Loading

0 comments on commit e70a77e

Please sign in to comment.