Compare commits
3 Commits
developmen
...
making-it-
Author | SHA1 | Date | |
---|---|---|---|
|
d994268317 | ||
|
ae314b0c2c | ||
|
728ed04317 |
25
Docker/dev/Dockerfile
Normal file
25
Docker/dev/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
FROM git.caliban.io/martin/node-python:8
|
||||
#FROM martind2000/node-python3:18
|
||||
ARG VERSION
|
||||
ENV VERSION ${VERSION:-development}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./Docker/start.sh ./package*.json ./server.js ./gulpfile.js ./mongo.yml ./ecosystem.json /app/
|
||||
|
||||
RUN mkdir -p /app/src /app/fonts /app/gulp /app/server /app/tools
|
||||
|
||||
# COPY ./src /app/src
|
||||
|
||||
# COPY ./types /app/types
|
||||
|
||||
RUN set -x \
|
||||
&& npm install \
|
||||
&& npm install -g gulp pm2
|
||||
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
EXPOSE 8110
|
||||
|
||||
|
||||
ENTRYPOINT ["/app/start.sh"]
|
9
Docker/start.sh
Normal file
9
Docker/start.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
# npm run dev
|
||||
|
||||
# npm run start
|
||||
|
||||
|
||||
while true; do sleep infinity; done
|
26
docker-compose.yml
Normal file
26
docker-compose.yml
Normal file
@ -0,0 +1,26 @@
|
||||
version: '3.5'
|
||||
|
||||
services:
|
||||
jubilee-src:
|
||||
container_name: jubilee-src
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Docker/dev/Dockerfile
|
||||
image: jubilee-src
|
||||
logging:
|
||||
options:
|
||||
max-size: '1m'
|
||||
max-file: '5'
|
||||
# restart: always
|
||||
# env_file:
|
||||
# - .env
|
||||
|
||||
ports:
|
||||
- '9110:8110'
|
||||
volumes:
|
||||
- ./src:/app/src
|
||||
- ./gulp:/app/gulp
|
||||
- ./server:/app/server
|
||||
- ./tools:/app/tools
|
||||
- ./fonts:/app/fonts
|
||||
- ./live:/app/live
|
@ -8,8 +8,8 @@
|
||||
{
|
||||
"name": "Jubilee",
|
||||
"script": "server.js",
|
||||
"cwd": "/home/martind2000/dev/jubilee",
|
||||
"watch": false,
|
||||
"cwd": ".",
|
||||
"watch": true,
|
||||
"ignore_watch" : ["node_modules"],
|
||||
"merge_logs" : true,
|
||||
"autorestart" : true,
|
||||
|
18
package.json
18
package.json
@ -3,8 +3,17 @@
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"watch": {
|
||||
"gulp" : "{src,server}/*.js",
|
||||
"server": "server/**/*.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
"gulp": "gulp default",
|
||||
"server": "node server.js",
|
||||
"watch-gulp": "npm-watch gulp",
|
||||
"watch-server": "npm-watch server",
|
||||
"start-watching": "npm run watch-gulp && npm run-watch-server",
|
||||
"start": "npm run watch-server"
|
||||
},
|
||||
"engines": {
|
||||
"node": "=8.17.0"
|
||||
@ -64,6 +73,7 @@
|
||||
"yelp-fusion": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.2",
|
||||
"expect.js": "^0.3.1",
|
||||
"gulp": "3.9.1",
|
||||
"gulp-google-webfonts": "0.0.14",
|
||||
@ -77,6 +87,9 @@
|
||||
"mocha": "^5.2.0",
|
||||
"node-fetch": "^2.3.0",
|
||||
"node-geocoder": "^3.22.0",
|
||||
"nodemon": "^3.0.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"npm-watch": "^0.11.0",
|
||||
"require-dir": "^1.2.0",
|
||||
"requirejs": "^2.3.6",
|
||||
"sinon": "^4.5.0",
|
||||
@ -84,7 +97,10 @@
|
||||
"tape-promise": "^4.0.0",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0",
|
||||
"watch": "^1.0.2",
|
||||
"watchify": "^3.11.0",
|
||||
"whatwg-fetch": "^2.0.4"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -432,14 +432,9 @@ function processICAL(ical) {
|
||||
'https://calendar.google.com/calendar/embed?src=family18216414236505453132%40group.calendar.google.com&ctz=Europe%2FLondon']
|
||||
*/
|
||||
module.exports = {
|
||||
'calendars': ['https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics',
|
||||
'https://calendar.google.com/calendar/ical/mt5pgdhknvgoc8usfnrso9vkv0%40group.calendar.google.com/private-58876002af9f302a593acfa6fa792dcf/basic.ics',
|
||||
'https://www.tripit.com/feed/ical/private/DB96E4BB-94A9BD8F9CC1CF51C6CC0D920840F4F5/tripit.ics',
|
||||
'https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics',
|
||||
'https://calendar.google.com/calendar/ical/i8dglj12p5nuv20sbjmun5s588%40group.calendar.google.com/private-c8adccb41e56d6a2f285078aaed313f5/basic.ics',
|
||||
'https://calendar.google.com/calendar/ical/qppj4ebvdur1qui4v0fdpl7l70%40group.calendar.google.com/private-b5071cb2c3fe49544ffbbd08645088f1/basic.ics',
|
||||
'https://calendar.google.com/calendar/ical/8h3vi3rd5rvpfe11klvgre0q4c%40group.calendar.google.com/private-e9df93163a7046658946be45fb08db6f/basic.ics',
|
||||
'https://calendar.google.com/calendar/embed?src=family18216414236505453132%40group.calendar.google.com&ctz=Europe%2FLondon'],
|
||||
'calendars': ['https://cloud.caliban.io/index.php/apps/calendar/p/EKtowxdMkFz6fzfN',
|
||||
'https://cloud.caliban.io/index.php/apps/calendar/p/WBSNSyLrk9ZmB2w5',
|
||||
'https://cloud.caliban.io/index.php/apps/calendar/p/KcK6B42rAePnrrW4'],
|
||||
'jsonBlock': [],
|
||||
'getTodaysSimple': function() {
|
||||
'use strict';
|
||||
|
@ -1,3 +1,4 @@
|
||||
//
|
||||
const $ = require('jquery');
|
||||
const _ = require('underscore');
|
||||
const Backbone = require('backbone');
|
||||
|
@ -7,6 +7,7 @@ const { createPanel, addPanel } = require('./libs/panel');
|
||||
const templates = require('./libs/templates');
|
||||
const TimeFormat = require('hh-mm-ss');
|
||||
const { hourFloor } = require('./libs/utils');
|
||||
const {reduceForcastToday, reduceForcastDaily} = require("./libs/reducers");
|
||||
|
||||
const ForecastModel = Backbone.Model.extend({
|
||||
'defaults': function (obj) {
|
||||
@ -27,12 +28,8 @@ const ForecastModel = Backbone.Model.extend({
|
||||
'getForecast': function() {
|
||||
const ll = this.get('ll');
|
||||
request({
|
||||
'url': `${window.loc}/forecast`,
|
||||
'url': `${window.loc}/forecast/${ll.replace(',','/')}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': ll,
|
||||
'w' : hourFloor()
|
||||
}
|
||||
}, function(err, res, body) {
|
||||
console.log('statusCode', res.statusCode);
|
||||
if (err)
|
||||
@ -45,6 +42,8 @@ const ForecastModel = Backbone.Model.extend({
|
||||
this.set(fsJSON);
|
||||
// console.log(body);
|
||||
|
||||
this.set('time', Date.now());
|
||||
|
||||
this.logUpdate();
|
||||
}
|
||||
}.bind(this));
|
||||
@ -73,13 +72,14 @@ const ForecastView = Backbone.View.extend({
|
||||
'initialize': function(options) {
|
||||
this.eventBus = options.eventBus;
|
||||
|
||||
/* this.model.on('all', function(eventName) {
|
||||
console.log(`${eventName } was triggered!`);
|
||||
});*/
|
||||
this.model.on('all', function(eventName) {
|
||||
console.log(`FORECAST ${eventName } was triggered!`);
|
||||
});
|
||||
|
||||
this.model.bind('change:time', this.doRender, this);
|
||||
this.eventBus.on('showForecast', this.showForecastPanel, this);
|
||||
this.eventBus.on('focused', this.focused, this);
|
||||
this.eventBus.on('renderForecase', this.doRender, this);
|
||||
},
|
||||
|
||||
'showForecastPanel': function(ll) {
|
||||
@ -132,12 +132,42 @@ const ForecastView = Backbone.View.extend({
|
||||
const html = [];
|
||||
|
||||
const currently = this.model.get('currently');
|
||||
const forcastToday = { 'today':this.model.get('forcastToday'), 'daily':this.model.get('dailyForecast') };
|
||||
const forcastToday = { 'today':reduceForcastToday(this.model.get('forcastToday')), 'daily':reduceForcastDaily(this.model.get('dailyForecast')) };
|
||||
const details = this.model.get('details');
|
||||
html.push('<div class="">');
|
||||
html.push(templates.templateCurrently(currently));
|
||||
html.push(templates.templateForecast(forcastToday));
|
||||
html.push(templates.templateDetails(details));
|
||||
|
||||
console.log('currently');
|
||||
console.log(JSON.stringify(currently));
|
||||
try {
|
||||
html.push(templates.templateCurrently(currently));
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
console.log('ERROR!! Forecast templating failed');
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
html.push(templates.templateForecast(forcastToday));
|
||||
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
console.log('ERROR!! Forecast templating failed');
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
html.push(templates.templateDetails(details));
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
console.log('ERROR!! Forecast templating failed');
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
|
||||
html.push('</div>');
|
||||
html.push('<div class="endbumper"></div>');
|
||||
|
||||
|
@ -165,8 +165,9 @@ const LocationModel = Backbone.Model.extend({
|
||||
const atWork = (workDistance < 0.10);
|
||||
const atHomeOrWork = (atHome || atWork);
|
||||
const latlong = { 'lat': latitude, 'lon': longitude };
|
||||
const latlong4 = { 'lat': Number.parseFloat(latitude).toFixed(4), 'lon': Number.parseFloat(longitude).toFixed(4) };
|
||||
const ll = `${latitude},${longitude}`;
|
||||
const llFixed = `${Number.parseFloat(latitude).toFixed(3)},${Number.parseFloat(longitude).toFixed(3)}`;
|
||||
const llFixed = `${Number.parseFloat(latitude).toFixed(4)},${Number.parseFloat(longitude).toFixed(4)}`;
|
||||
const llSix = `${Number.parseFloat(latitude).toFixed(6)},${Number.parseFloat(longitude).toFixed(6)}`;
|
||||
const llShort = `${Number.parseFloat(latitude).toFixed(1)},${Number.parseFloat(longitude).toFixed(1)}`;
|
||||
const moving = true;
|
||||
@ -184,6 +185,7 @@ const LocationModel = Backbone.Model.extend({
|
||||
llFixed,
|
||||
llSix,
|
||||
llShort,
|
||||
latlong4,
|
||||
moving,
|
||||
latlong,
|
||||
'city': '',
|
||||
@ -198,11 +200,8 @@ const LocationModel = Backbone.Model.extend({
|
||||
console.info('>> Location:geocoder request');
|
||||
|
||||
request({
|
||||
'url': `${window.loc}/geocode`,
|
||||
'url': `${window.loc}/geocode/${Number.parseFloat(latitude).toFixed(4)}/${Number.parseFloat(longitude).toFixed(4)}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': ll
|
||||
},
|
||||
'json': true
|
||||
}, function(err, res, body) {
|
||||
if (err)
|
||||
@ -246,11 +245,8 @@ const LocationModel = Backbone.Model.extend({
|
||||
console.log('>> Moved from previous', sinceLastGeocode, (sinceLastGeocode >= 1.8e+6));
|
||||
console.info('>> Location:geocoder request');
|
||||
request({
|
||||
'url': `${window.loc}/geocode`,
|
||||
'url': `${window.loc}/geocode/${llFixed.replace(',','/')}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': ll
|
||||
},
|
||||
'json': true
|
||||
}, function(err, res, body) {
|
||||
if (err)
|
||||
|
@ -47,12 +47,16 @@ const NearbyModel = Backbone.Model.extend({
|
||||
this.throttledGetNearby();
|
||||
},
|
||||
'getNearby': function() {
|
||||
const llFixed = this.get('llFixed');
|
||||
const llFixed = this.get('llFixed').replace(',','/');
|
||||
|
||||
const hour = parseInt((new Date()).getHours().toString(), 10);
|
||||
const section = this.get('section');
|
||||
const time = new Date().getTime() ;
|
||||
|
||||
const soqval = section;
|
||||
|
||||
const soqtype = "s";
|
||||
|
||||
const lastUpdate = time - (this.get('time') || 0);
|
||||
|
||||
console.log('>> Nearby section:', hour, section);
|
||||
@ -60,11 +64,9 @@ const NearbyModel = Backbone.Model.extend({
|
||||
console.log(`>> Nearby last fetch: ${TimeFormat.fromMs(lastUpdate, 'hh:mm')} ago`);
|
||||
|
||||
if (lastUpdate > 120000) {
|
||||
const url = new URL(`${window.loc}/fsexplore`);
|
||||
const url = new URL(`${window.loc}/fsexplore/${llFixed.replace(',','/')}/${soqval}/${soqtype}/10`);
|
||||
|
||||
|
||||
url.searchParams.append('ll', llFixed);
|
||||
url.searchParams.append('section', section);
|
||||
url.searchParams.append('w', hourFloor());
|
||||
|
||||
fetch(url)
|
||||
.then(res => {
|
||||
|
@ -40,6 +40,10 @@ const NearbyListModel = Backbone.Model.extend({
|
||||
const limit = this.get('limit');
|
||||
const time = new Date().getTime() ;
|
||||
|
||||
const soqval = section || query;
|
||||
|
||||
const soqtype = section ? "s" : "q";
|
||||
|
||||
const lastUpdate = time - (this.get('time') || 0);
|
||||
|
||||
console.log('>> Nearby section:', hour, section);
|
||||
@ -49,14 +53,7 @@ const NearbyListModel = Backbone.Model.extend({
|
||||
// this.fsCollection.reset( null, { 'silent':true });
|
||||
|
||||
if (lastUpdate > 120000 || force) {
|
||||
const _url = new URL(`${window.loc}/fsexplore`);
|
||||
|
||||
_url.search = new URLSearchParams({
|
||||
'll': llFixed,
|
||||
'section': section,
|
||||
'query':query,
|
||||
'limit': limit
|
||||
});
|
||||
const _url = new URL(`${window.loc}/fsexplore/${llFixed.replace(',','/')}/${soqval}/${soqtype}/${limit}`);
|
||||
|
||||
console.log(_url);
|
||||
|
||||
|
@ -45,11 +45,8 @@ const ByMeModel = Backbone.Model.extend({
|
||||
// console.log(this.toJSON());
|
||||
// const section = (partOfDay >= 11 && partOfDay <= 14) ? 'food' : 'topPicks';
|
||||
request({
|
||||
'url': `${window.loc}/rightbyme`,
|
||||
'url': `${window.loc}/rightbyme/${ll.replace(',','/')}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': ll
|
||||
}
|
||||
}, function(err, res, body) {
|
||||
console.log('statusCode', res.statusCode);
|
||||
if (err)
|
||||
|
@ -19,7 +19,7 @@ const VenueDetailModel = Backbone.Model.extend({
|
||||
'getVenue': function() {
|
||||
const id = this.get('id');
|
||||
request({
|
||||
'url': `${window.loc}/nearbydetail`,
|
||||
'url': `${window.loc}/nearbydetail/${id}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'id': id
|
||||
|
@ -99,12 +99,8 @@ const WeatherModel = Backbone.Model.extend({
|
||||
console.log('>> Weather request');
|
||||
const llFixed = this.get('llFixed');
|
||||
request({
|
||||
'url': `${window.loc}/weather`,
|
||||
'url': `${window.loc}/weather/${llFixed.replace(',','/')}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': llFixed,
|
||||
'w' : hourFloor()
|
||||
}
|
||||
}, function(err, res, body) {
|
||||
console.log('statusCode', res.statusCode);
|
||||
if (err)
|
||||
|
@ -59,12 +59,8 @@ const WeatherAlertModel = Backbone.Model.extend({
|
||||
console.log('>> WeatherAlert request');
|
||||
const llFixed = this.get('ll');
|
||||
request({
|
||||
'url': `${window.loc}/weatheralert`,
|
||||
'url': `${window.loc}/weatheralert/${llFixed.replace(',','/')}`,
|
||||
'method': 'GET',
|
||||
'qs': {
|
||||
'll': llFixed,
|
||||
'w' : hourFloor()
|
||||
}
|
||||
}, function (err, res, body) {
|
||||
console.log('statusCode', res.statusCode);
|
||||
if (err)
|
||||
|
@ -37,7 +37,7 @@ function reduceOpenWeather(item, city) {
|
||||
// Replaced Moment with Fecha.
|
||||
// Too many issues trying to get Moment packaged into the bundle.
|
||||
|
||||
if (!item || item === null) return {};
|
||||
if (!item) return {};
|
||||
const fts = new Date(item.dt * 1000);
|
||||
const weatherBlock = item.weather[0];
|
||||
|
||||
@ -45,9 +45,9 @@ function reduceOpenWeather(item, city) {
|
||||
'timestamp': item.dt,
|
||||
'icon': `wi-owm-${weatherBlock.id}`,
|
||||
'summary': weatherBlock.description,
|
||||
'temp': parseInt(item.main.temp, 10),
|
||||
'tempHigh': parseFloat(item.main.temp_max, 10),
|
||||
'tempLow': parseFloat(item.main.temp_min, 10),
|
||||
'temp': parseInt(item.temp['day'], 10),
|
||||
'tempHigh': parseFloat(item.temp['max'], 10),
|
||||
'tempLow': parseFloat(item.temp['min'], 10),
|
||||
'datelong': fecha.format(fts, 'YYYY-MM-DDTHH:mm:ss.SSSZZ'),
|
||||
'readdate': fecha.format(fts, 'default'),
|
||||
'time': item.dt,
|
||||
@ -113,6 +113,38 @@ const reduceEuronews = function(item) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
const reduceForcastToday = function(listArray) {
|
||||
|
||||
const newArray = listArray.map((item) => {
|
||||
|
||||
const fts = new Date(item.time * 1000);
|
||||
|
||||
return {
|
||||
'icon': item.icon,
|
||||
'temp': item.temp,
|
||||
'time': fecha.format(fts, 'HH:mm')
|
||||
};
|
||||
});
|
||||
|
||||
return newArray.slice(0,24);
|
||||
}
|
||||
const reduceForcastDaily = function(listArray) {
|
||||
|
||||
return listArray.map((item) => {
|
||||
|
||||
const fts = new Date(item.time * 1000);
|
||||
|
||||
return {
|
||||
'icon': item.icon,
|
||||
'tempHigh': item.tempHigh,
|
||||
'tempLow': item.tempLow,
|
||||
'time': fecha.format(fts, 'dddd')
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
const pubdateSrc = fecha.parse(item.pubdate, 'ddd, DD MMM YYYY HH:mm:SS ZZ');
|
||||
const pubdate = fecha.format(pubdateSrc, 'dddd MMMM Do, YYYY');
|
||||
@ -126,4 +158,4 @@ const pubdateSrc = fecha.parse(item.pubdate, 'ddd, DD MMM YYYY HH:mm:SS ZZ');
|
||||
</article>`;
|
||||
*/
|
||||
|
||||
module.exports = { reduceOpenWeather, reduceNearby, reduceEuronews, reduceDarksky };
|
||||
module.exports = { reduceOpenWeather, reduceNearby, reduceEuronews, reduceDarksky, reduceForcastToday, reduceForcastDaily };
|
||||
|
Loading…
Reference in New Issue
Block a user