Skip to content

lunatechza/kouga-fire-report

Repository files navigation

Kouga Fire Report (PWA)

A fully static, GitHub Pages–compatible wildfire reporting web app for Kouga Municipality. It lets residents send reports via WhatsApp or email, and logs a best‑effort copy to Firebase Firestore for cross‑referencing.

How it works

  • Users fill in visible signs, severity, size, spread, and optional notes.
  • GPS is optional; if unavailable, the nearest town/area is required.
  • Reports can be sent via WhatsApp or email, or copied to the clipboard.
  • A best‑effort Firestore log is created on WhatsApp/Email clicks.

Repository status (current)

  • Active static PWA: everything is served from the repo root (no build step).
  • Entry points: index.html (main UI), privacy.html, terms.html, disclaimer.html.
  • Runtime behavior: best‑effort logging to Firestore, optional geolocation, and offline caching via service-worker.js.
  • Dependencies: browser APIs + Firebase web SDK (loaded at runtime), with all config captured in app.js.

GitHub Pages setup

  1. Push the repo to GitHub.
  2. Go to Settings → Pages.
  3. Under Build and deployment, select Deploy from a branch.
  4. Choose Branch: main and Folder: / (root), then Save.
  5. Wait for Pages to publish, then open: https://lunatechza.github.io/kouga-fire-report/.

GitHub Pages serves over HTTPS, which is required for geolocation and Firebase.

Embedding and partner widgets (partner quick start)

Use the snippets below or open embed.html to generate copy‑paste snippets with live previews.

Quick start (copy/paste)

<script
  src="https://lunatechza.github.io/kouga-fire-report/widget.js"
  data-label="🔥 Report Fire"
  data-ref="station-23"
  data-source="embed"
  data-position="bottom-right"
></script>

The widget resolves its base URL from the script src so it stays GitHub Pages subpath‑safe.

Simple HTML button snippet

<a
  href="https://lunatechza.github.io/kouga-fire-report/?source=partner-site&ref=station-23&area=Humansdorp"
  target="_blank"
  rel="noopener noreferrer"
>
  🔥 Report Fire
</a>

Floating button snippet (no widget.js)

<a
  href="https://lunatechza.github.io/kouga-fire-report/?source=partner-site&ref=station-23&area=Humansdorp"
  target="_blank"
  rel="noopener noreferrer"
  style="
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
    background: #d7263d;
    color: #fff;
    padding: 12px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  "
>
  🔥 Report Fire
</a>

widget.js usage (preferred)

Include widget.js from the same host as the PWA. The script injects a floating button automatically.

<script
  src="https://lunatechza.github.io/kouga-fire-report/widget.js"
  data-label="🔥 Report Fire"
  data-ref="station-23"
  data-source="embed"
  data-position="bottom-right"
  data-version="1.1.0"
></script>

Widget configuration reference

Attribute Description Default
data-label Button text (use 🔥 if you want the fire emoji). 🔥 Report Fire
data-ref Partner or campaign reference (max 80 chars). (none)
data-source Source label (max 80 chars). embed
data-position bottom-right, bottom-left, top-right, or top-left. bottom-right
data-url Optional override of the base URL for the PWA. (auto)
data-version Optional widget version tag for logging. (none)

Position examples

<script src="https://lunatechza.github.io/kouga-fire-report/widget.js" data-position="bottom-right"></script>
<script src="https://lunatechza.github.io/kouga-fire-report/widget.js" data-position="bottom-left"></script>
<script src="https://lunatechza.github.io/kouga-fire-report/widget.js" data-position="top-right"></script>
<script src="https://lunatechza.github.io/kouga-fire-report/widget.js" data-position="top-left"></script>

Base URL notes

  • GitHub Pages hosts at https://<org>.github.io/<repo>/ so always include the repo path.
  • The widget uses its own src URL to stay subpath‑safe.
  • If you must override, set data-url to the full base URL ending in /.

Flutter (url_launcher) snippet

import 'package:url_launcher/url_launcher.dart';

Future<void> openKougaReport() async {
  final url = Uri.parse(
    'https://lunatechza.github.io/kouga-fire-report/?source=flutter&ref=my-app&area=Humansdorp',
  );
  if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
    throw 'Could not launch $url';
  }
}

Changelog

v1.1.0

  • Added partner widget v1.1.0 with idempotent injection and version tagging.
  • Added embed.html live demo generator with copy buttons.
  • Added client-side throttling + sanitized input handling in the PWA.
  • Added extra Firestore logging fields (session ID, widget version, submit channel).

Firebase + Firestore setup (logging)

  1. Create a Firebase project in the Firebase Console.
  2. Create a Firestore database (start in production or test mode as needed).
  3. Add a Web app in Firebase and copy the config values.
  4. Paste the config into app.js:
    const firebaseConfig = {
      apiKey: "...",
      authDomain: "...",
      projectId: "...",
      appId: "..."
    };
  5. Publish Firestore rules (see snippet below).

Anonymous Auth is not required right now. Enable it later only if you want authenticated reads from the app.

Firestore security rules (snippet)

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /fire_reports/{docId} {
      allow create: if true;
      allow read: if request.auth != null;
    }
  }
}

Legal pages

The app includes static pages at:

  • privacy.html
  • terms.html
  • disclaimer.html

Link to these from the main footer and header. Keep them in the repo root for GitHub Pages subpath compatibility.

Operational notes

  • All links are relative (e.g. ./privacy.html) so the app works under /<repo>/.
  • Replace the “Hosted at” placeholder in the footer once hosting is confirmed.
  • If you need to contact Lunatech about this app, open a GitHub issue at https://github.com/lunatechza/kouga-fire-report/issues.
  • Keep static assets in the repo root to preserve GitHub Pages compatibility.

Troubleshooting

  • If the app looks stale, do a hard refresh (Ctrl/Cmd+Shift+R).
  • Clear site data if the service worker or cache feels stuck (DevTools → Application → Clear storage).
  • After updates, unregister the old service worker or wait for it to refresh on the next load.

iOS install instructions

  1. Open the site in Safari.
  2. Tap Share.
  3. Tap Add to Home Screen.

About

A wild fire reporting tool for Kouga

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors