mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 17:19:30 -07:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9150d42802 | ||
|
|
54257e4667 | ||
|
|
7d50ce28bd | ||
|
|
2db7f30de7 | ||
|
|
5c7a6ab1a4 | ||
|
|
4b63328b74 | ||
|
|
ae1d004f60 | ||
|
|
7dd4c1dd24 | ||
|
|
1120247c99 |
13
.github/ISSUE_TEMPLATE/naming _issue.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/naming _issue.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: Naming issue
|
||||||
|
about: A city, airport or other location is not named correctly
|
||||||
|
title: 'Name Issue: '
|
||||||
|
labels: naming
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
This form is not for reporting a location that you can not find from the search box.
|
||||||
|
|
||||||
|
Use this form to help us rename airports, points of interest and other data provided from the API (rarely updated) to a better name. For example the airport in Broomfield colorado was renamed from "Jeffco" in the API to "Rocky Mountain Metro" it's new name.
|
||||||
|
|
||||||
|
You can also make a pull request on the `[station-overrides.mjs](https://github.com/netbymatt/ws4kp/blob/main/datagenerators/stations-states.mjs)` file which includes instructions on how to make the change directly. This is the preferred method.
|
||||||
File diff suppressed because it is too large
Load Diff
19
datagenerators/stations-overrides.mjs
Normal file
19
datagenerators/stations-overrides.mjs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// station overrides are used to change the data for a station that is provided by the api
|
||||||
|
// the most common use is to adjust the city (station name) for formatting or to update an outdated name
|
||||||
|
// a complete station object looks like this:
|
||||||
|
// {
|
||||||
|
// "id": "KMCO", // 4-letter station identifier and key for lookups
|
||||||
|
// "city": "Orlando International Airport", // name displayed for this station
|
||||||
|
// "state": "FL", // state
|
||||||
|
// "lat": 28.41826, // latitude of station
|
||||||
|
// "lon": -81.32413 // longitude of station
|
||||||
|
// }
|
||||||
|
// any or all of the data for a station can be overwritten, follow the existing override patterns below
|
||||||
|
|
||||||
|
const overrides = {
|
||||||
|
KBJC: {
|
||||||
|
city: 'Rocky Mountain Metro',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default overrides;
|
||||||
@@ -5,6 +5,7 @@ import { writeFileSync } from 'fs';
|
|||||||
import https from './https.mjs';
|
import https from './https.mjs';
|
||||||
import states from './stations-states.mjs';
|
import states from './stations-states.mjs';
|
||||||
import chunk from './chunk.mjs';
|
import chunk from './chunk.mjs';
|
||||||
|
import overrides from './stations-overrides.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'];
|
||||||
@@ -43,12 +44,16 @@ for (let i = 0; i < chunkStates.length; i += 1) {
|
|||||||
console.log(`Duplicate station: ${state}-${id}`);
|
console.log(`Duplicate station: ${state}-${id}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// get any overrides if available
|
||||||
|
const override = overrides[id] ?? {};
|
||||||
output[id] = {
|
output[id] = {
|
||||||
id,
|
id,
|
||||||
city: station.properties.name,
|
city: station.properties.name,
|
||||||
state,
|
state,
|
||||||
lat: station.geometry.coordinates[1],
|
lat: station.geometry.coordinates[1],
|
||||||
lon: station.geometry.coordinates[0],
|
lon: station.geometry.coordinates[0],
|
||||||
|
// finally add the overrides
|
||||||
|
...override,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
next = stations?.pagination?.next;
|
next = stations?.pagination?.next;
|
||||||
@@ -59,7 +64,7 @@ for (let i = 0; i < chunkStates.length; i += 1) {
|
|||||||
while (next && stations.features.length > 0);
|
while (next && stations.features.length > 0);
|
||||||
console.log(`Complete: ${state}`);
|
console.log(`Complete: ${state}`);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(`Unable to get state: ${state}`);
|
console.error(`Unable to get state: ${state}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ const mjsSources = [
|
|||||||
'server/scripts/modules/travelforecast.mjs',
|
'server/scripts/modules/travelforecast.mjs',
|
||||||
'server/scripts/modules/progress.mjs',
|
'server/scripts/modules/progress.mjs',
|
||||||
'server/scripts/modules/media.mjs',
|
'server/scripts/modules/media.mjs',
|
||||||
|
'server/scripts/modules/custom-rss-feed.mjs',
|
||||||
'server/scripts/index.mjs',
|
'server/scripts/index.mjs',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
715
package-lock.json
generated
715
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "5.27.0",
|
"version": "5.27.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",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"webpack-stream": "^7.0.0"
|
"webpack-stream": "^7.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^17.0.1",
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"express": "^5.1.0"
|
"express": "^5.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13350,6 +13350,13 @@ const StationInfo = {
|
|||||||
lat: 38.7578,
|
lat: 38.7578,
|
||||||
lon: -104.3013,
|
lon: -104.3013,
|
||||||
},
|
},
|
||||||
|
KAEJ: {
|
||||||
|
id: 'KAEJ',
|
||||||
|
city: 'Central Colorado Regional Airport',
|
||||||
|
state: 'CO',
|
||||||
|
lat: 38.81416,
|
||||||
|
lon: -106.12069,
|
||||||
|
},
|
||||||
KAFF: {
|
KAFF: {
|
||||||
id: 'KAFF',
|
id: 'KAFF',
|
||||||
city: 'Air Force Academy',
|
city: 'Air Force Academy',
|
||||||
@@ -13357,13 +13364,6 @@ const StationInfo = {
|
|||||||
lat: 38.96667,
|
lat: 38.96667,
|
||||||
lon: -104.81667,
|
lon: -104.81667,
|
||||||
},
|
},
|
||||||
KAIB: {
|
|
||||||
id: 'KAIB',
|
|
||||||
city: 'Nucla Hopkins Field Airport',
|
|
||||||
state: 'CO',
|
|
||||||
lat: 38.23875,
|
|
||||||
lon: -108.563277,
|
|
||||||
},
|
|
||||||
KAJZ: {
|
KAJZ: {
|
||||||
id: 'KAJZ',
|
id: 'KAJZ',
|
||||||
city: 'Delta/Blake Field Airport',
|
city: 'Delta/Blake Field Airport',
|
||||||
@@ -13415,7 +13415,7 @@ const StationInfo = {
|
|||||||
},
|
},
|
||||||
KBJC: {
|
KBJC: {
|
||||||
id: 'KBJC',
|
id: 'KBJC',
|
||||||
city: 'Broomfield / Jeffco',
|
city: 'Rocky Mountain Metro',
|
||||||
state: 'CO',
|
state: 'CO',
|
||||||
lat: 39.90085,
|
lat: 39.90085,
|
||||||
lon: -105.10417,
|
lon: -105.10417,
|
||||||
|
|||||||
@@ -114,11 +114,14 @@ class CurrentWeather extends WeatherDisplay {
|
|||||||
|
|
||||||
const wind = (typeof this.data.WindSpeed === 'number') ? this.data.WindDirection.padEnd(3, '') + this.data.WindSpeed.toString().padStart(3, ' ') : this.data.WindSpeed;
|
const wind = (typeof this.data.WindSpeed === 'number') ? this.data.WindDirection.padEnd(3, '') + this.data.WindSpeed.toString().padStart(3, ' ') : this.data.WindSpeed;
|
||||||
|
|
||||||
|
// get location (city name) from StationInfo if available (allows for overrides)
|
||||||
|
const location = (StationInfo[this.data.station.properties.stationIdentifier]?.city ?? locationCleanup(this.data.station.properties.name)).substr(0, 20);
|
||||||
|
|
||||||
const fill = {
|
const fill = {
|
||||||
temp: this.data.Temperature + String.fromCharCode(176),
|
temp: this.data.Temperature + String.fromCharCode(176),
|
||||||
condition,
|
condition,
|
||||||
wind,
|
wind,
|
||||||
location: locationCleanup(this.data.station.properties.name).substr(0, 20),
|
location,
|
||||||
humidity: `${this.data.Humidity}%`,
|
humidity: `${this.data.Humidity}%`,
|
||||||
dewpoint: this.data.DewPoint + String.fromCharCode(176),
|
dewpoint: this.data.DewPoint + String.fromCharCode(176),
|
||||||
ceiling: (this.data.Ceiling === 0 ? 'Unlimited' : this.data.Ceiling + this.data.CeilingUnit),
|
ceiling: (this.data.Ceiling === 0 ? 'Unlimited' : this.data.Ceiling + this.data.CeilingUnit),
|
||||||
|
|||||||
@@ -133,7 +133,10 @@ const baseScreens = [
|
|||||||
// hazards
|
// hazards
|
||||||
hazards,
|
hazards,
|
||||||
// station name
|
// station name
|
||||||
(data) => `Conditions at ${locationCleanup(data.station.properties.name).substr(0, 20)}`,
|
(data) => {
|
||||||
|
const location = (StationInfo[data.station.properties.stationIdentifier]?.city ?? locationCleanup(data.station.properties.name)).substr(0, 20);
|
||||||
|
return `Conditions at ${location}`;
|
||||||
|
},
|
||||||
|
|
||||||
// temperature
|
// temperature
|
||||||
(data) => {
|
(data) => {
|
||||||
|
|||||||
@@ -64,9 +64,11 @@ const getFeed = async (url) => {
|
|||||||
// this returns a data url
|
// this returns a data url
|
||||||
// a few sanity checks
|
// a few sanity checks
|
||||||
if (rssResponse.status.content_type.indexOf('xml') < 0) return;
|
if (rssResponse.status.content_type.indexOf('xml') < 0) return;
|
||||||
if (rssResponse.contents.indexOf('base64') > 100) return;
|
// determine return type
|
||||||
|
const isBase64 = rssResponse.status.content_type.substring(0, 8) !== 'text/xml';
|
||||||
|
|
||||||
// base 64 decode everything after the comma
|
// base 64 decode everything after the comma
|
||||||
const rss = atob(rssResponse.contents.split('base64,')[1]);
|
const rss = isBase64 ? atob(rssResponse.contents.split('base64,')[1]) : rssResponse.contents;
|
||||||
|
|
||||||
// parse the rss
|
// parse the rss
|
||||||
const doc = parser.parseFromString(rss, 'text/xml');
|
const doc = parser.parseFromString(rss, 'text/xml');
|
||||||
|
|||||||
35
static-env-handler.sh
Normal file → Executable file
35
static-env-handler.sh
Normal file → Executable file
@@ -4,22 +4,27 @@ set -eu
|
|||||||
ROOT="/usr/share/nginx/html"
|
ROOT="/usr/share/nginx/html"
|
||||||
QS=""
|
QS=""
|
||||||
|
|
||||||
|
# URL encode a string
|
||||||
|
url_encode() {
|
||||||
|
local string="$1"
|
||||||
|
printf '%s' "$string" | sed 's/ /%20/g; s/"/%22/g; s/</%3C/g; s/>/%3E/g; s/&/%26/g; s/#/%23/g; s/+/%2B/g'
|
||||||
|
}
|
||||||
|
|
||||||
# build query string from WSQS_ env vars
|
# build query string from WSQS_ env vars
|
||||||
for var in $(env); do
|
while IFS='=' read -r key val; do
|
||||||
case "$var" in
|
# Remove WSQS_ prefix and convert underscores to hyphens
|
||||||
WSQS_*=*)
|
key="${key#WSQS_}"
|
||||||
key="${var%%=*}"
|
key="${key//_/-}"
|
||||||
val="${var#*=}"
|
# URL encode the value
|
||||||
key="${key#WSQS_}"
|
encoded_val=$(url_encode "$val")
|
||||||
key="${key//_/-}"
|
if [ -n "$QS" ]; then
|
||||||
if [ -n "$QS" ]; then
|
QS="$QS&${key}=${encoded_val}"
|
||||||
QS="$QS&${key}=${val}"
|
else
|
||||||
else
|
QS="${key}=${encoded_val}"
|
||||||
QS="${key}=${val}"
|
fi
|
||||||
fi
|
done << EOF
|
||||||
;;
|
$(env | grep '^WSQS_')
|
||||||
esac
|
EOF
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$QS" ]; then
|
if [ -n "$QS" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user