mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 10:16:42 +00:00
commit
a6d2afc8dc
@ -18,7 +18,7 @@ sist2 (Simple incremental search tool)
|
|||||||
* Extracts text and metadata from common file types \*
|
* Extracts text and metadata from common file types \*
|
||||||
* Generates thumbnails \*
|
* Generates thumbnails \*
|
||||||
* Incremental scanning
|
* Incremental scanning
|
||||||
* Automatic tagging from file attributes via [user scripts](docs/scripting.md)
|
* Manual tagging from the UI and automatic tagging based on file attributes via [user scripts](docs/scripting.md)
|
||||||
* Recursive scan inside archive files \*\*
|
* Recursive scan inside archive files \*\*
|
||||||
* OCR support with tesseract \*\*\*
|
* OCR support with tesseract \*\*\*
|
||||||
* Stats page & disk utilisation visualization
|
* Stats page & disk utilisation visualization
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* [rewrite_url](#rewrite_url)
|
* [rewrite_url](#rewrite_url)
|
||||||
* [link to specific indices](#link-to-specific-indices)
|
* [link to specific indices](#link-to-specific-indices)
|
||||||
* [exec-script](#exec-script)
|
* [exec-script](#exec-script)
|
||||||
|
* [tagging](#tagging)
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: sist2 scan [OPTION]... PATH
|
Usage: sist2 scan [OPTION]... PATH
|
||||||
@ -57,6 +58,7 @@ Web options
|
|||||||
--es-url=<str> Elasticsearch url. DEFAULT=http://localhost:9200
|
--es-url=<str> Elasticsearch url. DEFAULT=http://localhost:9200
|
||||||
--bind=<str> Listen on this address. DEFAULT=localhost:4090
|
--bind=<str> Listen on this address. DEFAULT=localhost:4090
|
||||||
--auth=<str> Basic auth in user:password format
|
--auth=<str> Basic auth in user:password format
|
||||||
|
--tag-auth=<str> Basic auth in user:password format for tagging
|
||||||
|
|
||||||
Exec-script options
|
Exec-script options
|
||||||
--script-file=<str> Path to user script.
|
--script-file=<str> Path to user script.
|
||||||
@ -145,7 +147,10 @@ documents.idx/
|
|||||||
├── agg_mime.csv
|
├── agg_mime.csv
|
||||||
├── agg_date.csv
|
├── agg_date.csv
|
||||||
├── add_size.csv
|
├── add_size.csv
|
||||||
└── thumbs
|
├── thumbs
|
||||||
|
| ├── data.mdb
|
||||||
|
| └── lock.mdb
|
||||||
|
└── tags
|
||||||
├── data.mdb
|
├── data.mdb
|
||||||
└── lock.mdb
|
└── lock.mdb
|
||||||
```
|
```
|
||||||
@ -270,6 +275,8 @@ sist2 index --print ./my_index/ | jq | less
|
|||||||
* `--es-url=<str>` Elasticsearch url.
|
* `--es-url=<str>` Elasticsearch url.
|
||||||
* `--bind=<str>` Listen on this address.
|
* `--bind=<str>` Listen on this address.
|
||||||
* `--auth=<str>` Basic auth in user:password format
|
* `--auth=<str>` Basic auth in user:password format
|
||||||
|
* `--tag-auth=<str>` Basic auth in user:password format. Works the same way as the
|
||||||
|
`--auth` argument, but authentication is only applied the `/tag/` endpoint.
|
||||||
|
|
||||||
### Web examples
|
### Web examples
|
||||||
|
|
||||||
@ -301,3 +308,31 @@ not displayed.
|
|||||||
## exec-script
|
## exec-script
|
||||||
|
|
||||||
The `exec-script` command is used to execute a user script for an index that has already been imported to Elasticsearch with the `index` command. Note that the documents will not be reset to their default state before each execution as the `index` command does: if you make undesired changes to the documents by accident, you will need to run `index` again to revert to the original state.
|
The `exec-script` command is used to execute a user script for an index that has already been imported to Elasticsearch with the `index` command. Note that the documents will not be reset to their default state before each execution as the `index` command does: if you make undesired changes to the documents by accident, you will need to run `index` again to revert to the original state.
|
||||||
|
|
||||||
|
|
||||||
|
# Tagging
|
||||||
|
|
||||||
|
### Manual tagging
|
||||||
|
|
||||||
|
You can modify tags of individual documents directly from the
|
||||||
|
`web` interface. Note that you can setup authentication for this feature
|
||||||
|
with the `--tag-auth` option (See [web options](#web-options))
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Tags that are manually added are saved both in the
|
||||||
|
index folder (in `/tags/`) and in Elasticsearch*. When re-`index`ing,
|
||||||
|
they are read from the index and automatically applied.
|
||||||
|
|
||||||
|
You can safely copy the `/tags/` database to another index.
|
||||||
|
|
||||||
|
See [Automatic tagging](#automatic-tagging) for information about tag
|
||||||
|
hierarchies and tag colors.
|
||||||
|
|
||||||
|
\* *It can take a few seconds to take effect in new search queries, and the page needs
|
||||||
|
to be reloaded for the tag tab to update*
|
||||||
|
|
||||||
|
|
||||||
|
### Automatic tagging
|
||||||
|
|
||||||
|
See [scripting](docs/scripting.md) documentation.
|
BIN
docs/manual_tag.png
Normal file
BIN
docs/manual_tag.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@ -126,7 +126,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tag": {
|
"tag": {
|
||||||
"type": "keyword"
|
"type": "keyword",
|
||||||
|
"copy_to": "suggest-tag"
|
||||||
|
},
|
||||||
|
"suggest-tag": {
|
||||||
|
"type": "completion",
|
||||||
|
"analyzer": "case_insensitive_kw_analyzer"
|
||||||
},
|
},
|
||||||
"exif_make": {
|
"exif_make": {
|
||||||
"type": "text"
|
"type": "text"
|
||||||
|
28
src/cli.c
28
src/cli.c
@ -326,7 +326,7 @@ int web_args_validate(web_args_t *args, int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strncpy(args->auth_user, args->credentials, (ptr - args->credentials));
|
strncpy(args->auth_user, args->credentials, (ptr - args->credentials));
|
||||||
strncpy(args->auth_pass, ptr + 1, strlen(ptr + 1));
|
strcpy(args->auth_pass, ptr + 1);
|
||||||
|
|
||||||
if (strlen(args->auth_user) == 0) {
|
if (strlen(args->auth_user) == 0) {
|
||||||
fprintf(stderr, "--auth username must be at least one character long");
|
fprintf(stderr, "--auth username must be at least one character long");
|
||||||
@ -338,6 +338,31 @@ int web_args_validate(web_args_t *args, int argc, const char **argv) {
|
|||||||
args->auth_enabled = FALSE;
|
args->auth_enabled = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args->tag_credentials != NULL && args->credentials != NULL) {
|
||||||
|
fprintf(stderr, "--auth and --tag-auth are mutually exclusive");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->tag_credentials != NULL) {
|
||||||
|
char *ptr = strstr(args->tag_credentials, ":");
|
||||||
|
if (ptr == NULL) {
|
||||||
|
fprintf(stderr, "Invalid --tag-auth format, see usage\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(args->auth_user, args->tag_credentials, (ptr - args->tag_credentials));
|
||||||
|
strcpy(args->auth_pass, ptr + 1);
|
||||||
|
|
||||||
|
if (strlen(args->auth_user) == 0) {
|
||||||
|
fprintf(stderr, "--tag-auth username must be at least one character long");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
args->tag_auth_enabled = TRUE;
|
||||||
|
} else {
|
||||||
|
args->tag_auth_enabled = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
args->index_count = argc - 1;
|
args->index_count = argc - 1;
|
||||||
args->indices = argv + 1;
|
args->indices = argv + 1;
|
||||||
|
|
||||||
@ -352,6 +377,7 @@ int web_args_validate(web_args_t *args, int argc, const char **argv) {
|
|||||||
LOG_DEBUGF("cli.c", "arg es_url=%s", args->es_url)
|
LOG_DEBUGF("cli.c", "arg es_url=%s", args->es_url)
|
||||||
LOG_DEBUGF("cli.c", "arg listen=%s", args->listen_address)
|
LOG_DEBUGF("cli.c", "arg listen=%s", args->listen_address)
|
||||||
LOG_DEBUGF("cli.c", "arg credentials=%s", args->credentials)
|
LOG_DEBUGF("cli.c", "arg credentials=%s", args->credentials)
|
||||||
|
LOG_DEBUGF("cli.c", "arg tag_credentials=%s", args->tag_credentials)
|
||||||
LOG_DEBUGF("cli.c", "arg auth_user=%s", args->auth_user)
|
LOG_DEBUGF("cli.c", "arg auth_user=%s", args->auth_user)
|
||||||
LOG_DEBUGF("cli.c", "arg auth_pass=%s", args->auth_pass)
|
LOG_DEBUGF("cli.c", "arg auth_pass=%s", args->auth_pass)
|
||||||
LOG_DEBUGF("cli.c", "arg index_count=%d", args->index_count)
|
LOG_DEBUGF("cli.c", "arg index_count=%d", args->index_count)
|
||||||
|
@ -48,9 +48,11 @@ typedef struct web_args {
|
|||||||
char *es_url;
|
char *es_url;
|
||||||
char *listen_address;
|
char *listen_address;
|
||||||
char *credentials;
|
char *credentials;
|
||||||
|
char *tag_credentials;
|
||||||
char auth_user[256];
|
char auth_user[256];
|
||||||
char auth_pass[256];
|
char auth_pass[256];
|
||||||
int auth_enabled;
|
int auth_enabled;
|
||||||
|
int tag_auth_enabled;
|
||||||
int index_count;
|
int index_count;
|
||||||
const char **indices;
|
const char **indices;
|
||||||
} web_args_t;
|
} web_args_t;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "libscan/text/text.h"
|
#include "libscan/text/text.h"
|
||||||
#include "libscan/mobi/scan_mobi.h"
|
#include "libscan/mobi/scan_mobi.h"
|
||||||
#include "libscan/raw/raw.h"
|
#include "libscan/raw/raw.h"
|
||||||
|
#include "src/io/store.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <pcre.h>
|
#include <pcre.h>
|
||||||
@ -59,6 +60,8 @@ typedef struct {
|
|||||||
char *es_url;
|
char *es_url;
|
||||||
int batch_size;
|
int batch_size;
|
||||||
tpool_t *pool;
|
tpool_t *pool;
|
||||||
|
store_t *tag_store;
|
||||||
|
GHashTable *tags;
|
||||||
} IndexCtx_t;
|
} IndexCtx_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -67,6 +70,7 @@ typedef struct {
|
|||||||
char *auth_user;
|
char *auth_user;
|
||||||
char *auth_pass;
|
char *auth_pass;
|
||||||
int auth_enabled;
|
int auth_enabled;
|
||||||
|
int tag_auth_enabled;
|
||||||
struct index_t indices[64];
|
struct index_t indices[64];
|
||||||
} WebCtx_t;
|
} WebCtx_t;
|
||||||
|
|
||||||
|
@ -313,6 +313,11 @@ void finish_indexer(char *script, char *index_id) {
|
|||||||
r = web_post(url, "");
|
r = web_post(url, "");
|
||||||
LOG_INFOF("elastic.c", "Merge index <%d>", r->status_code);
|
LOG_INFOF("elastic.c", "Merge index <%d>", r->status_code);
|
||||||
free_response(r);
|
free_response(r);
|
||||||
|
|
||||||
|
snprintf(url, sizeof(url), "%s/sist2/_settings", IndexCtx.es_url);
|
||||||
|
r = web_put(url, "{\"index\":{\"refresh_interval\":\"1s\"}}");
|
||||||
|
LOG_INFOF("elastic.c", "Set refresh interval <%d>", r->status_code);
|
||||||
|
free_response(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void elastic_init(int force_reset) {
|
void elastic_init(int force_reset) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -62,7 +62,7 @@ index_descriptor_t read_index_descriptor(char *path) {
|
|||||||
int fd = open(path, O_RDONLY);
|
int fd = open(path, O_RDONLY);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
LOG_FATALF("serialize.c", "Invalid/corrupt index (Could not find descriptor): %s: %s\n", path ,strerror(errno))
|
LOG_FATALF("serialize.c", "Invalid/corrupt index (Could not find descriptor): %s: %s\n", path, strerror(errno))
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buf = malloc(info.st_size + 1);
|
char *buf = malloc(info.st_size + 1);
|
||||||
@ -172,8 +172,8 @@ void write_document(document_t *doc) {
|
|||||||
dyn_buffer_t buf = dyn_buffer_create();
|
dyn_buffer_t buf = dyn_buffer_create();
|
||||||
|
|
||||||
// Ignore root directory in the file path
|
// Ignore root directory in the file path
|
||||||
doc->ext = doc->ext - ScanCtx.index.desc.root_len;
|
doc->ext = (short) (doc->ext - ScanCtx.index.desc.root_len);
|
||||||
doc->base = doc->base - ScanCtx.index.desc.root_len;
|
doc->base = (short) (doc->base - ScanCtx.index.desc.root_len);
|
||||||
doc->filepath += ScanCtx.index.desc.root_len;
|
doc->filepath += ScanCtx.index.desc.root_len;
|
||||||
|
|
||||||
dyn_buffer_write(&buf, doc, sizeof(line_t));
|
dyn_buffer_write(&buf, doc, sizeof(line_t));
|
||||||
@ -230,7 +230,7 @@ void read_index_bin(const char *path, const char *index_id, index_func func) {
|
|||||||
char uuid_str[UUID_STR_LEN];
|
char uuid_str[UUID_STR_LEN];
|
||||||
uuid_unparse(line.uuid, uuid_str);
|
uuid_unparse(line.uuid, uuid_str);
|
||||||
|
|
||||||
const char* mime_text = mime_get_mime_text(line.mime);
|
const char *mime_text = mime_get_mime_text(line.mime);
|
||||||
if (mime_text == NULL) {
|
if (mime_text == NULL) {
|
||||||
cJSON_AddNullToObject(document, "mime");
|
cJSON_AddNullToObject(document, "mime");
|
||||||
} else {
|
} else {
|
||||||
@ -239,12 +239,18 @@ void read_index_bin(const char *path, const char *index_id, index_func func) {
|
|||||||
cJSON_AddNumberToObject(document, "size", (double) line.size);
|
cJSON_AddNumberToObject(document, "size", (double) line.size);
|
||||||
cJSON_AddNumberToObject(document, "mtime", line.mtime);
|
cJSON_AddNumberToObject(document, "mtime", line.mtime);
|
||||||
|
|
||||||
int c;
|
int c = 0;
|
||||||
while ((c = getc(file)) != 0) {
|
while ((c = getc(file)) != 0) {
|
||||||
dyn_buffer_write_char(&buf, (char) c);
|
dyn_buffer_write_char(&buf, (char) c);
|
||||||
}
|
}
|
||||||
dyn_buffer_write_char(&buf, '\0');
|
dyn_buffer_write_char(&buf, '\0');
|
||||||
|
|
||||||
|
const char *tags_string = g_hash_table_lookup(IndexCtx.tags, buf.buf);
|
||||||
|
if (tags_string != NULL) {
|
||||||
|
cJSON *tags_arr = cJSON_Parse(tags_string);
|
||||||
|
cJSON_AddItemToObject(document, "tag", tags_arr);
|
||||||
|
}
|
||||||
|
|
||||||
cJSON_AddStringToObject(document, "extension", buf.buf + line.ext);
|
cJSON_AddStringToObject(document, "extension", buf.buf + line.ext);
|
||||||
if (*(buf.buf + line.ext - 1) == '.') {
|
if (*(buf.buf + line.ext - 1) == '.') {
|
||||||
*(buf.buf + line.ext - 1) = '\0';
|
*(buf.buf + line.ext - 1) = '\0';
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "store.h"
|
#include "store.h"
|
||||||
#include "src/ctx.h"
|
#include "src/ctx.h"
|
||||||
|
|
||||||
store_t *store_create(char *path) {
|
store_t *store_create(char *path, size_t chunk_size) {
|
||||||
|
|
||||||
store_t *store = malloc(sizeof(struct store_t));
|
store_t *store = malloc(sizeof(struct store_t));
|
||||||
|
store->chunk_size = chunk_size;
|
||||||
pthread_rwlock_init(&store->lock, NULL);
|
pthread_rwlock_init(&store->lock, NULL);
|
||||||
|
|
||||||
mdb_env_create(&store->env);
|
mdb_env_create(&store->env);
|
||||||
@ -18,7 +19,7 @@ store_t *store_create(char *path) {
|
|||||||
LOG_FATALF("store.c", "Error while opening store: %s (%s)\n", mdb_strerror(open_ret), path)
|
LOG_FATALF("store.c", "Error while opening store: %s (%s)\n", mdb_strerror(open_ret), path)
|
||||||
}
|
}
|
||||||
|
|
||||||
store->size = (size_t) 1024 * 1024 * 5;
|
store->size = (size_t) store->chunk_size;
|
||||||
ScanCtx.stat_tn_size = 0;
|
ScanCtx.stat_tn_size = 0;
|
||||||
mdb_env_set_mapsize(store->env, store->size);
|
mdb_env_set_mapsize(store->env, store->size);
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ void store_write(store_t *store, char *key, size_t key_len, char *buf, size_t bu
|
|||||||
// Cannot resize when there is a opened transaction.
|
// Cannot resize when there is a opened transaction.
|
||||||
// Resize take effect on the next commit.
|
// Resize take effect on the next commit.
|
||||||
pthread_rwlock_wrlock(&store->lock);
|
pthread_rwlock_wrlock(&store->lock);
|
||||||
store->size += 1024 * 1024 * 50;
|
store->size += store->chunk_size;
|
||||||
mdb_env_set_mapsize(store->env, store->size);
|
mdb_env_set_mapsize(store->env, store->size);
|
||||||
mdb_txn_begin(store->env, NULL, 0, &txn);
|
mdb_txn_begin(store->env, NULL, 0, &txn);
|
||||||
put_ret = mdb_put(txn, store->dbi, &mdb_key, &mdb_value, 0);
|
put_ret = mdb_put(txn, store->dbi, &mdb_key, &mdb_value, 0);
|
||||||
@ -110,3 +111,35 @@ char *store_read(store_t *store, char *key, size_t key_len, size_t *ret_vallen)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GHashTable *store_read_all(store_t *store) {
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
GHashTable *table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
|
||||||
|
|
||||||
|
MDB_txn *txn = NULL;
|
||||||
|
mdb_txn_begin(store->env, NULL, MDB_RDONLY, &txn);
|
||||||
|
|
||||||
|
MDB_cursor *cur = NULL;
|
||||||
|
mdb_cursor_open(txn, store->dbi, &cur);
|
||||||
|
|
||||||
|
MDB_val key;
|
||||||
|
MDB_val value;
|
||||||
|
|
||||||
|
while (mdb_cursor_get(cur, &key, &value, MDB_NEXT) == 0) {
|
||||||
|
char *key_str = malloc(key.mv_size);
|
||||||
|
memcpy(key_str, key.mv_data, key.mv_size);
|
||||||
|
char *val_str = malloc(value.mv_size);
|
||||||
|
memcpy(val_str, value.mv_data, value.mv_size);
|
||||||
|
|
||||||
|
g_hash_table_insert(table, key_str, val_str);
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUGF("store.c", "Read tags for %d documents", count);
|
||||||
|
|
||||||
|
mdb_cursor_close(cur);
|
||||||
|
mdb_txn_abort(txn);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,14 +4,20 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <lmdb.h>
|
#include <lmdb.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#define STORE_SIZE_TN 1024 * 1024 * 5
|
||||||
|
#define STORE_SIZE_TAG 1024 * 16
|
||||||
|
|
||||||
typedef struct store_t {
|
typedef struct store_t {
|
||||||
MDB_dbi dbi;
|
MDB_dbi dbi;
|
||||||
MDB_env *env;
|
MDB_env *env;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
size_t chunk_size;
|
||||||
pthread_rwlock_t lock;
|
pthread_rwlock_t lock;
|
||||||
} store_t;
|
} store_t;
|
||||||
|
|
||||||
store_t *store_create(char *path);
|
store_t *store_create(char *path, size_t chunk_size);
|
||||||
|
|
||||||
void store_destroy(store_t *store);
|
void store_destroy(store_t *store);
|
||||||
|
|
||||||
@ -19,4 +25,6 @@ void store_write(store_t *store, char *key, size_t key_len, char *buf, size_t bu
|
|||||||
|
|
||||||
char *store_read(store_t *store, char *key, size_t key_len, size_t *ret_vallen);
|
char *store_read(store_t *store, char *key, size_t key_len, size_t *ret_vallen);
|
||||||
|
|
||||||
|
GHashTable *store_read_all(store_t *store);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
25
src/main.c
25
src/main.c
@ -21,7 +21,7 @@
|
|||||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||||
|
|
||||||
|
|
||||||
static const char *const Version = "2.5.2";
|
static const char *const Version = "2.6.0";
|
||||||
static const char *const usage[] = {
|
static const char *const usage[] = {
|
||||||
"sist2 scan [OPTION]... PATH",
|
"sist2 scan [OPTION]... PATH",
|
||||||
"sist2 index [OPTION]... INDEX",
|
"sist2 index [OPTION]... INDEX",
|
||||||
@ -176,7 +176,7 @@ void sist2_scan(scan_args_t *args) {
|
|||||||
char store_path[PATH_MAX];
|
char store_path[PATH_MAX];
|
||||||
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
||||||
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
||||||
ScanCtx.index.store = store_create(store_path);
|
ScanCtx.index.store = store_create(store_path, STORE_SIZE_TN);
|
||||||
|
|
||||||
scan_print_header();
|
scan_print_header();
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ void sist2_scan(scan_args_t *args) {
|
|||||||
char dst_path[PATH_MAX];
|
char dst_path[PATH_MAX];
|
||||||
snprintf(store_path, PATH_MAX, "%sthumbs", args->incremental);
|
snprintf(store_path, PATH_MAX, "%sthumbs", args->incremental);
|
||||||
snprintf(dst_path, PATH_MAX, "%s_index_original", ScanCtx.index.path);
|
snprintf(dst_path, PATH_MAX, "%s_index_original", ScanCtx.index.path);
|
||||||
store_t *source = store_create(store_path);
|
store_t *source = store_create(store_path, STORE_SIZE_TN);
|
||||||
|
|
||||||
DIR *dir = opendir(args->incremental);
|
DIR *dir = opendir(args->incremental);
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
@ -271,6 +271,12 @@ void sist2_index(index_args_t *args) {
|
|||||||
LOG_FATALF("main.c", "Could not open index %s: %s", args->index_path, strerror(errno))
|
LOG_FATALF("main.c", "Could not open index %s: %s", args->index_path, strerror(errno))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char path_tmp[PATH_MAX];
|
||||||
|
snprintf(path_tmp, sizeof(path_tmp), "%s/tags", args->index_path);
|
||||||
|
mkdir(path_tmp, S_IWUSR | S_IRUSR | S_IXUSR);
|
||||||
|
IndexCtx.tag_store = store_create(path_tmp, STORE_SIZE_TAG);
|
||||||
|
IndexCtx.tags = store_read_all(IndexCtx.tag_store);
|
||||||
|
|
||||||
index_func f;
|
index_func f;
|
||||||
if (args->print) {
|
if (args->print) {
|
||||||
f = print_json;
|
f = print_json;
|
||||||
@ -303,8 +309,11 @@ void sist2_index(index_args_t *args) {
|
|||||||
if (!args->print) {
|
if (!args->print) {
|
||||||
finish_indexer(args->script, desc.uuid);
|
finish_indexer(args->script, desc.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
tpool_destroy(IndexCtx.pool);
|
tpool_destroy(IndexCtx.pool);
|
||||||
|
|
||||||
|
store_destroy(IndexCtx.tag_store);
|
||||||
|
g_hash_table_remove_all(IndexCtx.tags);
|
||||||
|
g_hash_table_destroy(IndexCtx.tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sist2_exec_script(exec_args_t *args) {
|
void sist2_exec_script(exec_args_t *args) {
|
||||||
@ -330,6 +339,7 @@ void sist2_web(web_args_t *args) {
|
|||||||
WebCtx.auth_user = args->auth_user;
|
WebCtx.auth_user = args->auth_user;
|
||||||
WebCtx.auth_pass = args->auth_pass;
|
WebCtx.auth_pass = args->auth_pass;
|
||||||
WebCtx.auth_enabled = args->auth_enabled;
|
WebCtx.auth_enabled = args->auth_enabled;
|
||||||
|
WebCtx.tag_auth_enabled = args->tag_auth_enabled;
|
||||||
|
|
||||||
for (int i = 0; i < args->index_count; i++) {
|
for (int i = 0; i < args->index_count; i++) {
|
||||||
char *abs_path = abspath(args->indices[i]);
|
char *abs_path = abspath(args->indices[i]);
|
||||||
@ -339,7 +349,11 @@ void sist2_web(web_args_t *args) {
|
|||||||
char path_tmp[PATH_MAX];
|
char path_tmp[PATH_MAX];
|
||||||
|
|
||||||
snprintf(path_tmp, PATH_MAX, "%sthumbs", abs_path);
|
snprintf(path_tmp, PATH_MAX, "%sthumbs", abs_path);
|
||||||
WebCtx.indices[i].store = store_create(path_tmp);
|
WebCtx.indices[i].store = store_create(path_tmp, STORE_SIZE_TN);
|
||||||
|
|
||||||
|
snprintf(path_tmp, PATH_MAX, "%stags", abs_path);
|
||||||
|
mkdir(path_tmp, S_IWUSR | S_IRUSR | S_IXUSR);
|
||||||
|
WebCtx.indices[i].tag_store = store_create(path_tmp, STORE_SIZE_TAG);
|
||||||
|
|
||||||
snprintf(path_tmp, PATH_MAX, "%sdescriptor.json", abs_path);
|
snprintf(path_tmp, PATH_MAX, "%sdescriptor.json", abs_path);
|
||||||
WebCtx.indices[i].desc = read_index_descriptor(path_tmp);
|
WebCtx.indices[i].desc = read_index_descriptor(path_tmp);
|
||||||
@ -415,6 +429,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
OPT_STRING(0, "es-url", &common_es_url, "Elasticsearch url. DEFAULT=http://localhost:9200"),
|
OPT_STRING(0, "es-url", &common_es_url, "Elasticsearch url. DEFAULT=http://localhost:9200"),
|
||||||
OPT_STRING(0, "bind", &web_args->listen_address, "Listen on this address. DEFAULT=localhost:4090"),
|
OPT_STRING(0, "bind", &web_args->listen_address, "Listen on this address. DEFAULT=localhost:4090"),
|
||||||
OPT_STRING(0, "auth", &web_args->credentials, "Basic auth in user:password format"),
|
OPT_STRING(0, "auth", &web_args->credentials, "Basic auth in user:password format"),
|
||||||
|
OPT_STRING(0, "tag-auth", &web_args->tag_credentials, "Basic auth in user:password format for tagging"),
|
||||||
|
|
||||||
OPT_GROUP("Exec-script options"),
|
OPT_GROUP("Exec-script options"),
|
||||||
OPT_STRING(0, "script-file", &common_script_path, "Path to user script."),
|
OPT_STRING(0, "script-file", &common_script_path, "Path to user script."),
|
||||||
|
9
src/static/css/bootstrap-colorpicker.min.css
vendored
Normal file
9
src/static/css/bootstrap-colorpicker.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -166,6 +166,12 @@ a:hover,.btn:hover {
|
|||||||
background-color: #FAAB3C;
|
background-color: #FAAB3C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.add-tag-button {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #212529;
|
||||||
|
background-color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
.card-img-overlay {
|
.card-img-overlay {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
@ -191,6 +197,18 @@ a:hover,.btn:hover {
|
|||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge-delete {
|
||||||
|
margin-right: -2px;
|
||||||
|
margin-left: 2px;
|
||||||
|
margin-top: -1px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 90%;
|
||||||
|
background: rgba(0,0,0,0.2);
|
||||||
|
padding: 0.1em 0.4em;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.badge-user {
|
.badge-user {
|
||||||
color: #212529;
|
color: #212529;
|
||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
@ -516,3 +534,7 @@ svg {
|
|||||||
.wholerow {
|
.wholerow {
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stat > .card-body {
|
||||||
|
padding: 0.7em 1.25em;
|
||||||
|
}
|
||||||
|
@ -106,11 +106,33 @@ body {
|
|||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-delete {
|
||||||
|
margin-right: -2px;
|
||||||
|
margin-left: 2px;
|
||||||
|
margin-top: -1px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 90%;
|
||||||
|
background: rgba(0,0,0,0.2);
|
||||||
|
padding: 0.1em 0.4em;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.badge-text {
|
.badge-text {
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
background-color: #FAAB3C;
|
background-color: #FAAB3C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.add-tag-button {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #212529;
|
||||||
|
background-color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
.card-img-overlay {
|
.card-img-overlay {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
@ -131,9 +153,6 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
|
||||||
margin-right: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fit {
|
.fit {
|
||||||
display: block;
|
display: block;
|
||||||
@ -379,3 +398,7 @@ mark {
|
|||||||
.wholerow {
|
.wholerow {
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stat > .card-body {
|
||||||
|
padding: 0.7em 1.25em;
|
||||||
|
}
|
9
src/static/js/bootstrap-colorpicker.min.js
vendored
Normal file
9
src/static/js/bootstrap-colorpicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -153,26 +153,43 @@ function getTags(hit, mimeCategory) {
|
|||||||
// User tags
|
// User tags
|
||||||
if (hit["_source"].hasOwnProperty("tag")) {
|
if (hit["_source"].hasOwnProperty("tag")) {
|
||||||
hit["_source"]["tag"].forEach(tag => {
|
hit["_source"]["tag"].forEach(tag => {
|
||||||
const userTag = document.createElement("span");
|
tags.push(makeUserTag(tag, hit));
|
||||||
userTag.setAttribute("class", "badge badge-pill badge-user");
|
|
||||||
|
|
||||||
const tokens = tag.split("#");
|
|
||||||
|
|
||||||
if (tokens.length > 1) {
|
|
||||||
const bg = "#" + tokens[1];
|
|
||||||
const fg = lum(tokens[1]) > 50 ? "#000" : "#fff";
|
|
||||||
userTag.setAttribute("style", `background-color: ${bg}; color: ${fg}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = tokens[0].split(".")[tokens[0].split(".").length - 1];
|
|
||||||
userTag.appendChild(document.createTextNode(name));
|
|
||||||
tags.push(userTag);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeUserTag(tag, hit) {
|
||||||
|
const userTag = document.createElement("span");
|
||||||
|
userTag.setAttribute("class", "badge badge-pill badge-user");
|
||||||
|
|
||||||
|
const tokens = tag.split("#");
|
||||||
|
|
||||||
|
if (tokens.length > 1) {
|
||||||
|
const bg = "#" + tokens[1];
|
||||||
|
const fg = lum(tokens[1]) > 50 ? "#000" : "#fff";
|
||||||
|
userTag.setAttribute("style", `background-color: ${bg}; color: ${fg}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteButton = document.createElement("span");
|
||||||
|
deleteButton.setAttribute("class", "badge badge-pill badge-delete")
|
||||||
|
deleteButton.setAttribute("title", "Delete tag")
|
||||||
|
deleteButton.appendChild(document.createTextNode("X"));
|
||||||
|
deleteButton.addEventListener("click", () => {
|
||||||
|
deleteTag(tag, hit).then(() => {
|
||||||
|
userTag.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
userTag.addEventListener("mouseenter", () => userTag.appendChild(deleteButton));
|
||||||
|
userTag.addEventListener("mouseleave", () => deleteButton.remove());
|
||||||
|
|
||||||
|
const name = tokens[0].split(".")[tokens[0].split(".").length - 1];
|
||||||
|
userTag.appendChild(document.createTextNode(name));
|
||||||
|
|
||||||
|
return userTag;
|
||||||
|
}
|
||||||
|
|
||||||
function infoButtonCb(hit) {
|
function infoButtonCb(hit) {
|
||||||
return () => {
|
return () => {
|
||||||
getDocumentInfo(hit["_id"]).then(doc => {
|
getDocumentInfo(hit["_id"]).then(doc => {
|
||||||
@ -338,9 +355,31 @@ function createDocCard(hit) {
|
|||||||
|
|
||||||
docCardBody.appendChild(tagContainer);
|
docCardBody.appendChild(tagContainer);
|
||||||
|
|
||||||
|
attachTagContainerEventListener(tagContainer, hit);
|
||||||
return docCard;
|
return docCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function attachTagContainerEventListener(tagContainer, hit) {
|
||||||
|
const sizeTag = Array.from(tagContainer.children).find(child => child.tagName === "SMALL");
|
||||||
|
|
||||||
|
const addTagButton = document.createElement("span");
|
||||||
|
addTagButton.setAttribute("class", "badge badge-pill add-tag-button");
|
||||||
|
addTagButton.appendChild(document.createTextNode("+Add"));
|
||||||
|
|
||||||
|
tagContainer.addEventListener("mouseenter", () => tagContainer.insertBefore(addTagButton, sizeTag));
|
||||||
|
tagContainer.addEventListener("mouseleave", () => addTagButton.remove());
|
||||||
|
|
||||||
|
addTagButton.addEventListener("click", () => {
|
||||||
|
tagBar.value = "";
|
||||||
|
currentDocToTag = hit;
|
||||||
|
currentTagCallback = tag => {
|
||||||
|
tagContainer.insertBefore(makeUserTag(tag, hit), sizeTag);
|
||||||
|
}
|
||||||
|
$("#tagModal").modal("show");
|
||||||
|
tagBar.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function makeThumbnail(mimeCategory, hit, imgWrapper, small) {
|
function makeThumbnail(mimeCategory, hit, imgWrapper, small) {
|
||||||
|
|
||||||
if (!hit["_source"].hasOwnProperty("thumbnail")) {
|
if (!hit["_source"].hasOwnProperty("thumbnail")) {
|
||||||
@ -413,7 +452,6 @@ function createDocLine(hit) {
|
|||||||
|
|
||||||
if (hit["_source"].hasOwnProperty("parent")) {
|
if (hit["_source"].hasOwnProperty("parent")) {
|
||||||
line.classList.add("sub-document");
|
line.classList.add("sub-document");
|
||||||
isSubDocument = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const infoButton = makeInfoButton(hit);
|
const infoButton = makeInfoButton(hit);
|
||||||
@ -486,6 +524,8 @@ function createDocLine(hit) {
|
|||||||
pathLine.appendChild(path);
|
pathLine.appendChild(path);
|
||||||
pathLine.appendChild(tagContainer);
|
pathLine.appendChild(tagContainer);
|
||||||
|
|
||||||
|
attachTagContainerEventListener(tagContainer, hit);
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ let tagTree;
|
|||||||
|
|
||||||
let searchBar = document.getElementById("searchBar");
|
let searchBar = document.getElementById("searchBar");
|
||||||
let pathBar = document.getElementById("pathBar");
|
let pathBar = document.getElementById("pathBar");
|
||||||
|
let tagBar = document.getElementById("tagBar");
|
||||||
|
let currentDocToTag = null;
|
||||||
|
let currentTagCallback = null;
|
||||||
let lastDoc = null;
|
let lastDoc = null;
|
||||||
let reachedEnd = false;
|
let reachedEnd = false;
|
||||||
let docCount = 0;
|
let docCount = 0;
|
||||||
@ -109,13 +112,112 @@ window.onload = () => {
|
|||||||
searchDebounced();
|
searchDebounced();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
new autoComplete({
|
||||||
|
selector: '#tagBar',
|
||||||
|
minChars: 1,
|
||||||
|
delay: 200,
|
||||||
|
renderItem: function (item) {
|
||||||
|
return '<div class="autocomplete-suggestion" data-val="' + item + '">' + item.split("#")[0] + '</div>';
|
||||||
|
},
|
||||||
|
source: async function (term, suggest) {
|
||||||
|
term = term.toLowerCase();
|
||||||
|
|
||||||
|
const choices = await getTagChoices();
|
||||||
|
|
||||||
|
let matches = [];
|
||||||
|
for (let i = 0; i < choices.length; i++) {
|
||||||
|
if (~choices[i].toLowerCase().indexOf(term)) {
|
||||||
|
matches.push(choices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
suggest(matches.sort());
|
||||||
|
},
|
||||||
|
onSelect: function (e, item) {
|
||||||
|
const name = item.split("#")[0];
|
||||||
|
const color = "#" + item.split("#")[1];
|
||||||
|
$("#tag-color").val(color);
|
||||||
|
$("#tag-color").trigger("keyup", color);
|
||||||
|
tagBar.value = name;
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
[tagBar, document.getElementById("tag-color")].forEach(elem => {
|
||||||
|
elem.addEventListener("keyup", e => {
|
||||||
|
if (e.key === "Enter" && tagBar.value.length > 0) {
|
||||||
|
const tag = tagBar.value + document.getElementById("tag-color").value;
|
||||||
|
saveTag(tag, currentDocToTag).then(() => currentTagCallback(tag));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
$("#tag-color").colorpicker({
|
||||||
|
format: "hex",
|
||||||
|
sliders: {
|
||||||
|
saturation: {
|
||||||
|
selector: '.colorpicker-saturation',
|
||||||
|
callLeft: 'setSaturationRatio',
|
||||||
|
callTop: 'setValueRatio'
|
||||||
|
},
|
||||||
|
hue: {
|
||||||
|
selector: '.colorpicker-hue',
|
||||||
|
maxLeft: 0,
|
||||||
|
callLeft: false,
|
||||||
|
callTop: 'setHueRatio'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function saveTag(tag, hit) {
|
||||||
|
const relPath = hit["_source"]["path"] + "/" + hit["_source"]["name"] + ext(hit);
|
||||||
|
|
||||||
|
return $.jsonPost("/tag/" + hit["_source"]["index"], {
|
||||||
|
delete: false,
|
||||||
|
name: tag,
|
||||||
|
doc_id: hit["_id"],
|
||||||
|
relpath: relPath
|
||||||
|
}).then(() => {
|
||||||
|
tagBar.blur();
|
||||||
|
$("#tagModal").modal("hide");
|
||||||
|
$.toast({
|
||||||
|
heading: "Tag added",
|
||||||
|
text: "Tag saved to index storage and updated in ElasticSearch",
|
||||||
|
stack: 3,
|
||||||
|
bgColor: "#00a4bc",
|
||||||
|
textColor: "#fff",
|
||||||
|
position: 'bottom-right',
|
||||||
|
hideAfter: 3000,
|
||||||
|
loaderBg: "#08c7e8",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTag(tag, hit) {
|
||||||
|
const relPath = hit["_source"]["path"] + "/" + hit["_source"]["name"] + ext(hit);
|
||||||
|
|
||||||
|
return $.jsonPost("/tag/" + hit["_source"]["index"], {
|
||||||
|
delete: true,
|
||||||
|
name: tag,
|
||||||
|
doc_id: hit["_id"],
|
||||||
|
relpath: relPath
|
||||||
|
}).then(() => {
|
||||||
|
$.toast({
|
||||||
|
heading: "Tag deleted",
|
||||||
|
text: "Tag deleted index storage and updated in ElasticSearch",
|
||||||
|
stack: 3,
|
||||||
|
bgColor: "#00a4bc",
|
||||||
|
textColor: "#fff",
|
||||||
|
position: 'bottom-right',
|
||||||
|
hideAfter: 3000,
|
||||||
|
loaderBg: "#08c7e8",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function toggleFuzzy() {
|
function toggleFuzzy() {
|
||||||
searchDebounced();
|
searchDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.jsonPost("i").then(resp => {
|
$.get("i").then(resp => {
|
||||||
|
|
||||||
const urlIndices = (new URLSearchParams(location.search)).get("i");
|
const urlIndices = (new URLSearchParams(location.search)).get("i");
|
||||||
resp["indices"].forEach(idx => {
|
resp["indices"].forEach(idx => {
|
||||||
@ -248,21 +350,25 @@ $.jsonPost("es", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function addTag(map, tag, id, count) {
|
function addTag(map, tag, id, count) {
|
||||||
let tags = tag.split("#")[0].split(".");
|
// let tags = tag.split("#")[0].split(".");
|
||||||
|
let tags = tag.split(".");
|
||||||
|
|
||||||
let child = {
|
let child = {
|
||||||
id: id,
|
id: id,
|
||||||
text: tags.length !== 1 ? tags[0] : `${tags[0]} (${count})`,
|
values: [id],
|
||||||
|
count: count,
|
||||||
|
text: tags.length !== 1 ? tags[0] : `${tags[0].split("#")[0]} (${count})`,
|
||||||
name: tags[0],
|
name: tags[0],
|
||||||
children: [],
|
children: [],
|
||||||
isLeaf: tags.length === 1,
|
isLeaf: tags.length === 1,
|
||||||
//Overwrite base functions
|
//Overwrite base functions
|
||||||
blur: function() {},
|
blur: function () {
|
||||||
select: function() {
|
},
|
||||||
|
select: function () {
|
||||||
this.state("selected", true);
|
this.state("selected", true);
|
||||||
return this.check()
|
return this.check()
|
||||||
},
|
},
|
||||||
deselect: function() {
|
deselect: function () {
|
||||||
this.state("selected", false);
|
this.state("selected", false);
|
||||||
return this.uncheck()
|
return this.uncheck()
|
||||||
},
|
},
|
||||||
@ -299,10 +405,15 @@ function addTag(map, tag, id, count) {
|
|||||||
|
|
||||||
let found = false;
|
let found = false;
|
||||||
map.forEach(node => {
|
map.forEach(node => {
|
||||||
if (node.name === child.name) {
|
if (node.name.split("#")[0] === child.name.split("#")[0]) {
|
||||||
found = true;
|
found = true;
|
||||||
if (tags.length !== 1) {
|
if (tags.length !== 1) {
|
||||||
addTag(node.children, tags.slice(1).join("."), id, count);
|
addTag(node.children, tags.slice(1).join("."), id, count);
|
||||||
|
} else {
|
||||||
|
// Same name, different color
|
||||||
|
node.count += count;
|
||||||
|
node.text = `${tags[0].split("#")[0]} (${node.count})`;
|
||||||
|
node.values.push(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -354,7 +465,11 @@ function getSelectedNodes(tree) {
|
|||||||
|
|
||||||
//Only get children
|
//Only get children
|
||||||
if (selected[i].text.indexOf("(") !== -1) {
|
if (selected[i].text.indexOf("(") !== -1) {
|
||||||
selectedNodes.push(selected[i].id);
|
if (selected[i].values) {
|
||||||
|
selectedNodes.push(selected[i].values);
|
||||||
|
} else {
|
||||||
|
selectedNodes.push(selected[i].id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +532,9 @@ function search(after = null) {
|
|||||||
|
|
||||||
let tags = getSelectedNodes(tagTree);
|
let tags = getSelectedNodes(tagTree);
|
||||||
if (!tags.includes("any")) {
|
if (!tags.includes("any")) {
|
||||||
tags.forEach(term => filters.push({term: {"tag": term}}))
|
tags.forEach(tagGroup => {
|
||||||
|
filters.push({terms: {"tag": tagGroup}})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date_min && date_max) {
|
if (date_min && date_max) {
|
||||||
@ -661,6 +778,7 @@ function getNextDepth(node) {
|
|||||||
text: `${name}/ (${bucket.doc_count})`,
|
text: `${name}/ (${bucket.doc_count})`,
|
||||||
depth: node.depth + 1,
|
depth: node.depth + 1,
|
||||||
index: node.index,
|
index: node.index,
|
||||||
|
values: [bucket.key],
|
||||||
children: true,
|
children: true,
|
||||||
}
|
}
|
||||||
}).filter(x => x !== null)
|
}).filter(x => x !== null)
|
||||||
@ -691,6 +809,7 @@ function createPathTree(target) {
|
|||||||
selectedIndices.forEach(index => {
|
selectedIndices.forEach(index => {
|
||||||
pathTree.addNode({
|
pathTree.addNode({
|
||||||
id: "/" + index,
|
id: "/" + index,
|
||||||
|
values: ["/" + index],
|
||||||
text: `/[${indexMap[index]}]`,
|
text: `/[${indexMap[index]}]`,
|
||||||
index: index,
|
index: index,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
@ -719,5 +838,34 @@ function getPathChoices() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(resp => getPaths(resp["suggest"]["path"][0]["options"].map(opt => opt["_source"]["path"])));
|
}).then(resp => getPaths(resp["suggest"]["path"][0]["options"].map(opt => opt["_source"]["path"])));
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getTagChoices() {
|
||||||
|
return new Promise(getPaths => {
|
||||||
|
$.jsonPost("es", {
|
||||||
|
suggest: {
|
||||||
|
tag: {
|
||||||
|
prefix: tagBar.value,
|
||||||
|
completion: {
|
||||||
|
field: "suggest-tag",
|
||||||
|
skip_duplicates: true,
|
||||||
|
size: 10000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).then(resp => {
|
||||||
|
const result = [];
|
||||||
|
resp["suggest"]["tag"][0]["options"].map(opt => opt["_source"]["tag"]).forEach(tags => {
|
||||||
|
tags.forEach(tag => {
|
||||||
|
const t = tag.split("#")[0];
|
||||||
|
if (!result.find(x => x.split("#")[0] === t)) {
|
||||||
|
result.push(tag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
getPaths(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,11 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">2.5.2</span>
|
<span class="badge badge-pill version">2.6.0</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<a class="btn ml-auto" href="/stats">Stats</a>
|
<a class="btn ml-auto" href="/stats">Stats</a>
|
||||||
<button class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
<button class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings
|
||||||
|
</button>
|
||||||
<button class="btn" title="Toggle theme" onclick="toggleTheme()">Theme</button>
|
<button class="btn" title="Toggle theme" onclick="toggleTheme()">Theme</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@ -48,8 +49,11 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="input-group" style="margin-bottom: 0.5em; margin-top: 1em">
|
<div class="input-group" style="margin-bottom: 0.5em; margin-top: 1em">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<button id="pathBarHelper" class="btn btn-outline-secondary" data-toggle="modal" data-target="#pathTreeModal">
|
<button id="pathBarHelper" class="btn btn-outline-secondary" data-toggle="modal"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" width="20px"><path d="M288 224h224a32 32 0 0 0 32-32V64a32 32 0 0 0-32-32H400L368 0h-80a32 32 0 0 0-32 32v64H64V8a8 8 0 0 0-8-8H40a8 8 0 0 0-8 8v392a16 16 0 0 0 16 16h208v64a32 32 0 0 0 32 32h224a32 32 0 0 0 32-32V352a32 32 0 0 0-32-32H400l-32-32h-80a32 32 0 0 0-32 32v64H64V128h192v64a32 32 0 0 0 32 32zm0 96h66.74l32 32H512v128H288zm0-288h66.74l32 32H512v128H288z"/></svg>
|
data-target="#pathTreeModal">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" width="20px">
|
||||||
|
<path d="M288 224h224a32 32 0 0 0 32-32V64a32 32 0 0 0-32-32H400L368 0h-80a32 32 0 0 0-32 32v64H64V8a8 8 0 0 0-8-8H40a8 8 0 0 0-8 8v392a16 16 0 0 0 16 16h208v64a32 32 0 0 0 32 32h224a32 32 0 0 0 32-32V352a32 32 0 0 0-32-32H400l-32-32h-80a32 32 0 0 0-32 32v64H64V128h192v64a32 32 0 0 0 32 32zm0 96h66.74l32 32H512v128H288zm0-288h66.74l32 32H512v128H288z"/>
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<input id="pathBar" type="search" class="form-control" placeholder="Filter path">
|
<input id="pathBar" type="search" class="form-control" placeholder="Filter path">
|
||||||
@ -156,7 +160,8 @@
|
|||||||
<i>fried eggs</i> and either <i>eggplant</i> or <i>potato</i>, but will ignore results
|
<i>fried eggs</i> and either <i>eggplant</i> or <i>potato</i>, but will ignore results
|
||||||
containing <i>frittata</i>.</p>
|
containing <i>frittata</i>.</p>
|
||||||
|
|
||||||
<p>When neither <code>+</code> or <code>|</code> is specified, the default operator is <code>+</code> (and).</p>
|
<p>When neither <code>+</code> or <code>|</code> is specified, the default operator is
|
||||||
|
<code>+</code> (and).</p>
|
||||||
<p>When the <b>Fuzzy</b> option is checked, partial matches are also returned.</p>
|
<p>When the <b>Fuzzy</b> option is checked, partial matches are also returned.</p>
|
||||||
<br>
|
<br>
|
||||||
<p>For more information, see <a target="_blank"
|
<p>For more information, see <a target="_blank"
|
||||||
@ -189,12 +194,14 @@
|
|||||||
|
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="settingSearchInPath">
|
<input type="checkbox" class="custom-control-input" id="settingSearchInPath">
|
||||||
<label class="custom-control-label" for="settingSearchInPath">Enable matching query against document path</label>
|
<label class="custom-control-label" for="settingSearchInPath">Enable matching query against
|
||||||
|
document path</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="settingSuggestPath">
|
<input type="checkbox" class="custom-control-input" id="settingSuggestPath">
|
||||||
<label class="custom-control-label" for="settingSuggestPath">Enable auto-complete in path filter bar</label>
|
<label class="custom-control-label" for="settingSuggestPath">Enable auto-complete in path filter
|
||||||
|
bar</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
@ -288,6 +295,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="tagModal" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Add tag</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col col-8">
|
||||||
|
<input type="text" id="tagBar" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col col-4">
|
||||||
|
<input type="text" id="tag-color" value="" class="form-control"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="searchResults"></div>
|
<div id="searchResults"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">2.5.2</span>
|
<span class="badge badge-pill version">2.6.0</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<a style="margin-left: auto" class="btn" href="/">Back</a>
|
<a style="margin-left: auto" class="btn" href="/">Back</a>
|
||||||
<button class="btn" type="button" data-toggle="modal" data-target="#settings"
|
<button class="btn" type="button" data-toggle="modal" data-target="#settings"
|
||||||
|
@ -19,6 +19,7 @@ typedef struct index_descriptor {
|
|||||||
typedef struct index_t {
|
typedef struct index_t {
|
||||||
struct index_descriptor desc;
|
struct index_descriptor desc;
|
||||||
struct store_t *store;
|
struct store_t *store;
|
||||||
|
struct store_t *tag_store;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
} index_t;
|
} index_t;
|
||||||
|
|
||||||
|
196
src/web/serve.c
196
src/web/serve.c
@ -53,6 +53,14 @@ store_t *get_store(const char *index_id) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store_t *get_tag_store(const char *index_id) {
|
||||||
|
index_t *idx = get_index_by_id(index_id);
|
||||||
|
if (idx != NULL) {
|
||||||
|
return idx->tag_store;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void search_index(struct mg_connection *nc) {
|
void search_index(struct mg_connection *nc) {
|
||||||
send_response_line(nc, 200, sizeof(search_html), "Content-Type: text/html");
|
send_response_line(nc, 200, sizeof(search_html), "Content-Type: text/html");
|
||||||
mg_send(nc, search_html, sizeof(search_html));
|
mg_send(nc, search_html, sizeof(search_html));
|
||||||
@ -422,6 +430,177 @@ void status(struct mg_connection *nc) {
|
|||||||
nc->flags |= MG_F_SEND_AND_CLOSE;
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
int delete;
|
||||||
|
char *relpath;
|
||||||
|
char *doc_id;
|
||||||
|
} tag_req_t;
|
||||||
|
|
||||||
|
tag_req_t *parse_tag_request(cJSON *json) {
|
||||||
|
|
||||||
|
if (!cJSON_IsObject(json)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *arg_name = cJSON_GetObjectItem(json, "name");
|
||||||
|
if (arg_name == NULL || !cJSON_IsString(arg_name)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *arg_delete = cJSON_GetObjectItem(json, "delete");
|
||||||
|
if (arg_delete == NULL || !cJSON_IsBool(arg_delete)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *arg_relpath = cJSON_GetObjectItem(json, "relpath");
|
||||||
|
if (arg_relpath == NULL || !cJSON_IsString(arg_relpath)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *arg_doc_id = cJSON_GetObjectItem(json, "doc_id");
|
||||||
|
if (arg_doc_id == NULL || !cJSON_IsString(arg_doc_id)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tag_req_t *req = malloc(sizeof(tag_req_t));
|
||||||
|
req->delete = arg_delete->valueint;
|
||||||
|
req->name = arg_name->valuestring;
|
||||||
|
req->relpath = arg_relpath->valuestring;
|
||||||
|
req->doc_id = arg_doc_id->valuestring;
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tag(struct mg_connection *nc, struct http_message *hm, struct mg_str *path) {
|
||||||
|
if (path->len != UUID_STR_LEN + 4) {
|
||||||
|
LOG_DEBUGF("serve.c", "Invalid tag path: %.*s", (int) path->len, path->p)
|
||||||
|
mg_http_send_error(nc, 404, NULL);
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char arg_index[UUID_STR_LEN];
|
||||||
|
memcpy(arg_index, hm->uri.p + 5, UUID_STR_LEN);
|
||||||
|
*(arg_index + UUID_STR_LEN - 1) = '\0';
|
||||||
|
|
||||||
|
if (hm->body.len < 2 || hm->method.len != 4 || memcmp(&hm->method, "POST", 4) == 0) {
|
||||||
|
LOG_DEBUG("serve.c", "Invalid tag request")
|
||||||
|
mg_http_send_error(nc, 400, NULL);
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
store_t *store = get_tag_store(arg_index);
|
||||||
|
if (store == NULL) {
|
||||||
|
LOG_DEBUGF("serve.c", "Could not get tag store for index: %s", arg_index)
|
||||||
|
mg_http_send_error(nc, 404, NULL);
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *body = malloc(hm->body.len + 1);
|
||||||
|
memcpy(body, hm->body.p, hm->body.len);
|
||||||
|
*(body + hm->body.len) = '\0';
|
||||||
|
cJSON *json = cJSON_Parse(body);
|
||||||
|
|
||||||
|
tag_req_t *arg_req = parse_tag_request(json);
|
||||||
|
if (arg_req == NULL) {
|
||||||
|
LOG_DEBUGF("serve.c", "Could not parse tag request", arg_index)
|
||||||
|
cJSON_Delete(json);
|
||||||
|
free(body);
|
||||||
|
mg_http_send_error(nc, 400, NULL);
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *arr = NULL;
|
||||||
|
|
||||||
|
size_t data_len = 0;
|
||||||
|
const char *data = store_read(store, arg_req->relpath, strlen(arg_req->relpath), &data_len);
|
||||||
|
if (data_len == 0) {
|
||||||
|
arr = cJSON_CreateArray();
|
||||||
|
} else {
|
||||||
|
arr = cJSON_Parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg_req->delete) {
|
||||||
|
|
||||||
|
if (data_len > 0) {
|
||||||
|
cJSON *element = NULL;
|
||||||
|
int i = 0;
|
||||||
|
cJSON_ArrayForEach(element, arr) {
|
||||||
|
if (strcmp(element->valuestring, arg_req->name) == 0) {
|
||||||
|
cJSON_DeleteItemFromArray(arr, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[8196];
|
||||||
|
snprintf(buf, sizeof(buf),
|
||||||
|
"{"
|
||||||
|
" \"script\" : {"
|
||||||
|
" \"source\": \"if (ctx._source.tag.contains(params.tag)) { ctx._source.tag.remove(ctx._source.tag.indexOf(params.tag)) }\","
|
||||||
|
" \"lang\": \"painless\","
|
||||||
|
" \"params\" : {"
|
||||||
|
" \"tag\" : \"%s\""
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
"}", arg_req->name
|
||||||
|
);
|
||||||
|
|
||||||
|
char url[4096];
|
||||||
|
snprintf(url, sizeof(url), "%s/sist2/_update/%s", WebCtx.es_url, arg_req->doc_id);
|
||||||
|
nc->user_data = web_post_async(url, buf);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cJSON_AddItemToArray(arr, cJSON_CreateString(arg_req->name));
|
||||||
|
|
||||||
|
char buf[8196];
|
||||||
|
snprintf(buf, sizeof(buf),
|
||||||
|
"{"
|
||||||
|
" \"script\" : {"
|
||||||
|
" \"source\": \"if(ctx._source.tag == null) {ctx._source.tag = new ArrayList()} ctx._source.tag.add(params.tag)\","
|
||||||
|
" \"lang\": \"painless\","
|
||||||
|
" \"params\" : {"
|
||||||
|
" \"tag\" : \"%s\""
|
||||||
|
" }"
|
||||||
|
" }"
|
||||||
|
"}", arg_req->name
|
||||||
|
);
|
||||||
|
|
||||||
|
char url[4096];
|
||||||
|
snprintf(url, sizeof(url), "%s/sist2/_update/%s", WebCtx.es_url, arg_req->doc_id);
|
||||||
|
nc->user_data = web_post_async(url, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *json_str = cJSON_PrintUnformatted(arr);
|
||||||
|
store_write(store, arg_req->relpath, strlen(arg_req->relpath) + 1, json_str, strlen(json_str) + 1);
|
||||||
|
|
||||||
|
free(arg_req);
|
||||||
|
free(json_str);
|
||||||
|
cJSON_Delete(json);
|
||||||
|
cJSON_Delete(arr);
|
||||||
|
free(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
int validate_auth(struct mg_connection *nc, struct http_message *hm) {
|
||||||
|
char user[256] = {0,};
|
||||||
|
char pass[256] = {0,};
|
||||||
|
|
||||||
|
int ret = mg_get_http_basic_auth(hm, user, sizeof(user), pass, sizeof(pass));
|
||||||
|
if (ret == -1 || strcmp(user, WebCtx.auth_user) != 0 || strcmp(pass, WebCtx.auth_pass) != 0) {
|
||||||
|
mg_printf(nc, "HTTP/1.1 401 Unauthorized\r\n"
|
||||||
|
"WWW-Authenticate: Basic realm=\"sist2\"\r\n"
|
||||||
|
"Content-Length: 0\r\n\r\n");
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void ev_router(struct mg_connection *nc, int ev, void *p) {
|
static void ev_router(struct mg_connection *nc, int ev, void *p) {
|
||||||
struct mg_str scheme;
|
struct mg_str scheme;
|
||||||
struct mg_str user_info;
|
struct mg_str user_info;
|
||||||
@ -442,15 +621,7 @@ static void ev_router(struct mg_connection *nc, int ev, void *p) {
|
|||||||
|
|
||||||
|
|
||||||
if (WebCtx.auth_enabled == TRUE) {
|
if (WebCtx.auth_enabled == TRUE) {
|
||||||
char user[256] = {0,};
|
if (!validate_auth(nc, hm)) {
|
||||||
char pass[256] = {0,};
|
|
||||||
|
|
||||||
int ret = mg_get_http_basic_auth(hm, user, sizeof(user), pass, sizeof(pass));
|
|
||||||
if (ret == -1 || strcmp(user, WebCtx.auth_user) != 0 || strcmp(pass, WebCtx.auth_pass) != 0) {
|
|
||||||
mg_printf(nc, "HTTP/1.1 401 Unauthorized\r\n"
|
|
||||||
"WWW-Authenticate: Basic realm=\"sist2\"\r\n"
|
|
||||||
"Content-Length: 0\r\n\r\n");
|
|
||||||
nc->flags |= MG_F_SEND_AND_CLOSE;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,6 +650,13 @@ static void ev_router(struct mg_connection *nc, int ev, void *p) {
|
|||||||
thumbnail(nc, hm, &path);
|
thumbnail(nc, hm, &path);
|
||||||
} else if (has_prefix(&path, &((struct mg_str) MG_MK_STR("/s/")))) {
|
} else if (has_prefix(&path, &((struct mg_str) MG_MK_STR("/s/")))) {
|
||||||
stats_files(nc, hm, &path);
|
stats_files(nc, hm, &path);
|
||||||
|
} else if (has_prefix(&path, &((struct mg_str) MG_MK_STR("/tag/")))) {
|
||||||
|
if (WebCtx.tag_auth_enabled == TRUE) {
|
||||||
|
if (!validate_auth(nc, hm)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tag(nc, hm, &path);
|
||||||
} else if (has_prefix(&path, &((struct mg_str) MG_MK_STR("/d/")))) {
|
} else if (has_prefix(&path, &((struct mg_str) MG_MK_STR("/d/")))) {
|
||||||
document_info(nc, hm, &path);
|
document_info(nc, hm, &path);
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user