Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
867657a965 | ||
|
|
e89dc52541 | ||
|
|
317883fc04 | ||
|
|
a4a601a387 | ||
|
|
375812c024 | ||
|
|
6af8b58f14 | ||
|
|
6287db7483 | ||
|
|
46a8fa470c | ||
|
|
8489b7e2be | ||
|
|
7a196ac64a | ||
|
|
5946ee495a | ||
|
|
93ac03acd4 | ||
|
|
23a0dd6870 | ||
|
|
384693688c | ||
|
|
e2877aad77 | ||
|
|
7fae649357 | ||
|
|
468e057c51 | ||
|
|
4c65f5bc4d | ||
|
|
99308155d6 | ||
|
|
cde7ceda6e | ||
|
|
72938671ac | ||
|
|
9e1ea31262 | ||
|
|
e952d860dc | ||
|
|
262ea15468 | ||
|
|
5d2e5a6d9c | ||
|
|
992258d3ce | ||
|
|
b031934022 | ||
|
|
4cc2312ffd | ||
|
|
ce99fc16e7 | ||
|
|
97f96d4091 | ||
|
|
13f08b62cc | ||
|
|
eacd82b4f4 | ||
|
|
91f669e828 | ||
|
|
cdbe3d968f | ||
|
|
0a388cdb83 | ||
|
|
8678d9f053 | ||
|
|
a592668d0d | ||
|
|
b3faf95e39 | ||
|
|
3a304d7c08 | ||
|
|
c7eb56f60c |
@@ -2,8 +2,7 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"node": true,
|
"node": true
|
||||||
"jquery": true
|
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"airbnb-base"
|
"airbnb-base"
|
||||||
@@ -12,10 +11,11 @@
|
|||||||
"TravelCities": "readonly",
|
"TravelCities": "readonly",
|
||||||
"RegionalCities": "readonly",
|
"RegionalCities": "readonly",
|
||||||
"StationInfo": "readonly",
|
"StationInfo": "readonly",
|
||||||
"SunCalc": "readonly"
|
"SunCalc": "readonly",
|
||||||
|
"NoSleep": "readonly"
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2023,
|
"ecmaVersion": "latest",
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [],
|
||||||
|
|||||||
5
.gitignore
vendored
@@ -11,4 +11,7 @@ server/music/*
|
|||||||
|
|
||||||
#dist folder
|
#dist folder
|
||||||
dist/*
|
dist/*
|
||||||
!dist/readme.txt
|
!dist/readme.txt
|
||||||
|
|
||||||
|
#environment variables
|
||||||
|
.env
|
||||||
7
.vscode/launch.json
vendored
@@ -15,6 +15,9 @@
|
|||||||
"**/*.min.js",
|
"**/*.min.js",
|
||||||
"**/vendor/**"
|
"**/vendor/**"
|
||||||
],
|
],
|
||||||
|
"runtimeArgs": [
|
||||||
|
"--autoplay-policy=no-user-gesture-required"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Data:stations",
|
"name": "Data:stations",
|
||||||
@@ -66,13 +69,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"program": "${workspaceFolder}/tests/index.js",
|
"program": "${workspaceFolder}/tests/index.mjs",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"outputCapture": "std"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
|
|||||||
6
.vscode/settings.json
vendored
@@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"cSpell.enableFiletypes": [
|
|
||||||
"javascript"
|
|
||||||
],
|
|
||||||
"liveSassCompile.settings.formats": [
|
"liveSassCompile.settings.formats": [
|
||||||
{
|
{
|
||||||
"format": "compressed",
|
"format": "compressed",
|
||||||
@@ -23,7 +20,4 @@
|
|||||||
"eslint.validate": [
|
"eslint.validate": [
|
||||||
"javascript"
|
"javascript"
|
||||||
],
|
],
|
||||||
"cSpell.words": [
|
|
||||||
"Tucsan"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
12
README.md
@@ -18,7 +18,7 @@ This project is based on the work of [Mike Battaglia](https://github.com/vbguyny
|
|||||||
|
|
||||||
## Does WeatherStar 4000+ work outside of the USA?
|
## Does WeatherStar 4000+ work outside of the USA?
|
||||||
|
|
||||||
This project is tightly coupled to [NOAA's Weather API](https://www.weather.gov/documentation/services-web-api), which is exclsuive to the United States. Using NOAA's Weather API is a crucial requirement to provide an authentic WeatherStar 4000+ experience.
|
This project is tightly coupled to [NOAA's Weather API](https://www.weather.gov/documentation/services-web-api), which is exclusive to the United States. Using NOAA's Weather API is a crucial requirement to provide an authentic WeatherStar 4000+ experience.
|
||||||
|
|
||||||
If you would like to display weather information for international locations (outside of the USA), please checkout a fork of this project created by [@mwood77](https://github.com/mwood77):
|
If you would like to display weather information for international locations (outside of the USA), please checkout a fork of this project created by [@mwood77](https://github.com/mwood77):
|
||||||
- [`ws4kp-international`](https://github.com/mwood77/ws4kp-international)
|
- [`ws4kp-international`](https://github.com/mwood77/ws4kp-international)
|
||||||
@@ -92,11 +92,12 @@ Kiosk mode can be activated by a checkbox on the page. Note that there is no way
|
|||||||
|
|
||||||
It's also possible to enter kiosk mode using a permalink. First generate a [Permalink](#sharing-a-permalink-bookmarking), then to the end of it add `&kiosk=true`. Opening this link will load all of the selected displays included in the Permalink, enter kiosk mode immediately upon loading and start playing the forecast.
|
It's also possible to enter kiosk mode using a permalink. First generate a [Permalink](#sharing-a-permalink-bookmarking), then to the end of it add `&kiosk=true`. Opening this link will load all of the selected displays included in the Permalink, enter kiosk mode immediately upon loading and start playing the forecast.
|
||||||
|
|
||||||
## Wish list
|
## Default query string paramaters (environment variables)
|
||||||
|
When serving this via the built-in Express server, it's possible to define environment variables that direct the user to a default set of paramaters (like the [Permalink](#sharing-a-permalink-bookmarking) above). If a user requests the root page at `http://localhost:8080/` the query string provided by environment variables will be appended to the url thus providing a default configuration.
|
||||||
|
|
||||||
As time allows I will be working on the following enhancements.
|
Environment variables can be added to the command line as usual, or via a .env file which is parsed with [dotenv](https://github.com/motdotla/dotenv). Both methods have the same effect.
|
||||||
|
|
||||||
* Better error reporting when api.weather.gov is down (happens more often than you would think)
|
Environment variables that are to be added to the default query string are prefixed with `WSQS_` and then use the same key/value pairs generated by the [Permalink](#sharing-a-permalink-bookmarking) above, with the `- (dash)` character replaced by an `_ (underscore)`. For example, if you wanted to turn the travel forecast on, you would find `travel-checkbox=true` in the permalink, it's matching environment variable becomes `WSQS_travel_checkbox=true`.
|
||||||
|
|
||||||
## Serving static files
|
## Serving static files
|
||||||
The app can be served as a static set of files on any web server. Run the provided gulp task to create a set of static distribution files:
|
The app can be served as a static set of files on any web server. Run the provided gulp task to create a set of static distribution files:
|
||||||
@@ -108,7 +109,7 @@ The resulting files will be in the /dist folder in the root of the project. Thes
|
|||||||
## Music
|
## Music
|
||||||
The WeatherStar had wonderful background music from the smooth jazz and new age genres by artists of the time. Lists of the music that played are available by searching online, but it's all copyrighted music and would be difficult to provide as part of this repository.
|
The WeatherStar had wonderful background music from the smooth jazz and new age genres by artists of the time. Lists of the music that played are available by searching online, but it's all copyrighted music and would be difficult to provide as part of this repository.
|
||||||
|
|
||||||
I've used AI tools to create WeatherStar-inspired music tracks that are unencumbered by copyright and are included in this repo. Too keep the size down, I've only included 4 tracks. Additional tracks will be posted in a companion repository [ws4kp-music](https://github.com/netbymatt/ws4kp-music).
|
I've used AI tools to create WeatherStar-inspired music tracks that are unencumbered by copyright and are included in this repo. Too keep the size down, I've only included 4 tracks. Additional tracks are in a companion repository [ws4kp-music](https://github.com/netbymatt/ws4kp-music).
|
||||||
|
|
||||||
### Customizing the music
|
### Customizing the music
|
||||||
Placing .mp3 files in the `/server/music` folder will override the default music included in the repo. Subdirectories will not be scanned. When weatherstar loads in the browser it will load a list if available files and randomize the order when it starts playing. On each loop through the available tracks the order will again be shuffled. If you're using the static files method to host your WeatherStar music is located in `/music`.
|
Placing .mp3 files in the `/server/music` folder will override the default music included in the repo. Subdirectories will not be scanned. When weatherstar loads in the browser it will load a list if available files and randomize the order when it starts playing. On each loop through the available tracks the order will again be shuffled. If you're using the static files method to host your WeatherStar music is located in `/music`.
|
||||||
@@ -129,6 +130,7 @@ Thanks to the WeatherStar community for providing these discussions to further e
|
|||||||
|
|
||||||
* [Stream as FFMPEG](https://github.com/netbymatt/ws4kp/issues/37#issuecomment-2008491948)
|
* [Stream as FFMPEG](https://github.com/netbymatt/ws4kp/issues/37#issuecomment-2008491948)
|
||||||
* [Weather like it's 1999](https://blog.scottlabs.io/2024/02/weather-like-its-1999/) Raspberry pi, streaming, music and CRT all combined into a complete solution.
|
* [Weather like it's 1999](https://blog.scottlabs.io/2024/02/weather-like-its-1999/) Raspberry pi, streaming, music and CRT all combined into a complete solution.
|
||||||
|
* [ws4channels](https://github.com/rice9797/ws4channels) A Dockerized Node.js application to stream WeatherStar 4000 data into Channels DVR using Puppeteer and FFmpeg.
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
A hook is provided as `/server/scripts/custom.js` to allow customizations to your own fork of this project, without accidentally pushing your customizations back upstream to the git repository. An sample file is provided at `/server/scripts/custom.sample.js` and should be renamed to `custom.js` activate it.
|
A hook is provided as `/server/scripts/custom.js` to allow customizations to your own fork of this project, without accidentally pushing your customizations back upstream to the git repository. An sample file is provided at `/server/scripts/custom.sample.js` and should be renamed to `custom.js` activate it.
|
||||||
|
|||||||
@@ -1150,7 +1150,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"city": "Tucsan",
|
"city": "Tucson",
|
||||||
"lat": 32.2216,
|
"lat": 32.2216,
|
||||||
"lon": -110.9698,
|
"lon": -110.9698,
|
||||||
"point": {
|
"point": {
|
||||||
|
|||||||
@@ -575,7 +575,7 @@
|
|||||||
"lon": -77.9447
|
"lon": -77.9447
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"city": "Tucsan",
|
"city": "Tucson",
|
||||||
"lat": 32.2216,
|
"lat": 32.2216,
|
||||||
"lon": -110.9698
|
"lon": -110.9698
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,61 +9,59 @@ import chunk from './chunk.mjs';
|
|||||||
// skip stations starting with these letters
|
// skip stations starting with these letters
|
||||||
const skipStations = ['U', 'C', 'H', 'W', 'Y', 'T', 'S', 'M', 'O', 'L', 'A', 'F', 'B', 'N', 'V', 'R', 'D', 'E', 'I', 'G', 'J'];
|
const skipStations = ['U', 'C', 'H', 'W', 'Y', 'T', 'S', 'M', 'O', 'L', 'A', 'F', 'B', 'N', 'V', 'R', 'D', 'E', 'I', 'G', 'J'];
|
||||||
|
|
||||||
// immediately invoked function so we can access async/await
|
// chunk the list of states
|
||||||
const start = async () => {
|
const chunkStates = chunk(states, 1);
|
||||||
// chunk the list of states
|
|
||||||
const chunkStates = chunk(states, 5);
|
|
||||||
|
|
||||||
// store output
|
// store output
|
||||||
const output = {};
|
const output = {};
|
||||||
|
|
||||||
// process all chunks
|
// process all chunks
|
||||||
for (let i = 0; i < chunkStates.length; i += 1) {
|
for (let i = 0; i < chunkStates.length; i += 1) {
|
||||||
const stateChunk = chunkStates[i];
|
const stateChunk = chunkStates[i];
|
||||||
// loop through states
|
// loop through states
|
||||||
|
|
||||||
stateChunk.forEach(async (state) => {
|
// eslint-disable-next-line no-await-in-loop
|
||||||
try {
|
await Promise.allSettled(stateChunk.map(async (state) => {
|
||||||
let stations;
|
try {
|
||||||
let next = `https://api.weather.gov/stations?state=${state}`;
|
let stations;
|
||||||
do {
|
let next = `https://api.weather.gov/stations?state=${state}`;
|
||||||
// get list and parse the JSON
|
let round = 0;
|
||||||
// eslint-disable-next-line no-await-in-loop
|
do {
|
||||||
const stationsRaw = await https(next);
|
console.log(`Getting: ${state}-${round}`);
|
||||||
stations = JSON.parse(stationsRaw);
|
// get list and parse the JSON
|
||||||
// filter stations for 4 letter identifiers
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const stationsFiltered4 = stations.features.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
|
const stationsRaw = await https(next);
|
||||||
// filter against starting letter
|
stations = JSON.parse(stationsRaw);
|
||||||
const stationsFiltered = stationsFiltered4.filter((station) => !skipStations.includes(station.properties.stationIdentifier.slice(0, 1)));
|
// filter stations for 4 letter identifiers
|
||||||
// add each resulting station to the output
|
const stationsFiltered4 = stations.features.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
|
||||||
stationsFiltered.forEach((station) => {
|
// filter against starting letter
|
||||||
const id = station.properties.stationIdentifier;
|
const stationsFiltered = stationsFiltered4.filter((station) => !skipStations.includes(station.properties.stationIdentifier.slice(0, 1)));
|
||||||
if (output[id]) {
|
// add each resulting station to the output
|
||||||
console.log(`Duplicate station: ${state}-${id}`);
|
stationsFiltered.forEach((station) => {
|
||||||
return;
|
const id = station.properties.stationIdentifier;
|
||||||
}
|
if (output[id]) {
|
||||||
output[id] = {
|
console.log(`Duplicate station: ${state}-${id}`);
|
||||||
id,
|
return;
|
||||||
city: station.properties.name,
|
}
|
||||||
state,
|
output[id] = {
|
||||||
lat: station.geometry.coordinates[1],
|
id,
|
||||||
lon: station.geometry.coordinates[0],
|
city: station.properties.name,
|
||||||
};
|
state,
|
||||||
});
|
lat: station.geometry.coordinates[1],
|
||||||
next = stations?.pagination?.next;
|
lon: station.geometry.coordinates[0],
|
||||||
// write the output
|
};
|
||||||
writeFileSync('./datagenerators/output/stations.json', JSON.stringify(output, null, 2));
|
});
|
||||||
}
|
next = stations?.pagination?.next;
|
||||||
while (next && stations.features.length > 0);
|
round += 1;
|
||||||
console.log(`Complete: ${state}`);
|
// write the output
|
||||||
return true;
|
writeFileSync('./datagenerators/output/stations.json', JSON.stringify(output, null, 2));
|
||||||
} catch (e) {
|
|
||||||
console.error(`Unable to get state: ${state}`);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
while (next && stations.features.length > 0);
|
||||||
}
|
console.log(`Complete: ${state}`);
|
||||||
};
|
return true;
|
||||||
|
} catch (e) {
|
||||||
// immediately invoked function allows access to async
|
console.error(`Unable to get state: ${state}`);
|
||||||
await start();
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
import 'dotenv/config';
|
||||||
import {
|
import {
|
||||||
src, dest, series, parallel,
|
src, dest, series, parallel,
|
||||||
} from 'gulp';
|
} from 'gulp';
|
||||||
@@ -6,9 +7,9 @@ import concat from 'gulp-concat';
|
|||||||
import terser from 'gulp-terser';
|
import terser from 'gulp-terser';
|
||||||
import ejs from 'gulp-ejs';
|
import ejs from 'gulp-ejs';
|
||||||
import rename from 'gulp-rename';
|
import rename from 'gulp-rename';
|
||||||
import htmlmin from 'gulp-htmlmin';
|
import htmlmin from 'gulp-html-minifier-terser';
|
||||||
import { deleteAsync } from 'del';
|
import { deleteAsync } from 'del';
|
||||||
import s3Upload from 'gulp-s3-upload';
|
import s3Upload from 'gulp-s3-uploader';
|
||||||
import webpack from 'webpack-stream';
|
import webpack from 'webpack-stream';
|
||||||
import TerserPlugin from 'terser-webpack-plugin';
|
import TerserPlugin from 'terser-webpack-plugin';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
@@ -32,8 +33,6 @@ const jsSourcesData = [
|
|||||||
|
|
||||||
const webpackOptions = {
|
const webpackOptions = {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
// mode: 'development',
|
|
||||||
// devtool: 'source-map',
|
|
||||||
output: {
|
output: {
|
||||||
filename: 'ws.min.js',
|
filename: 'ws.min.js',
|
||||||
},
|
},
|
||||||
@@ -62,8 +61,6 @@ const compressJsData = () => src(jsSourcesData)
|
|||||||
.pipe(dest(RESOURCES_PATH));
|
.pipe(dest(RESOURCES_PATH));
|
||||||
|
|
||||||
const jsVendorSources = [
|
const jsVendorSources = [
|
||||||
'server/scripts/vendor/auto/jquery.js',
|
|
||||||
'server/scripts/vendor/jquery.autocomplete.min.js',
|
|
||||||
'server/scripts/vendor/auto/nosleep.js',
|
'server/scripts/vendor/auto/nosleep.js',
|
||||||
'server/scripts/vendor/auto/swiped-events.js',
|
'server/scripts/vendor/auto/swiped-events.js',
|
||||||
'server/scripts/vendor/auto/suncalc.js',
|
'server/scripts/vendor/auto/suncalc.js',
|
||||||
@@ -79,6 +76,7 @@ const mjsSources = [
|
|||||||
'server/scripts/modules/hazards.mjs',
|
'server/scripts/modules/hazards.mjs',
|
||||||
'server/scripts/modules/currentweather.mjs',
|
'server/scripts/modules/currentweather.mjs',
|
||||||
'server/scripts/modules/almanac.mjs',
|
'server/scripts/modules/almanac.mjs',
|
||||||
|
'server/scripts/modules/spc-outlook.mjs',
|
||||||
'server/scripts/modules/icons.mjs',
|
'server/scripts/modules/icons.mjs',
|
||||||
'server/scripts/modules/extendedforecast.mjs',
|
'server/scripts/modules/extendedforecast.mjs',
|
||||||
'server/scripts/modules/hourly.mjs',
|
'server/scripts/modules/hourly.mjs',
|
||||||
@@ -140,7 +138,7 @@ const uploadSources = [
|
|||||||
];
|
];
|
||||||
const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
||||||
.pipe(s3({
|
.pipe(s3({
|
||||||
Bucket: 'weatherstar',
|
Bucket: process.env.BUCKET,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
maps: {
|
maps: {
|
||||||
CacheControl: (keyname) => {
|
CacheControl: (keyname) => {
|
||||||
@@ -154,17 +152,18 @@ const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
|||||||
const imageSources = [
|
const imageSources = [
|
||||||
'server/fonts/**',
|
'server/fonts/**',
|
||||||
'server/images/**',
|
'server/images/**',
|
||||||
|
'!server/images/gimp/**',
|
||||||
];
|
];
|
||||||
const uploadImages = () => src(imageSources, { base: './server', encoding: false })
|
const uploadImages = () => src(imageSources, { base: './server', encoding: false })
|
||||||
.pipe(
|
.pipe(
|
||||||
s3({
|
s3({
|
||||||
Bucket: 'weatherstar',
|
Bucket: process.env.BUCKET,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
||||||
DistributionId: 'E9171A4KV8KCW',
|
DistributionId: process.env.DISTRIBUTION_ID,
|
||||||
InvalidationBatch: {
|
InvalidationBatch: {
|
||||||
CallerReference: (new Date()).toLocaleString(),
|
CallerReference: (new Date()).toLocaleString(),
|
||||||
Paths: {
|
Paths: {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const vendorFiles = [
|
|||||||
'./node_modules/luxon/build/es6/luxon.js',
|
'./node_modules/luxon/build/es6/luxon.js',
|
||||||
'./node_modules/luxon/build/es6/luxon.js.map',
|
'./node_modules/luxon/build/es6/luxon.js.map',
|
||||||
'./node_modules/nosleep.js/dist/NoSleep.js',
|
'./node_modules/nosleep.js/dist/NoSleep.js',
|
||||||
'./node_modules/jquery/dist/jquery.js',
|
|
||||||
'./node_modules/suncalc/suncalc.js',
|
'./node_modules/suncalc/suncalc.js',
|
||||||
'./node_modules/swiped-events/src/swiped-events.js',
|
'./node_modules/swiped-events/src/swiped-events.js',
|
||||||
];
|
];
|
||||||
|
|||||||
33
index.mjs
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import corsPassThru from './cors/index.mjs';
|
import corsPassThru from './cors/index.mjs';
|
||||||
@@ -20,7 +21,39 @@ app.get('/playlist.json', playlist);
|
|||||||
// version
|
// version
|
||||||
const { version } = JSON.parse(fs.readFileSync('package.json'));
|
const { version } = JSON.parse(fs.readFileSync('package.json'));
|
||||||
|
|
||||||
|
// read and parse environment variables to append to the query string
|
||||||
|
// use the permalink (share) button on the web app to generate a starting point for your configuration
|
||||||
|
// then take each key/value in the querystring and append WSQS_ to the beginning, and then replace any
|
||||||
|
// hyphens with underscores in the key name
|
||||||
|
// environment variables are read from the command line and .env file via the dotenv package
|
||||||
|
|
||||||
|
const qsVars = {};
|
||||||
|
|
||||||
|
Object.entries(process.env).forEach(([key, value]) => {
|
||||||
|
// test for key matching pattern described above
|
||||||
|
if (key.match(/^WSQS_[A-Za-z0-9_]+$/)) {
|
||||||
|
// convert the key to a querystring formatted key
|
||||||
|
const formattedKey = key.replace(/^WSQS_/, '').replaceAll('_', '-');
|
||||||
|
qsVars[formattedKey] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// single flag to determine if environment variables are present
|
||||||
|
const hasQsVars = Object.entries(qsVars).length > 0;
|
||||||
|
|
||||||
|
// turn the environment query string into search params
|
||||||
|
const defaultSearchParams = (new URLSearchParams(qsVars)).toString();
|
||||||
|
|
||||||
const index = (req, res) => {
|
const index = (req, res) => {
|
||||||
|
// test for no query string in request and if environment query string values were provided
|
||||||
|
if (hasQsVars && Object.keys(req.query).length === 0) {
|
||||||
|
// redirect the user to the query-string appended url
|
||||||
|
const url = new URL(`${req.protocol}://${req.host}${req.url}`);
|
||||||
|
url.search = defaultSearchParams;
|
||||||
|
res.redirect(307, url.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// return the standard page
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
production: false,
|
production: false,
|
||||||
version,
|
version,
|
||||||
|
|||||||
1885
package-lock.json
generated
11
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "5.16.2",
|
"version": "5.19.2",
|
||||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||||
"main": "index.mjs",
|
"main": "index.mjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -32,22 +32,21 @@
|
|||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-ejs": "^5.1.0",
|
"gulp-ejs": "^5.1.0",
|
||||||
"gulp-file": "^0.4.0",
|
"gulp-file": "^0.4.0",
|
||||||
"gulp-htmlmin": "^5.0.1",
|
|
||||||
"gulp-rename": "^2.0.0",
|
"gulp-rename": "^2.0.0",
|
||||||
"gulp-s3-upload": "^1.7.3",
|
"gulp-s3-uploader": "^1.0.6",
|
||||||
"gulp-sass": "^6.0.0",
|
"gulp-sass": "^6.0.0",
|
||||||
"gulp-terser": "^2.0.0",
|
"gulp-terser": "^2.0.0",
|
||||||
"jquery": "^3.6.0",
|
|
||||||
"jquery-touchswipe": "^1.6.19",
|
|
||||||
"luxon": "^3.0.0",
|
"luxon": "^3.0.0",
|
||||||
"nosleep.js": "^0.12.0",
|
"nosleep.js": "^0.12.0",
|
||||||
"sass": "^1.54.0",
|
"sass": "^1.54.0",
|
||||||
"suncalc": "^1.8.0",
|
"suncalc": "^1.8.0",
|
||||||
"swiped-events": "^1.1.4",
|
"swiped-events": "^1.1.4",
|
||||||
"terser-webpack-plugin": "^5.3.6",
|
"terser-webpack-plugin": "^5.3.6",
|
||||||
"webpack-stream": "^7.0.0"
|
"webpack-stream": "^7.0.0",
|
||||||
|
"gulp-html-minifier-terser": "^7.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"dotenv": "^16.5.0",
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"express": "^5.1.0"
|
"express": "^5.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
[Dolphin]
|
|
||||||
PreviewsShown=true
|
|
||||||
Timestamp=2020,10,1,21,36,7
|
|
||||||
Version=4
|
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 890 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 925 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 273 B |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 717 B |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 451 B |
|
Before Width: | Height: | Size: 925 B |
|
Before Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 358 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 729 B |
|
Before Width: | Height: | Size: 727 B |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |