diff --git a/README.md b/README.md index ed4f9b8..a5af79f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # potato-mesh - a simple meshtastic node dashboard for your local community. here: berlin mediumfast. +a simple meshtastic node dashboard for your local community. - demo: [potatomesh.net](https://potatomesh.net) +demo for berlin mediumfast: [potatomesh.net](https://potatomesh.net) -  + ## status @@ -24,7 +24,6 @@ what works: what does not work _(yet):_ * posting nodes and messages to the api endpoints _(wip)_ -* white-label for your community (need to updated some berlin-specific hardcoded stuff) ## requirements @@ -81,6 +80,20 @@ Puma starting in single mode... set `API_TOKEN` required for authorizations on the api post-endpoints (wip). +the web app can be configured with environment variables (defaults shown): + +* `SITE_NAME` - title and header shown in the ui (default: "Meshtastic Berlin") +* `DEFAULT_CHANNEL` - default channel shown in the ui (default: "#MediumFast") +* `MAP_CENTER_LAT` / `MAP_CENTER_LON` - default map center coordinates (default: `52.502889` / `13.404194`) +* `MAX_NODE_DISTANCE_KM` - hide nodes farther than this distance from the center (default: `137`) +* `MATRIX_ROOM` - matrix room id for a footer link (default: `#meshtastic-berlin:matrix.org`) + +example: + +```bash +SITE_NAME="Meshtastic Berlin" MAP_CENTER_LAT=52.502889 MAP_CENTER_LON=13.404194 MAX_NODE_DISTANCE_KM=137 MATRIX_ROOM="#meshtastic-berlin:matrix.org" ./app.sh +``` + ## api the web app contains an api: diff --git a/web/app.rb b/web/app.rb index 51b9119..e045ff3 100644 --- a/web/app.rb +++ b/web/app.rb @@ -8,6 +8,14 @@ DB_PATH = ENV.fetch("MESH_DB", File.join(__dir__, "../data/mesh.db")) WEEK_SECONDS = 7 * 24 * 60 * 60 set :public_folder, File.join(__dir__, "public") +set :views, File.join(__dir__, "views") + +SITE_NAME = ENV.fetch("SITE_NAME", "Meshtastic Berlin") +DEFAULT_CHANNEL = ENV.fetch("DEFAULT_CHANNEL", "#MediumFast") +MAP_CENTER_LAT = ENV.fetch("MAP_CENTER_LAT", "52.502889").to_f +MAP_CENTER_LON = ENV.fetch("MAP_CENTER_LON", "13.404194").to_f +MAX_NODE_DISTANCE_KM = ENV.fetch("MAX_NODE_DISTANCE_KM", "137").to_f +MATRIX_ROOM = ENV.fetch("MATRIX_ROOM", "#meshtastic-berlin:matrix.org") def query_nodes(limit) db = SQLite3::Database.new(DB_PATH, readonly: true, results_as_hash: true) @@ -155,5 +163,12 @@ ensure end get "/" do - send_file File.join(settings.public_folder, "index.html") + erb :index, locals: { + site_name: SITE_NAME, + default_channel: DEFAULT_CHANNEL, + map_center_lat: MAP_CENTER_LAT, + map_center_lon: MAP_CENTER_LON, + max_node_distance_km: MAX_NODE_DISTANCE_KM, + matrix_room: MATRIX_ROOM + } end diff --git a/web/public/.keep b/web/public/.keep new file mode 100644 index 0000000..e69de29 diff --git a/web/public/index.html b/web/views/index.erb similarity index 96% rename from web/public/index.html rename to web/views/index.erb index 13cfc1f..50c412c 100644 --- a/web/public/index.html +++ b/web/views/index.erb @@ -3,7 +3,7 @@
-