mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-23 11:26:16 +00:00
NEW: @@@LABEL@@@ in view HTML is replaced by view's label attribute
This commit is contained in:
@@ -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`.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>OwnTracks View</title>
|
||||
<title>OwnTracks @@@LABEL@@@</title>
|
||||
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0">
|
||||
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user