diff --git a/README.md b/README.md index 925a430..7de5a76 100644 --- a/README.md +++ b/README.md @@ -770,6 +770,7 @@ The `page` is a single HTML file which must be located in the `views/` directory * `@@@LASTPOS@@@` is converted to a URI on which the Recorder will serve the last position data * `@@@GEO@@@` is converted to a URI on which the Recorder will serve GeoJSON data from its storage. +* `@@@LABEL@@@` is replaced with the `label` attribute from the page's JSON or the empty string if that doesn't exist. The default `page` we provide is called `vmap.html`; by default it refreshes the last position every 60 seconds, and clicking on "Load track" loads the GeoJSON track for the time frame specified by `from` and `to`. diff --git a/docroot/views/leafletmap.html b/docroot/views/leafletmap.html index c28e7b8..80bacd4 100644 --- a/docroot/views/leafletmap.html +++ b/docroot/views/leafletmap.html @@ -2,7 +2,7 @@ - OwnTracks View + OwnTracks @@@LABEL@@@ diff --git a/http.c b/http.c index fe5d1fe..da3cd4a 100644 --- a/http.c +++ b/http.c @@ -985,6 +985,21 @@ static int view(struct mg_connection *conn, const char *viewname) viewname, // conn->uri, p+strlen("@@@LASTPOS@@@")); mg_printf_data(conn, "%s", UB(sbuf)); + } else if ((p = strstr(buf, "@@@LABEL@@@")) != NULL) { + char *label; + JsonNode *t; + if ((t = json_find_member(view, "label")) == NULL) { + label = ""; + } else { + label = t->string_; + } + *p = 0; + utstring_clear(sbuf); + utstring_printf(sbuf, "%s%s%s", + buf, + label, + p+strlen("@@@LABEL@@@")); + mg_printf_data(conn, "%s", UB(sbuf)); } else { mg_printf_data(conn, "%s", buf); }