Add URL params parsing and concept of "embedded mode"

This commit is contained in:
Ian Renton
2025-11-30 11:26:15 +00:00
parent 8a82f81ec4
commit 9d130712d8
13 changed files with 143 additions and 49 deletions

View File

@@ -16,11 +16,44 @@ Supported data sources include DX Clusters, the Reverse Beacon Network (RBN), th
![Screenshot](/images/screenshot3.png)
### Accessing the public version
## Accessing the public version
You can access the public version's web interface at [https://spothole.app](https://spothole.app), and see [https://spothole.app/apidocs](https://spothole.app/apidocs) for the API details.
### Running your own copy
This is a Progressive Web App, so you can also "install" it to your Android or iOS device by accessing it in Chrome or Safari respectively, and following the menu-driven process for installing PWAs.
## Embedding Spothole in another website
You can embed Spothole in another website, e.g. for use as part of a ham radio custom dashboard.
URL parameters can be used to trigger an "embedded" mode which hides the headers, footers and settings. In this mode, you provide configuration for the various filter and display options via additional URL parameters. In this mode, any settings that the user has set for Spothole are ignored. This is so that the embedding site can select, for example, their choice of dark mode or SIG filters, which will not impact how Spothole appears when the user accesses it directly.
These are supplied with the URL to the page you want to embed, for example for an embedded version of the band map in dark mode, use `https://spothole.com/bands?embedded=true&dark-mode=true`. For an embedded version of the main spots/home page in the system light/dark mode, use `https://spothole.com/?embedded=true`. Providing no URL params causes the page to be loaded in the normal way it would when accessed directly in the user's browser.
The supported parameters are:
| Name | Allowed Values | Default | Example | Description |
|-------------|-----------------|---------|-------------------|------------------------|
| `embedded` | `true`, `false` | `false` | `?embedded=true` | Enables embedded mode. |
| `dark-mode` | `true`, `false` | `false` | `?dark-mode=true` | Enables dark mode. |
More will be added soon to allow customisation of filters and other display properties.
## Writing your own client
One of the key strengths of Spothole is that the API is well-defined and open to anyone to use. This means you can build your own software that uses data from Spothole.
Various approaches exist to writing your own client, but in general:
* Refer to the API docs. These are built on an OpenAPI definition file (`/webassets/apidocs/openapi.yml`), which you can automatically use to generate a client skeleton using various software.
* Call the main "spots" or "alerts" API endpoints to get the data you want. Apply filters if necessary.
* Call the "options" API to get an idea of which bands, modes etc. the server knows about. You might want to do that first before calling the spots/alerts APIs, to allow you to populate your filters correctly.
* Refer to the provided HTML/JS interface for a reference
* Let me know if you get stuck, I'm happy to help!
## Running your own copy
If you want to run a copy of Spothole with different configuration settings than the main instance, you can download it and run it on your own local machine or server.
To download and set up Spothole on a Debian server, run the following commands. Other operating systems will likely be similar.
@@ -139,17 +172,11 @@ You should now be able to access the web interface by going to the domain from y
Once that's working, [install certbot](https://certbot.eff.org/instructions?ws=nginx&os=snap) onto your server. Run it as root, and when prompted pick your domain name from the list. After a few seconds, it should successfully provision a certificate and modify your nginx config files automatically. You should then be able to access the site via HTTPS.
### Writing your own client
## Modifying the source code
Various approaches exist to writing your own client, but in general:
Spothole is Public Domain licenced, so you can grab the source code and start modifying it for your own needs. Contributions of code back to the main repository are encouraged, but completely optional.
* Refer to the API docs. These are built on an OpenAPI definition file (`/webassets/apidocs/openapi.yml`), which you can automatically use to generate a client skeleton using various software.
* Call the main "spots" or "alerts" API endpoints to get the data you want. Apply filters if necessary.
* Call the "options" API to get an idea of which bands, modes etc. the server knows about. You might want to do that first before calling the spots/alerts APIs, to allow you to populate your filters correctly.
* Refer to the provided HTML/JS interface for a reference
* Let me know if you get stuck, I'm happy to help!
### Structure of the source code
### Code structure
To navigate your way around the source code, this list may help.
@@ -198,7 +225,7 @@ Finally, simply add the appropriate config to the `spot_providers` section of `c
The same approach as above is also used for alert providers.
### Thanks
## Thanks
As well as being my work, I have also gratefully received feature patches from Steven, M1SDH.