mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-27 16:57:21 +00:00
@@ -267,6 +267,8 @@ This section lists the most important options of the Recorder with their long na
|
||||
|
||||
`--docroot` overrides the compile-time setting of the HTTP document root.
|
||||
|
||||
`--viewsdir` overrides the path to the JSON views, which defaults to `<docroot>/views`.
|
||||
|
||||
`--lua-script` specifies the path to the Lua script. If not given, Lua support is disabled.
|
||||
|
||||
`--precision` overrides the compiled-in default. (See "Precision" later.)
|
||||
@@ -831,6 +833,8 @@ All JSON elements are copied into the `lastpos` data which is returned to the ca
|
||||
|
||||
Note how `pathname` and `port` have been copied into the object. These values can be used by the `page` served in the view.
|
||||
|
||||
Recall that while we typically say `htdocs/views/` this path is actually configurable with the `--viewsdir` option.
|
||||
|
||||
### Authentication
|
||||
|
||||
If `view.json` contains an element called `auth`, it is assumed to be an array of strings, each of which are a 32-character [Digest authentication](https://en.wikipedia.org/wiki/Digest_access_authentication) SHA1 strings for the realm `owntracks-recorder`, for example:
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#ifdef WITH_HTTP
|
||||
|
||||
#define MAXPARTS 40
|
||||
#define VIEWSUBDIR "views"
|
||||
|
||||
/* A transparent 40x40 PNG image with a black border */
|
||||
static unsigned char border40x40png[] = {
|
||||
@@ -132,11 +131,10 @@ static long *field_n(struct mg_connection *conn, char *fieldname)
|
||||
static JsonNode *loadview(struct udata *ud, const char *viewname)
|
||||
{
|
||||
static UT_string *fpath = NULL;
|
||||
const char *doc_root = mg_get_option(ud->mgserver, "document_root");
|
||||
JsonNode *view;
|
||||
|
||||
utstring_renew(fpath);
|
||||
utstring_printf(fpath, "%s/%s/%s.json", doc_root, VIEWSUBDIR, viewname);
|
||||
utstring_printf(fpath, "%s/%s.json", ud->viewsdir, viewname);
|
||||
debug(ud, "loadview fpath=%s", UB(fpath));
|
||||
|
||||
view = json_mkobject();
|
||||
@@ -905,7 +903,6 @@ static int view(struct mg_connection *conn, const char *viewname)
|
||||
struct udata *ud = (struct udata *)conn->server_param;
|
||||
int limit;
|
||||
char *p, buf[BUFSIZ];
|
||||
const char *doc_root = mg_get_option(ud->mgserver, "document_root");
|
||||
static UT_string *fpath = NULL, *sbuf = NULL;
|
||||
FILE *fp;
|
||||
JsonNode *view, *j, *locarray, *obj, *loc, *geoline;
|
||||
@@ -946,7 +943,7 @@ static int view(struct mg_connection *conn, const char *viewname)
|
||||
}
|
||||
|
||||
utstring_renew(fpath);
|
||||
utstring_printf(fpath, "%s/%s/%s", doc_root, VIEWSUBDIR, j->string_);
|
||||
utstring_printf(fpath, "%s/%s", ud->viewsdir, j->string_);
|
||||
debug(ud, "page file=%s", UB(fpath));
|
||||
|
||||
if ((fp = fopen(UB(fpath), "r")) == NULL) {
|
||||
|
||||
+12
-1
@@ -1162,6 +1162,7 @@ void usage(char *prog)
|
||||
printf(" --doc-root <directory> document root (%s)\n", DOCROOT);
|
||||
printf(" --http-logdir <directory> directory in which to store access.log\n");
|
||||
printf(" --browser-apikey <key> Google maps browser API key\n");
|
||||
printf(" --viewsdir <directory> full path to JSON views. Default: (%s/views)\n", DOCROOT);
|
||||
#endif
|
||||
#ifdef WITH_LUA
|
||||
printf(" --lua-script <script.lua> path to Lua script. If unset, no Lua hooks\n");
|
||||
@@ -1190,7 +1191,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
#if WITH_MQTT
|
||||
struct mosquitto *mosq = NULL;
|
||||
UT_string *clientid;
|
||||
UT_string *clientid, *uviewsdir;
|
||||
int rc, i;
|
||||
struct utsname uts;
|
||||
bool do_tls = false;
|
||||
@@ -1238,6 +1239,10 @@ int main(int argc, char **argv)
|
||||
udata.http_port = 8083;
|
||||
udata.http_logdir = NULL;
|
||||
udata.browser_apikey = NULL;
|
||||
udata.viewsdir = NULL;
|
||||
|
||||
utstring_new(uviewsdir);
|
||||
utstring_printf(uviewsdir, "%s/views", DOCROOT);
|
||||
#endif
|
||||
#ifdef WITH_LUA
|
||||
udata.luascript = NULL;
|
||||
@@ -1360,6 +1365,7 @@ int main(int argc, char **argv)
|
||||
{ "doc-root", required_argument, 0, 2},
|
||||
{ "http-logdir", required_argument, 0, 14},
|
||||
{ "browser-apikey", required_argument, 0, 15},
|
||||
{ "viewsdir", required_argument, 0, 16},
|
||||
#endif
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
@@ -1455,6 +1461,10 @@ int main(int argc, char **argv)
|
||||
if (ud->browser_apikey) free(ud->browser_apikey);
|
||||
ud->browser_apikey = strdup(optarg);
|
||||
break;
|
||||
case 16:
|
||||
if (ud->viewsdir) free(ud->viewsdir);
|
||||
ud->viewsdir = strdup(optarg);
|
||||
break;
|
||||
#endif
|
||||
case 'D':
|
||||
ud->skipdemo = FALSE;
|
||||
@@ -1804,6 +1814,7 @@ int main(int argc, char **argv)
|
||||
mg_destroy_server(&udata.mgserver);
|
||||
free(ud->http_host);
|
||||
free(ud->browser_apikey);
|
||||
free(ud->viewsdir);
|
||||
if (ud->http_logdir) free(ud->http_logdir);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ struct udata {
|
||||
int http_port; /* port number for above */
|
||||
char *http_logdir; /* full path to http access log */
|
||||
char *browser_apikey; /* Google maps browser API key */
|
||||
char *viewsdir; /* path to views directory */
|
||||
#endif
|
||||
#ifdef WITH_LUA
|
||||
char *luascript; /* Path to Lua script */
|
||||
|
||||
Reference in New Issue
Block a user