diff --git a/index.html b/index.html index 98061ac8f..57a3c05c5 100644 --- a/index.html +++ b/index.html @@ -56,20 +56,20 @@
-
{{date.format('dddd')}}, {{date.format('LL')}}
-
{{date.format('LT')}}
+
,
+
- {{ 'traffic.time_to' | translate:traffic }} - {{traffic.duration.humanize()}} + +
- {{quote.Name}}: ${{quote.LastTradePriceOnly | number : 3}} ({{quote.Change}}%) + : $
-

{{greeting}}

+

@@ -127,7 +127,7 @@

{{greeting}}

-

{{scTrack}}

+

@@ -140,48 +140,43 @@

{{scTrack}}

-
{{dilbert.title}}
+
-
+
-
{{timer.countdown | secondsToDateTime | date:"mm:ss"}}
-
{{timer.duration | secondsToDateTime | date:"mm:ss"}}
+
+
-
-

{{ 'commands.title' | translate }}

+
+

-
{{command['text']}}
-
{{command['description']}}
+
+
Show my walking
Refreshes fitbit data.
- - We are using node , - Chrome , - and Electron . -
-
+
- Source: {{news.title}}, Last Updated: {{news.lastUpdated.format('MMM DD, h:mm a')}} + Source: , Last Updated:
- {{news.content}} +
@@ -190,7 +185,7 @@

{{ 'commands.title' | translate }}

-
+
{{'fitbit.statsFor' | translate}} {{fbDailyAverage.fullName}}
{{'fitbit.averageSteps' | translate}}: {{fbDailyAverage.averageDailySteps}}
{{'fitbit.todaysSteps' | translate}}: {{fbToday.summary.steps}}
diff --git a/js/controller.js b/js/controller.js index 3476c4626..46f87be50 100644 --- a/js/controller.js +++ b/js/controller.js @@ -259,7 +259,7 @@ }); } - if(typeof config.lastfm.key !== 'undefined' && config.lastfm.user !== 'undefined'){ + if(typeof config.lastfm !== 'undefined' && typeof config.lastfm.key !== 'undefined' && config.lastfm.user !== 'undefined'){ registerRefreshInterval(getScrobblingTrack, config.lastfm.refreshInterval || 0.6) } diff --git a/js/services/fitbit.js b/js/services/fitbit.js index edd1c5609..2c7f34c5b 100644 --- a/js/services/fitbit.js +++ b/js/services/fitbit.js @@ -1,10 +1,5 @@ (function() { 'use strict'; - - var express = require('express'); - var app = express(); - var fs = require( 'fs' ); - var Fitbit = require( 'fitbit-oauth2' ); function FitbitService($http) { @@ -56,53 +51,58 @@ var fitbit = {}; if (typeof config.fitbit != 'undefined') { fitbit = new Fitbit(config.fitbit); - } - // In a browser, http://localhost:4000/fitbit to authorize a user for the first time. - // - app.get('/fitbit', function (req, res) { - res.redirect(fitbit.authorizeURL()); - }); + var express = require('express'); + var app = express(); + var fs = require( 'fs' ); + var Fitbit = require( 'fitbit-oauth2' ); - // Callback service parsing the authorization token and asking for the access token. This - // endpoint is refered to in config.fitbit.authorization_uri.redirect_uri. See example - // config below. - // - app.get('/fitbit_auth_callback', function (req, res, next) { - var code = req.query.code; - fitbit.fetchToken( code, function(err, token) { - if (err) return next(err); + // In a browser, http://localhost:4000/fitbit to authorize a user for the first time. + // + app.get('/fitbit', function (req, res) { + res.redirect(fitbit.authorizeURL()); + }); - // persist the token - persist.write(tfile, token, function(err) { + // Callback service parsing the authorization token and asking for the access token. This + // endpoint is refered to in config.fitbit.authorization_uri.redirect_uri. See example + // config below. + // + app.get('/fitbit_auth_callback', function (req, res, next) { + var code = req.query.code; + fitbit.fetchToken( code, function(err, token) { if (err) return next(err); - res.redirect('/fb-profile'); - }); - }); - }); - // Call an API. fitbit.request() mimics nodejs request() library, automatically - // adding the required oauth2 headers. The callback is a bit different, called - // with ( err, body, token ). If token is non-null, this means a refresh has happened - // and you should persist the new token. - // - app.get( '/fb-profile', function(req, res, next) { - fitbit.request({ - uri: "https://api.fitbit.com/1/user/-/profile.json", - method: 'GET', - }, function(err, body, token) { - if (err) return next(err); - var profile = JSON.parse(body); - // if token is not null, a refesh has happened and we need to persist the new token - if (token) + // persist the token persist.write(tfile, token, function(err) { if (err) return next(err); - res.send('
' + JSON.stringify(profile, null, 2) + '
'); + res.redirect('/fb-profile'); }); - else - res.send('
' + JSON.stringify(profile, null, 2) + '
'); + }); + }); + + // Call an API. fitbit.request() mimics nodejs request() library, automatically + // adding the required oauth2 headers. The callback is a bit different, called + // with ( err, body, token ). If token is non-null, this means a refresh has happened + // and you should persist the new token. + // + app.get( '/fb-profile', function(req, res, next) { + fitbit.request({ + uri: "https://api.fitbit.com/1/user/-/profile.json", + method: 'GET', + }, function(err, body, token) { + if (err) return next(err); + var profile = JSON.parse(body); + // if token is not null, a refesh has happened and we need to persist the new token + if (token) + persist.write(tfile, token, function(err) { + if (err) return next(err); + res.send('
' + JSON.stringify(profile, null, 2) + '
'); + }); + else + res.send('
' + JSON.stringify(profile, null, 2) + '
'); + }); }); - }); + } // Only start up express and enable the fitbit service to start making API calls if the fitbit config is present in config.js. if (typeof config.fitbit != 'undefined') { diff --git a/main.js b/main.js index fc990baf0..c79e3e659 100644 --- a/main.js +++ b/main.js @@ -11,6 +11,9 @@ const BrowserWindow = electron.BrowserWindow const powerSaveBlocker = electron.powerSaveBlocker powerSaveBlocker.start('prevent-display-sleep') +// Launching the mirror in dev mode +const DevelopmentMode = process.argv[2] == "dev"; + // Load the smart mirror config var config; try{ @@ -59,7 +62,7 @@ function createWindow () { mainWindow.loadURL('file://' + __dirname + '/index.html') // Open the DevTools if run with "npm start dev" - if(process.argv[2] == "dev"){ + if(DevelopmentMode){ mainWindow.webContents.openDevTools(); }