Some fixes for nearby, using fetch instead of request in some places

This commit is contained in:
Martin Donnelly 2019-04-01 15:53:19 +01:00
parent d3f09bbf2f
commit 5ff3fc6a34
15 changed files with 1362 additions and 1038 deletions

2051
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,71 +12,72 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"apicache": "^1.2.1", "apicache": "^1.2.3",
"backbone": "^1.3.3", "backbone": "^1.3.3",
"browserify": "^16.2.3", "browserify": "^16.2.3",
"cheerio": "^1.0.0-rc.2", "cheerio": "^1.0.0-rc.2",
"dark-sky-api": "^0.6.3", "dark-sky-api": "^0.6.32",
"dateformat": "^3.0.3", "dateformat": "^3.0.3",
"debug-logger": "^0.4.1", "debug-logger": "^0.4.1",
"del": "^3.0.0",
"elapsed": "0.0.7", "elapsed": "0.0.7",
"eslint": "^4.19.0", "eslint": "^4.19.1",
"express": "^4.16.3", "express": "^4.16.4",
"fecha": "^2.3.3", "fecha": "^2.3.3",
"feedme": "^1.2.0", "feedme": "^1.2.0",
"geolocation": "^0.2.0", "geolocation": "^0.2.0",
"gulp-autoprefixer": "^4.1.0", "gulp-autoprefixer": "^4.1.0",
"gulp-bump": "^3.1.0", "gulp-bump": "^3.1.3",
"gulp-cache": "^1.0.2", "gulp-cache": "^1.1.1",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2", "gulp-cssnano": "^2.1.3",
"gulp-html-replace": "^1.6.2", "gulp-html-replace": "^1.6.2",
"gulp-htmlmin": "^4.0.0", "gulp-htmlmin": "^4.0.0",
"gulp-inject": "^4.3.0", "gulp-inject": "^4.3.2",
"gulp-uglify": "^3.0.0", "gulp-uglify": "^3.0.1",
"hh-mm-ss": "^1.2.0", "hh-mm-ss": "^1.2.0",
"humanize-duration": "^3.13.0", "humanize-duration": "^3.17.0",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"jsonfile": "^5.0.0", "jsonfile": "^5.0.0",
"leaflet": "^1.3.1", "leaflet": "^1.4.0",
"lodash": "^4.17.5", "lodash": "^4.17.11",
"log4js": "^2.5.3", "log4js": "^2.11.0",
"log4js-node-mongodb": "^2.2.1", "log4js-node-mongodb": "^2.2.1",
"loggy": "^1.0.2", "loggy": "^1.0.4",
"memory-cache": "^0.2.0", "memory-cache": "^0.2.0",
"moment": "^2.21.0", "moment": "^2.24.0",
"muicss": "^0.9.38", "muicss": "^0.9.41",
"node-foursquare-venues": "^1.1.0", "node-foursquare-venues": "^1.1.0",
"openweather-apis": "^3.3.5", "openweather-apis": "^3.3.5",
"request-json": "^0.6.3", "request-json": "^0.6.4",
"request-promise-native": "^1.0.5", "request-promise-native": "^1.0.5",
"strict-uri-encode": "^2.0.0", "strict-uri-encode": "^2.0.0",
"string": "^3.3.3", "string": "^3.3.3",
"sugar": "^2.0.4", "sugar": "^2.0.6",
"twitter": "^1.7.1", "twitter": "^1.7.1",
"uglifyify": "^4.0.5", "uglifyify": "^4.0.5",
"underscore": "^1.9.0", "underscore": "^1.9.1",
"winston": "^2.4.1", "winston": "^2.4.4",
"winston-mongodb": "^4.0.0-rc1", "winston-mongodb": "^4.0.3",
"yelp-fusion": "^2.0.3" "yelp-fusion": "^2.2.1"
}, },
"devDependencies": { "devDependencies": {
"expect.js": "^0.3.1", "expect.js": "^0.3.1",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-google-webfonts": "0.0.14", "gulp-google-webfonts": "0.0.14",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.4.0",
"gulp-sass": "^3.1.0", "gulp-sass": "^3.2.1",
"gulp-scss": "^1.4.0", "gulp-scss": "^1.4.0",
"gulp-sourcemaps": "^2.6.4", "gulp-sourcemaps": "^2.6.4",
"gulp-strip-debug": "^2.0.0", "gulp-strip-debug": "^2.0.0",
"gulp-uglify-es": "^1.0.1", "gulp-uglify-es": "^1.0.4",
"lodash.assign": "^4.2.0", "lodash.assign": "^4.2.0",
"mocha": "^5.0.4", "mocha": "^5.2.0",
"node-fetch": "^2.1.1", "node-fetch": "^2.3.0",
"node-geocoder": "^3.22.0", "node-geocoder": "^3.22.0",
"require-dir": "^1.0.0", "require-dir": "^1.2.0",
"requirejs": "^2.3.5", "requirejs": "^2.3.6",
"sinon": "^4.4.6", "sinon": "^4.5.0",
"tape": "^4.9.2", "tape": "^4.9.2",
"tape-promise": "^4.0.0", "tape-promise": "^4.0.0",
"vinyl-buffer": "^1.0.1", "vinyl-buffer": "^1.0.1",

View File

@ -116,6 +116,8 @@ function doGetArticle(guid = '') {
const output = reduceArticle(body); const output = reduceArticle(body);
logger.debug(JSON.stringify(output));
return resolve(output); return resolve(output);
}, function(error, response, body) { }, function(error, response, body) {
if (response.statusCode !== 200) { if (response.statusCode !== 200) {

View File

@ -68,23 +68,24 @@ function toCompass(degrees) {
function moonCalc(moonPhase) { function moonCalc(moonPhase) {
let output = ''; let output = '';
if (moonPhase === 0.0) if (moonPhase === 0.0)
output = 'New moon'; output = '🌕 New moon';
else if (moonPhase >= 0.1 && moonPhase < 0.25) else if (moonPhase >= 0.1 && moonPhase < 0.25)
output = 'waxing crescent'; output = '🌔 waxing crescent';
else if (moonPhase === 0.25) else if (moonPhase === 0.25)
output = 'First Quarter'; output = '🌓 First Quarter';
else if (moonPhase > 0.25 && moonPhase < 0.5) else if (moonPhase > 0.25 && moonPhase < 0.5)
output = 'waxing gibbous'; output = '🌒 waxing gibbous';
else if (moonPhase === 0.5) else if (moonPhase === 0.5)
output = 'Full moon'; output = '🌑 Full moon';
else if (moonPhase > 0.5 && moonPhase < 0.75) else if (moonPhase > 0.5 && moonPhase < 0.75)
output = 'Waning gibbous'; output = '🌘 Waning gibbous';
else if (moonPhase === 0.5) else if (moonPhase === 0.5)
output = 'Third quarter'; output = '🌗 Third quarter';
else if (moonPhase > 0.75) else if (moonPhase > 0.75)
output = 'Waning crescent'; output = '🌖 Waning crescent';
return output; return output;
// ['🌑', '🌘', '🌗', '🌖', '🌕', '🌔', '🌓', '🌒']
// a value of 0 corresponds to a new moon, 0.25 to a first quarter moon, 0.5 to a full moon, and 0.75 to a last quarter moon. (The ranges // a value of 0 corresponds to a new moon, 0.25 to a first quarter moon, 0.5 to a full moon, and 0.75 to a last quarter moon. (The ranges
// in between these represent waxing crescent, waxing gibbous, waning gibbous, and waning crescent moons, respectively.) // in between these represent waxing crescent, waxing gibbous, waning gibbous, and waning crescent moons, respectively.)
} }

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
const CACHE_VERSION = { 'version': '0.0.998' }; const CACHE_VERSION = { 'version': '0.0.1049' };
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`; const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
const RUNTIME = 'runtime'; const RUNTIME = 'runtime';

117
src/v1/index-orig.html Normal file
View File

@ -0,0 +1,117 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jubilee</title>
<link href="//cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.css" rel="stylesheet" type="text/css"/>
<link href="/fonts/fonts.css" rel="stylesheet" type="text/css"/>
<link href="/fonts/fujicons.css" rel="stylesheet" type="text/css"/>
<link href="/css/mui.custom.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/img/safari-pinned-tab.svg" color="#5bbad5">
<meta name="apple-mobile-web-app-title" content="Train Times">
<meta name="application-name" content="Sidekick">
<meta name="theme-color" content="#ffff00">
<script src="//cdn.layerjs.org/libs/layerjs/layerjs-0.6.1.min.js"></script>
<link href="//cdn.layerjs.org/libs/layerjs/layerjs-0.6.1.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div data-lj-type="stage">
<div data-lj-type="layer" data-lj-default-frame="main" >
<div data-lj-type="frame" >
… your HTML code …
</div>
</div>
</div>
<div class="appPanel" data-id="main">
<div class="mui-container">
<div id="greet"></div>
<div id="location" class="mui-row" style="display: none;"></div>
</div>
<div class="mui-container" id="connectionStatus" style="display:none;">
<div class="mui--text-center"><i class="large fa fa-globe mui--align-middle mui--text-center"
style="color:grey;"></i></div>
<div class="mui--text-body1 mui--text-center">No internet connection</div>
</div>
<div class="mui-container" id="viewFrame">
<div id="weatherAlertShell" class="mui-panel" style="display: none;">
<div id="weatherAlertTitle" class="mui--text-title cardTitle">Weather Alert</div>
<div id="weatherAlert"></div>
</div>
<div id="bymeShell" class="mui-panel" style="display: none;">
<div id="byMeTitle" class="mui--text-title cardTitle">By me</div>
<div id="byme"></div>
</div>
<div id="trafficShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Traffic</div>
<div id="traffic"></div>
</div>
<div id="agendaShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Upcoming events</div>
<div id="agenda"></div>
</div>
<div id="nearbyShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Around me</div>
<div id="nearby"></div>
</div>
<div id="nearbyShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Nearby places</div>
<div id="nearbyPlaces"></div>
</div>
<div id="newsShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Latest news</div>
<div id="news" class="scrolling-wrapper-flexbox"></div>
<div id='newsMore' class="cardLink">
<i class="seemore fa fa-forward mui--align-middle " ></i> <span class="seemore mui--align-middle">More news</span>
</div>
</div>
<div id="weatherShell" class="mui-panel" style="display: none;">
<div class="mui--text-title cardTitle">Weather</div>
<div id="weather"></div>
</div>
</div>
</div>
<script src="js/vendor.js" async></script>
<script type='module' src="js/bundle.js" async></script>
<script async="" src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
<noscript>
<!-- anchor linking to external file -->
<h1>Javascript disabled</h1>
<p>This really requires javascript to work</p>
</noscript>
</body>
</html>

View File

@ -21,12 +21,27 @@
<link rel="mask-icon" href="/img/safari-pinned-tab.svg" color="#5bbad5"> <link rel="mask-icon" href="/img/safari-pinned-tab.svg" color="#5bbad5">
<meta name="apple-mobile-web-app-title" content="Train Times"> <meta name="apple-mobile-web-app-title" content="Train Times">
<meta name="application-name" content="Sidekick"> <meta name="application-name" content="Sidekick">
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffff00">
<!-- <script src="//cdn.layerjs.org/libs/layerjs/layerjs-0.6.1.min.js"></script>
<link href="//cdn.layerjs.org/libs/layerjs/layerjs-0.6.1.css" type="text/css" rel="stylesheet" />-->
</head> </head>
<body> <body>
<!--
<div data-lj-type="stage">
<div data-lj-type="layer" data-lj-default-frame="main" >
<div data-lj-type="frame" >
… your HTML code …
</div>
</div>
</div>
-->
<div class="appPanel" data-id="main"> <div class="appPanel" data-id="main">
<div class="mui-container"> <div class="mui-container">
<div id="greet"></div> <div id="greet"></div>

View File

@ -1,9 +1,7 @@
const $ = require('jquery'); const $ = require('jquery');
const _ = require('underscore'); const _ = require('underscore');
const Backbone = require('backbone'); const Backbone = require('backbone');
const request = require('request');
const { get } = require('lodash');
// const { reduceNearby } = require('./libs/reducers');
const { toHour, hourFloor } = require('./libs/utils'); const { toHour, hourFloor } = require('./libs/utils');
const TimeFormat = require('hh-mm-ss'); const TimeFormat = require('hh-mm-ss');
const fecha = require('fecha'); const fecha = require('fecha');
@ -66,24 +64,27 @@ const AgendaModel = Backbone.Model.extend({
'getAgenda': function() { 'getAgenda': function() {
const time = new Date().getTime() ; const time = new Date().getTime() ;
console.log('>> agenda this', this);
const lastUpdate = time - (this.get('time') || 0); const lastUpdate = time - (this.get('time') || 0);
console.log(`>> Agenda last fetch: ${TimeFormat.fromMs(lastUpdate, 'hh:mm')} ago`); console.log(`>> Agenda last fetch: ${TimeFormat.fromMs(lastUpdate, 'hh:mm')} ago`);
if (lastUpdate > 120000) if (lastUpdate > 120000) {
request({ const _url = new URL(`${window.loc}/agenda`);
'url': `${window.loc}/agenda`,
'method': 'GET', _url.search = new URLSearchParams({
'qs': { 'w' : hourFloor()
'w' : hourFloor() });
}
}, function(err, res, body) { console.log(_url);
if (err)
console.error(err); fetch(_url)
else { .then((res) => {
console.log('statusCode', res.statusCode); return res.json();
})
.then((agendaJSON) => {
const now = new Date().getTime(); const now = new Date().getTime();
const agendaJSON = JSON.parse(body);
const newAgenda = []; const newAgenda = [];
// console.log('>> agendaJSON', agendaJSON); // console.log('>> agendaJSON', agendaJSON);
@ -94,20 +95,27 @@ const AgendaModel = Backbone.Model.extend({
if (dend > now) { if (dend > now) {
// console.log('>> agenda', item); // console.log('>> agenda', item);
const timeStart = fecha.format(new Date(item.dtstart), 'shortTime'); item.timeStart = fecha.format(new Date(item.dtstart), 'shortTime');
item.timeStart = timeStart;
newAgenda.push(item); newAgenda.push(item);
} }
// console.log(dend); // console.log(dend);
} }
this.agendaCollection.reset(newAgenda); this.agendaCollection.reset(newAgenda);
this.logUpdate(); const time = new Date().getTime() ;
}
}.bind(this)); this.set('time', time);
}, 'logUpdate': function() { })
.catch((e) => {
console.error(e);
});
}
}, 'logUpdate': () => {
console.log('>> Agenda logging:'); console.log('>> Agenda logging:');
console.log('>> agend log update', this);
const time = new Date().getTime() ; const time = new Date().getTime() ;
this.set('time', time); this.set('time', time);
@ -128,6 +136,8 @@ const AgendaView = Backbone.View.extend({
const now = new Date().getTime(); const now = new Date().getTime();
const since = now - this.model.get('time'); const since = now - this.model.get('time');
console.log('> t', now, this.model.get('time'));
console.log(`Agenda was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`); console.log(`Agenda was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`);
if (since > (60 * 1000 * 60) ) if (since > (60 * 1000 * 60) )

View File

@ -123,11 +123,11 @@ const LocationModel = Backbone.Model.extend({
const updatelocationthrottled = _.throttle(updateLocation, 120000); const updatelocationthrottled = _.throttle(updateLocation, 120000);
const updateMotionhrottled = _.throttle(updateMotion, 15000); const updateMotionhrottled = _.throttle(updateMotion, 15000);
geolocation.on('change', function (position) { geolocation.on('change', _.throttle(function (position) {
console.log('Location update'); console.log('Location update');
updatelocationthrottled(position); updatelocationthrottled(position);
updateMotionhrottled(position); updateMotionhrottled(position);
}.bind(this)); }.bind(this), 15000));
this.watcher = geolocation.createWatcher(); this.watcher = geolocation.createWatcher();

View File

@ -1,7 +1,6 @@
const $ = require('jquery'); const $ = require('jquery');
const _ = require('underscore'); const _ = require('underscore');
const Backbone = require('backbone'); const Backbone = require('backbone');
const request = require('request');
const { get } = require('lodash'); const { get } = require('lodash');
const { reduceNearby } = require('./libs/reducers'); const { reduceNearby } = require('./libs/reducers');
const { createPanel, addPanel } = require('./libs/panel'); const { createPanel, addPanel } = require('./libs/panel');
@ -23,12 +22,16 @@ const NearbyListModel = Backbone.Model.extend({
this.listenTo(this, 'change:section change:query', this.onChangeSection); this.listenTo(this, 'change:section change:query', this.onChangeSection);
}, },
'onChange': function() { 'onChange': function() {
console.log('NearbyList::onChange');
console.log(this);
this.getNearby(); this.getNearby();
}, },
'onChangeSection': function() { 'onChangeSection': function() {
console.log('NearbyList::onChangeSection');
console.log(this);
this.getNearby(true); this.getNearby(true);
}, },
'getNearby': function(force = false) { 'getNearby': _.throttle(function(force = false) {
const llFixed = this.get('llFixed'); const llFixed = this.get('llFixed');
const hour = parseInt((new Date()).getHours().toString(), 10); const hour = parseInt((new Date()).getHours().toString(), 10);
@ -41,38 +44,44 @@ const NearbyListModel = Backbone.Model.extend({
console.log('>> Nearby section:', hour, section); console.log('>> Nearby section:', hour, section);
console.info('>> Nearby:request'); console.info('>> Nearby:request');
console.log(`>> Nearby last fetch: ${TimeFormat.fromMs(lastUpdate, 'hh:mm')} ago`); console.log(`>> Nearby last fetch: ${lastUpdate} ago`);
// this.fsCollection.reset( null, { 'silent':true }); // this.fsCollection.reset( null, { 'silent':true });
if (lastUpdate > 120000 || force) if (lastUpdate > 120000 || force) {
request({ const _url = new URL(`${window.loc}/fsexplore`);
'url': `${window.loc}/fsexplore`,
'method': 'GET', _url.search = new URLSearchParams({
'qs': { 'll': llFixed,
'll': llFixed, 'section': section,
'section': section, 'query':query,
'query':query, 'limit': limit
'limit': limit });
}
}, function(err, res, body) { console.log(_url);
if (err)
console.error(err); fetch(_url)
else { .then((res) => {
console.log('statusCode', res.statusCode); return res.json();
const fsJSON = JSON.parse(body); })
.then((fsJSON) => {
const groups = get(fsJSON, 'response.groups'); const groups = get(fsJSON, 'response.groups');
const items = groups[0].items; const items = groups[0].items;
const newItems = []; const newItems = [];
this.set('totalResults', get(fsJSON, 'response.totalResults')); this.set('totalResults', get(fsJSON, 'response.totalResults'));
this.set('fullLocation', get(fsJSON, 'response.headerFullLocation'));
for(const item of items) for(const item of items)
newItems.push(reduceNearby(item)); newItems.push(reduceNearby(item));
this.fsCollection.reset(newItems); this.fsCollection.reset(newItems);
this.logUpdate(); this.logUpdate();
} })
}.bind(this)); .catch((e) => {
}, 'logUpdate': function() { console.error(e);
});
}
}, 9000), 'logUpdate': function() {
console.log('NearyList logging:'); console.log('NearyList logging:');
const time = new Date().getTime() ; const time = new Date().getTime() ;
@ -147,6 +156,13 @@ const NearbyListView = Backbone.View.extend({
const totalResults = this.model.get('totalResults'); const totalResults = this.model.get('totalResults');
console.log('>> totalResults', totalResults); console.log('>> totalResults', totalResults);
this.$el.empty(); this.$el.empty();
const fullLocation = this.model.get('fullLocation');
console.log('nearby::fullLocation', fullLocation);
this.$el.append(`<div class="mui--text-subhead mui--text-accent">Near ${fullLocation}</div>`);
this.model.fsCollection.each(function(item) { this.model.fsCollection.each(function(item) {
const fsView = new FSItemView({ 'model': item }); const fsView = new FSItemView({ 'model': item });
this.$el.append(fsView.el); this.$el.append(fsView.el);

View File

@ -57,7 +57,7 @@ const NewsListModel = Backbone.Model.extend({
this.getNews(); this.getNews();
}, },
'getNews': function() { 'getNews': function() {
console.info('>> News:request'); console.info('>> NewsList:request');
request({ request({
'url': `${window.loc}/news`, 'url': `${window.loc}/news`,
'method': 'GET', 'qs': { 'method': 'GET', 'qs': {

View File

@ -104,7 +104,7 @@ const VenueDetailView = Backbone.View.extend({
contents.push(templates.map()); contents.push(templates.map());
contents.push(templates.venueDirections()); contents.push(templates.venueDirections(m));
contents.push(templates.venueDescription(m)); contents.push(templates.venueDescription(m));

View File

@ -15,7 +15,7 @@ const FSItemView = Backbone.View.extend({
'tagName': 'div', 'tagName': 'div',
'className': 'itemRow mui--align-middle', 'className': 'itemRow mui--align-middle',
'template': _.template(` 'template': _.template(`
<img class='mui--align-middle' src="<%= icon %>" width="32px" height="32px" style="-webkit-filter: invert(100%);"/><span class="mui--text-dark mui--text-subhead"><%= name %></span> <span class="mui--text-caption mui--text-dark-secondary"><%= category %></span> `), <img class='mui--align-middle' src="<%= icon %>" width="32px" height="32px" style="-webkit-filter: invert(100%);"/><span class="mui--text-dark mui--text-subhead"><%= name %></span> <span class="mui--text-caption mui--text-dark-secondary">(<%= distance %>km)</span> <span class="mui--text-caption mui--text-dark-secondary"><%= category %></span> `),
'initialize': function() { 'initialize': function() {
this.render(); this.render();
}, },

View File

@ -90,6 +90,8 @@ const reduceNearby = function(item) {
obj.category = get(categories[0], 'name', ''); obj.category = get(categories[0], 'name', '');
obj.icon = `${get(categories[0], 'icon.prefix', '')}32${get(categories[0], 'icon.suffix', '')}`; obj.icon = `${get(categories[0], 'icon.prefix', '')}32${get(categories[0], 'icon.suffix', '')}`;
obj.distance = (get(item, 'venue.location.distance', 0) / 1000).toFixed(2);
return obj; return obj;
}; };

View File

@ -63,7 +63,7 @@ const templates = {
<div class="mui--text-body1" ><%=description %></div> <div class="mui--text-body1" ><%=description %></div>
`), `),
'venueDirections' : _.template(` 'venueDirections' : _.template(`
<div class="mui--text-subhead mui--text-center separate" style="" id="getDirections"><p><i class="fa fa-sm fa-map-marker mui--align-middle " ></i></p><p>Directions</p></div> <div class="mui--text-subhead mui--text-center separate" style="" id="getDirections"><p><i class="fa fa-sm fa-map-marker mui--align-middle " ></i><%=address%></p><p>Directions</p></div>
`), `),
'openInFS' : _.template(` 'openInFS' : _.template(`
<div style="margin-bottom:50px"><a href="<%=url%>">Open in Foursquare</a></div> <div style="margin-bottom:50px"><a href="<%=url%>">Open in Foursquare</a></div>
@ -134,6 +134,9 @@ const templates = {
</div> </div>
<h3>Sun & Moon</h3> <h3>Sun & Moon</h3>
<div class="mui-row">
<div class="mui-col-xs-3 mui--text-left mui--text-title"><%=moonphase %></div>
</div>
<div class="mui-row"> <div class="mui-row">
<div class="mui-col-xs-3 mui--text-left mui--text-body2">Sunrise</div> <div class="mui-col-xs-3 mui--text-left mui--text-body2">Sunrise</div>
<div class="mui-col-xs-3 mui--text-right mui--text-title"><%=sunriseTime %></div> <div class="mui-col-xs-3 mui--text-right mui--text-title"><%=sunriseTime %></div>