mirror of
https://github.com/simon987/sist2.git
synced 2025-12-13 15:29:04 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8505cb8c1 | |||
| ae8652d86e | |||
| 849beb09d8 | |||
| e1aaaee617 | |||
| c02b940945 | |||
| 2934ddb07f | |||
| 7f6f3c02fa | |||
| 7f98d5a682 | |||
| 7eb9c5d7d5 | |||
| 184439aa38 | |||
| 1ce8b298a1 |
2
mime.csv
2
mime.csv
@@ -320,7 +320,7 @@ video/x-dv, dif|dv
|
|||||||
video/x-fli, fli
|
video/x-fli, fli
|
||||||
video/x-isvideo, isu
|
video/x-isvideo, isu
|
||||||
video/x-motion-jpeg, mjpg
|
video/x-motion-jpeg, mjpg
|
||||||
video/x-ms-asf, asf|asx
|
video/x-ms-asf, asf|asx|wmv
|
||||||
video/x-qtc, qtc
|
video/x-qtc, qtc
|
||||||
video/x-sgi-movie, movie|mv
|
video/x-sgi-movie, movie|mv
|
||||||
application/x-7z-compressed, 7z
|
application/x-7z-compressed, 7z
|
||||||
|
|||||||
|
@@ -13,7 +13,7 @@ mv mupdf/build/release/libmupdf-third.a .
|
|||||||
|
|
||||||
# openjp2
|
# openjp2
|
||||||
cd openjpeg
|
cd openjpeg
|
||||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG -fPIC"
|
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-O3 -DNDEBUG -fPIC"
|
||||||
make -j $THREADS
|
make -j $THREADS
|
||||||
cd ..
|
cd ..
|
||||||
mv openjpeg/bin/libopenjp2.a .
|
mv openjpeg/bin/libopenjp2.a .
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ struct {
|
|||||||
|
|
||||||
pthread_mutex_t mupdf_mu;
|
pthread_mutex_t mupdf_mu;
|
||||||
char * tesseract_lang;
|
char * tesseract_lang;
|
||||||
char * tesseract_path;
|
const char * tesseract_path;
|
||||||
} ScanCtx;
|
} ScanCtx;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ typedef struct es_indexer {
|
|||||||
|
|
||||||
static es_indexer_t *Indexer;
|
static es_indexer_t *Indexer;
|
||||||
|
|
||||||
|
void delete_queue(int max);
|
||||||
|
|
||||||
void print_json(cJSON *document, const char uuid_str[UUID_STR_LEN]) {
|
void print_json(cJSON *document, const char uuid_str[UUID_STR_LEN]) {
|
||||||
|
|
||||||
cJSON *line = cJSON_CreateObject();
|
cJSON *line = cJSON_CreateObject();
|
||||||
@@ -64,7 +66,7 @@ void execute_update_script(const char *script, const char index_id[UUID_STR_LEN]
|
|||||||
cJSON *term_obj = cJSON_AddObjectToObject(query, "term");
|
cJSON *term_obj = cJSON_AddObjectToObject(query, "term");
|
||||||
cJSON_AddStringToObject(term_obj, "index", index_id);
|
cJSON_AddStringToObject(term_obj, "index", index_id);
|
||||||
|
|
||||||
char * str = cJSON_Print(body);
|
char *str = cJSON_Print(body);
|
||||||
|
|
||||||
char bulk_url[4096];
|
char bulk_url[4096];
|
||||||
snprintf(bulk_url, 4096, "%s/sist2/_update_by_query?pretty", Indexer->es_url);
|
snprintf(bulk_url, 4096, "%s/sist2/_update_by_query?pretty", Indexer->es_url);
|
||||||
@@ -87,21 +89,15 @@ void execute_update_script(const char *script, const char index_id[UUID_STR_LEN]
|
|||||||
cJSON_Delete(resp);
|
cJSON_Delete(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void elastic_flush() {
|
void *create_bulk_buffer(int max, int *count, size_t *buf_len) {
|
||||||
|
|
||||||
if (Indexer == NULL) {
|
|
||||||
Indexer = create_indexer(IndexCtx.es_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
es_bulk_line_t *line = Indexer->line_head;
|
es_bulk_line_t *line = Indexer->line_head;
|
||||||
|
*count = 0;
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
size_t buf_size = 0;
|
size_t buf_size = 0;
|
||||||
size_t buf_cur = 0;
|
size_t buf_cur = 0;
|
||||||
char *buf = malloc(1);
|
char *buf = malloc(1);
|
||||||
|
|
||||||
while (line != NULL) {
|
while (line != NULL && *count < max) {
|
||||||
char action_str[512];
|
char action_str[512];
|
||||||
snprintf(action_str, 512,
|
snprintf(action_str, 512,
|
||||||
"{\"index\":{\"_id\":\"%s\", \"_type\":\"_doc\", \"_index\":\"sist2\"}}\n", line->uuid_str);
|
"{\"index\":{\"_id\":\"%s\", \"_type\":\"_doc\", \"_index\":\"sist2\"}}\n", line->uuid_str);
|
||||||
@@ -116,17 +112,20 @@ void elastic_flush() {
|
|||||||
memcpy(buf + buf_cur, line->line, line_len);
|
memcpy(buf + buf_cur, line->line, line_len);
|
||||||
buf_cur += line_len;
|
buf_cur += line_len;
|
||||||
|
|
||||||
es_bulk_line_t *tmp = line;
|
|
||||||
line = line->next;
|
line = line->next;
|
||||||
free(tmp);
|
(*count)++;
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
buf = realloc(buf, buf_size + 1);
|
buf = realloc(buf, buf_size + 1);
|
||||||
*(buf+buf_cur) = '\0';
|
*(buf + buf_cur) = '\0';
|
||||||
|
|
||||||
Indexer->line_head = NULL;
|
*buf_len = buf_cur;
|
||||||
Indexer->line_tail = NULL;
|
return buf;
|
||||||
Indexer->queued = 0;
|
}
|
||||||
|
|
||||||
|
void _elastic_flush(int max) {
|
||||||
|
size_t buf_len;
|
||||||
|
int count;
|
||||||
|
void *buf = create_bulk_buffer(max, &count, &buf_len);
|
||||||
|
|
||||||
char bulk_url[4096];
|
char bulk_url[4096];
|
||||||
snprintf(bulk_url, 4096, "%s/sist2/_bulk?pipeline=tie", Indexer->es_url);
|
snprintf(bulk_url, 4096, "%s/sist2/_bulk?pipeline=tie", Indexer->es_url);
|
||||||
@@ -136,14 +135,33 @@ void elastic_flush() {
|
|||||||
LOG_FATALF("elastic.c", "Could not connect to %s, make sure that elasticsearch is running!\n", IndexCtx.es_url)
|
LOG_FATALF("elastic.c", "Could not connect to %s, make sure that elasticsearch is running!\n", IndexCtx.es_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFOF("elastic.c", "Indexed %d documents (%zukB) <%d>", count, buf_cur / 1024, r->status_code);
|
if (r->status_code == 413) {
|
||||||
|
|
||||||
|
if (max <= 1) {
|
||||||
|
LOG_ERRORF("elastic.c", "Single document too large, giving up: {%s}", Indexer->line_head->uuid_str)
|
||||||
|
free_response(r);
|
||||||
|
free(buf);
|
||||||
|
delete_queue(1);
|
||||||
|
if (Indexer->queued != 0) {
|
||||||
|
elastic_flush();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_WARNINGF("elastic.c", "Payload too large, retrying (%d documents)", count);
|
||||||
|
|
||||||
|
free_response(r);
|
||||||
|
free(buf);
|
||||||
|
_elastic_flush(max / 2);
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else if (r->status_code != 200) {
|
||||||
cJSON *ret_json = cJSON_Parse(r->body);
|
cJSON *ret_json = cJSON_Parse(r->body);
|
||||||
if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) {
|
if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) {
|
||||||
cJSON *err;
|
cJSON *err;
|
||||||
cJSON_ArrayForEach(err, cJSON_GetObjectItem(ret_json, "items")) {
|
cJSON_ArrayForEach(err, cJSON_GetObjectItem(ret_json, "items")) {
|
||||||
if (cJSON_GetObjectItem(cJSON_GetObjectItem(err, "index"), "status")->valueint != 201) {
|
if (cJSON_GetObjectItem(cJSON_GetObjectItem(err, "index"), "status")->valueint != 201) {
|
||||||
char* str = cJSON_Print(err);
|
char *str = cJSON_Print(err);
|
||||||
LOG_ERRORF("elastic.c", "%s\n", str);
|
LOG_ERRORF("elastic.c", "%s\n", str);
|
||||||
cJSON_free(str);
|
cJSON_free(str);
|
||||||
}
|
}
|
||||||
@@ -151,11 +169,44 @@ void elastic_flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cJSON_Delete(ret_json);
|
cJSON_Delete(ret_json);
|
||||||
|
delete_queue(Indexer->queued);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOG_INFOF("elastic.c", "Indexed %d documents (%zukB) <%d>", count, buf_len / 1024, r->status_code);
|
||||||
|
|
||||||
|
delete_queue(max);
|
||||||
|
|
||||||
|
if (Indexer->queued != 0) {
|
||||||
|
elastic_flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free_response(r);
|
free_response(r);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void delete_queue(int max) {
|
||||||
|
for (int i = 0; i < max; i++) {
|
||||||
|
es_bulk_line_t *tmp = Indexer->line_head;
|
||||||
|
Indexer->line_head = tmp->next;
|
||||||
|
if (Indexer->line_head == NULL) {
|
||||||
|
Indexer->line_tail = NULL;
|
||||||
|
} else {
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
Indexer->queued -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void elastic_flush() {
|
||||||
|
|
||||||
|
if (Indexer == NULL) {
|
||||||
|
Indexer = create_indexer(IndexCtx.es_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
_elastic_flush(Indexer->queued);
|
||||||
|
}
|
||||||
|
|
||||||
void elastic_index_line(es_bulk_line_t *line) {
|
void elastic_index_line(es_bulk_line_t *line) {
|
||||||
|
|
||||||
if (Indexer == NULL) {
|
if (Indexer == NULL) {
|
||||||
@@ -192,7 +243,7 @@ es_indexer_t *create_indexer(const char *url) {
|
|||||||
return indexer;
|
return indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_indexer(char * script, char index_id[UUID_STR_LEN]) {
|
void destroy_indexer(char *script, char index_id[UUID_STR_LEN]) {
|
||||||
|
|
||||||
char url[4096];
|
char url[4096];
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,12 @@ 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);
|
||||||
|
if (mime_text == NULL) {
|
||||||
|
cJSON_AddNullToObject(document, "mime");
|
||||||
|
} else {
|
||||||
cJSON_AddStringToObject(document, "mime", mime_get_mime_text(line.mime));
|
cJSON_AddStringToObject(document, "mime", mime_get_mime_text(line.mime));
|
||||||
|
}
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,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 = "1.2.9";
|
static const char *const Version = "1.2.13";
|
||||||
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",
|
||||||
|
|||||||
@@ -1293,6 +1293,7 @@ g_hash_table_insert(ext_table, "isu", (gpointer)video_x_isvideo);
|
|||||||
g_hash_table_insert(ext_table, "mjpg", (gpointer)video_x_motion_jpeg);
|
g_hash_table_insert(ext_table, "mjpg", (gpointer)video_x_motion_jpeg);
|
||||||
g_hash_table_insert(ext_table, "asf", (gpointer)video_x_ms_asf);
|
g_hash_table_insert(ext_table, "asf", (gpointer)video_x_ms_asf);
|
||||||
g_hash_table_insert(ext_table, "asx", (gpointer)video_x_ms_asf);
|
g_hash_table_insert(ext_table, "asx", (gpointer)video_x_ms_asf);
|
||||||
|
g_hash_table_insert(ext_table, "wmv", (gpointer)video_x_ms_asf);
|
||||||
g_hash_table_insert(ext_table, "qtc", (gpointer)video_x_qtc);
|
g_hash_table_insert(ext_table, "qtc", (gpointer)video_x_qtc);
|
||||||
g_hash_table_insert(ext_table, "movie", (gpointer)video_x_sgi_movie);
|
g_hash_table_insert(ext_table, "movie", (gpointer)video_x_sgi_movie);
|
||||||
g_hash_table_insert(ext_table, "mv", (gpointer)video_x_sgi_movie);
|
g_hash_table_insert(ext_table, "mv", (gpointer)video_x_sgi_movie);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#include "pdf.h"
|
#include "pdf.h"
|
||||||
#include "src/ctx.h"
|
#include "src/ctx.h"
|
||||||
|
|
||||||
#define MIN_OCR_SIZE 128
|
#define MIN_OCR_SIZE 350
|
||||||
|
#define MIN_OCR_LEN 10
|
||||||
__thread text_buffer_t thread_buffer;
|
__thread text_buffer_t thread_buffer;
|
||||||
|
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ int read_stext_block(fz_stext_block *block, text_buffer_t *tex) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define IS_VALID_BPP(d) (d==1 || d==2 || d==4 || d==8 || d==16 || d==24 || d==32)
|
||||||
|
|
||||||
void fill_image(fz_context *ctx, UNUSED(fz_device *dev),
|
void fill_image(fz_context *ctx, UNUSED(fz_device *dev),
|
||||||
fz_image *img, UNUSED(fz_matrix ctm), UNUSED(float alpha),
|
fz_image *img, UNUSED(fz_matrix ctm), UNUSED(float alpha),
|
||||||
@@ -135,7 +137,7 @@ void fill_image(fz_context *ctx, UNUSED(fz_device *dev),
|
|||||||
|
|
||||||
int l2factor = 0;
|
int l2factor = 0;
|
||||||
|
|
||||||
if (img->w > MIN_OCR_SIZE && img->h > MIN_OCR_SIZE) {
|
if (img->w > MIN_OCR_SIZE && img->h > MIN_OCR_SIZE && IS_VALID_BPP(img->n)) {
|
||||||
|
|
||||||
fz_pixmap *pix = img->get_pixmap(ctx, img, NULL, img->w, img->h, &l2factor);
|
fz_pixmap *pix = img->get_pixmap(ctx, img, NULL, img->w, img->h, &l2factor);
|
||||||
|
|
||||||
@@ -148,12 +150,14 @@ void fill_image(fz_context *ctx, UNUSED(fz_device *dev),
|
|||||||
|
|
||||||
char *text = TessBaseAPIGetUTF8Text(api);
|
char *text = TessBaseAPIGetUTF8Text(api);
|
||||||
size_t len = strlen(text);
|
size_t len = strlen(text);
|
||||||
|
if (len >= MIN_OCR_LEN) {
|
||||||
text_buffer_append_string(&thread_buffer, text, len - 1);
|
text_buffer_append_string(&thread_buffer, text, len - 1);
|
||||||
LOG_DEBUGF(
|
LOG_DEBUGF(
|
||||||
"pdf.c",
|
"pdf.c",
|
||||||
"(OCR) %dx%d got %dB from tesseract (%s), buffer:%dB",
|
"(OCR) %dx%d got %dB from tesseract (%s), buffer:%dB",
|
||||||
pix->w, pix->h, len, ScanCtx.tesseract_lang, thread_buffer.dyn_buffer.cur
|
pix->w, pix->h, len, ScanCtx.tesseract_lang, thread_buffer.dyn_buffer.cur
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
TessBaseAPIEnd(api);
|
TessBaseAPIEnd(api);
|
||||||
TessBaseAPIDelete(api);
|
TessBaseAPIDelete(api);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ enum metakey {
|
|||||||
|
|
||||||
typedef struct index_descriptor {
|
typedef struct index_descriptor {
|
||||||
char uuid[UUID_STR_LEN];
|
char uuid[UUID_STR_LEN];
|
||||||
char version[6];
|
char version[64];
|
||||||
long timestamp;
|
long timestamp;
|
||||||
char root[PATH_MAX];
|
char root[PATH_MAX];
|
||||||
char rewrite_url[8196];
|
char rewrite_url[8196];
|
||||||
|
|||||||
@@ -181,7 +181,12 @@ int chunked_response_file(const char *filename, const char *mime,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onion_response_set_length(res, length);
|
onion_response_set_length(res, length);
|
||||||
|
if (mime != NULL) {
|
||||||
onion_response_set_header(res, "Content-Type", mime);
|
onion_response_set_header(res, "Content-Type", mime);
|
||||||
|
} else {
|
||||||
|
onion_response_set_header(res, "Content-Type", "application/octet-stream");
|
||||||
|
}
|
||||||
|
|
||||||
onion_response_write_headers(res);
|
onion_response_write_headers(res);
|
||||||
if ((onion_request_get_flags(request) & OR_HEAD) == OR_HEAD) {
|
if ((onion_request_get_flags(request) & OR_HEAD) == OR_HEAD) {
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -423,3 +423,21 @@ option {
|
|||||||
margin-top: -14px;
|
margin-top: -14px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.small-btn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.large-btn {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 801px) {
|
||||||
|
.small-btn {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
.large-btn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -287,3 +287,21 @@ mark {
|
|||||||
margin-top: -14px;
|
margin-top: -14px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.small-btn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.large-btn {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 801px) {
|
||||||
|
.small-btn {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
.large-btn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
1
web/css/smartphoto.min.css
vendored
Normal file
1
web/css/smartphoto.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -75,6 +75,10 @@ function shouldPlayVideo(hit) {
|
|||||||
return videoc !== "hevc" && videoc !== "mpeg2video" && videoc !== "wmv3";
|
return videoc !== "hevc" && videoc !== "mpeg2video" && videoc !== "wmv3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldDisplayRawImage(hit) {
|
||||||
|
return hit["_source"]["mime"] && hit["_source"]["mime"].startsWith("image/") && hit["_source"]["videoc"] !== "tiff";
|
||||||
|
}
|
||||||
|
|
||||||
function makePlaceholder(w, h, small) {
|
function makePlaceholder(w, h, small) {
|
||||||
let calc;
|
let calc;
|
||||||
if (small) {
|
if (small) {
|
||||||
@@ -96,10 +100,14 @@ function makePlaceholder(w, h, small) {
|
|||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ext(hit) {
|
||||||
|
return hit["_source"].hasOwnProperty("extension") && hit["_source"]["extension"] !== "" ? "." + hit["_source"]["extension"] : "";
|
||||||
|
}
|
||||||
|
|
||||||
function makeTitle(hit) {
|
function makeTitle(hit) {
|
||||||
let title = document.createElement("div");
|
let title = document.createElement("div");
|
||||||
title.setAttribute("class", "file-title");
|
title.setAttribute("class", "file-title");
|
||||||
let extension = hit["_source"].hasOwnProperty("extension") && hit["_source"]["extension"] !== "" ? "." + hit["_source"]["extension"] : "";
|
let extension = ext(hit);
|
||||||
|
|
||||||
applyNameToTitle(hit, title, extension);
|
applyNameToTitle(hit, title, extension);
|
||||||
|
|
||||||
@@ -156,7 +164,7 @@ function getTags(hit, mimeCategory) {
|
|||||||
function infoButtonCb(hit) {
|
function infoButtonCb(hit) {
|
||||||
return () => {
|
return () => {
|
||||||
getDocumentInfo(hit["_id"]).then(doc => {
|
getDocumentInfo(hit["_id"]).then(doc => {
|
||||||
$("#modal-title").text(doc["name"] + (doc["extension"] ? "." + doc["extension"] : ""));
|
$("#modal-title").text(doc["name"] + ext(hit));
|
||||||
|
|
||||||
const tbody = $("<tbody>");
|
const tbody = $("<tbody>");
|
||||||
$("#modal-body").empty()
|
$("#modal-body").empty()
|
||||||
@@ -175,7 +183,7 @@ function infoButtonCb(hit) {
|
|||||||
"bitrate", "artist", "album", "album_artist", "genre", "title", "font_name", "tag"
|
"bitrate", "artist", "album", "album_artist", "genre", "title", "font_name", "tag"
|
||||||
]);
|
]);
|
||||||
Object.keys(doc)
|
Object.keys(doc)
|
||||||
.filter(key => key.startsWith("_keyword.") || key.startsWith("_text.") || displayFields.has(key))
|
.filter(key => key.startsWith("_keyword.") || key.startsWith("_text.") || displayFields.has(key) || key.startsWith("exif_"))
|
||||||
.forEach(key => {
|
.forEach(key => {
|
||||||
tbody.append($("<tr>")
|
tbody.append($("<tr>")
|
||||||
.append($("<td>").text(key))
|
.append($("<td>").text(key))
|
||||||
@@ -379,6 +387,15 @@ function makeThumbnail(mimeCategory, hit, imgWrapper, small) {
|
|||||||
}
|
}
|
||||||
thumbnail.setAttribute("src", `t/${hit["_source"]["index"]}/${hit["_id"]}`);
|
thumbnail.setAttribute("src", `t/${hit["_source"]["index"]}/${hit["_id"]}`);
|
||||||
|
|
||||||
|
if (!hit["_source"]["parent"] && shouldDisplayRawImage(hit)) {
|
||||||
|
imgWrapper.setAttribute("id", "sp" + hit["_id"]);
|
||||||
|
imgWrapper.setAttribute("data-src", `t/${hit["_source"]["index"]}/${hit["_id"]}`);
|
||||||
|
imgWrapper.setAttribute("href", `f/${hit["_id"]}`);
|
||||||
|
imgWrapper.setAttribute("data-caption", hit["_source"]["path"] + "/" + hit["_source"]["name"] + ext(hit));
|
||||||
|
imgWrapper.setAttribute("data-group", "p" + Math.floor(docCount / SIZE));
|
||||||
|
imgWrapper.classList.add("sp");
|
||||||
|
}
|
||||||
|
|
||||||
const placeholder = makePlaceholder(hit["_source"]["width"], hit["_source"]["height"], small);
|
const placeholder = makePlaceholder(hit["_source"]["width"], hit["_source"]["height"], small);
|
||||||
imgWrapper.appendChild(placeholder);
|
imgWrapper.appendChild(placeholder);
|
||||||
|
|
||||||
|
|||||||
56
web/js/jquery-smartphoto.min.js
vendored
Normal file
56
web/js/jquery-smartphoto.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -152,8 +152,8 @@ $.jsonPost("es", {
|
|||||||
target: '#mimeTree'
|
target: '#mimeTree'
|
||||||
});
|
});
|
||||||
mimeTree.on("node.click", handleTreeClick(mimeTree));
|
mimeTree.on("node.click", handleTreeClick(mimeTree));
|
||||||
mimeTree.select();
|
mimeTree.deselect();
|
||||||
mimeTree.node("any").deselect();
|
mimeTree.node("any").select();
|
||||||
});
|
});
|
||||||
|
|
||||||
function leafTag(tag) {
|
function leafTag(tag) {
|
||||||
@@ -351,11 +351,10 @@ function search(after = null) {
|
|||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
[condition]: {
|
[condition]: {
|
||||||
multi_match: {
|
simple_query_string: {
|
||||||
query: query,
|
query: query,
|
||||||
type: "most_fields",
|
|
||||||
fields: fields,
|
fields: fields,
|
||||||
operator: "and"
|
default_operator: "and"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter: filters
|
filter: filters
|
||||||
@@ -406,6 +405,10 @@ function search(after = null) {
|
|||||||
let resultContainer = makeResultContainer();
|
let resultContainer = makeResultContainer();
|
||||||
searchResults.appendChild(resultContainer);
|
searchResults.appendChild(resultContainer);
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
$(".sp").SmartPhoto({animationSpeed: 0, swipeTopToClose: true, showAnimation: false, forceInterval: 50});
|
||||||
|
}, 100);
|
||||||
|
|
||||||
if (!after) {
|
if (!after) {
|
||||||
docCount = 0;
|
docCount = 0;
|
||||||
}
|
}
|
||||||
@@ -471,6 +474,15 @@ function updateIndices() {
|
|||||||
document.getElementById("indices").addEventListener("change", updateIndices);
|
document.getElementById("indices").addEventListener("change", updateIndices);
|
||||||
updateIndices();
|
updateIndices();
|
||||||
|
|
||||||
|
window.onkeyup = function(e) {
|
||||||
|
if (e.key === "/" || e.key === "Escape") {
|
||||||
|
const bar = document.getElementById("searchBar");
|
||||||
|
bar.scrollIntoView();
|
||||||
|
bar.focus();
|
||||||
|
}
|
||||||
|
console.log(e)
|
||||||
|
};
|
||||||
|
|
||||||
//Suggest
|
//Suggest
|
||||||
function getPathChoices() {
|
function getPathChoices() {
|
||||||
return new Promise(getPaths => {
|
return new Promise(getPaths => {
|
||||||
|
|||||||
@@ -11,7 +11,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">v1.2.9</span>
|
<span class="badge badge-pill version">v1.2.13</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" id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
<a style="margin-left: auto" id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -31,7 +31,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input id="searchBar" type="search" class="form-control" placeholder="Search">
|
<input id="searchBar" type="search" class="form-control" placeholder="Search">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-outline-secondary small-btn" type="button" data-toggle="modal"
|
||||||
|
data-target="#help">?
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-outline-secondary large-btn" type="button" data-toggle="modal"
|
||||||
|
data-target="#help">Help
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input title="File size" id="sizeSlider" name="size">
|
<input title="File size" id="sizeSlider" name="size">
|
||||||
@@ -45,10 +52,12 @@
|
|||||||
<div class="col" id="treeTabs">
|
<div class="col" id="treeTabs">
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" data-toggle="tab" href="#mime" role="tab" aria-controls="home" aria-selected="true">Mime Types</a>
|
<a class="nav-link active" data-toggle="tab" href="#mime" role="tab" aria-controls="home"
|
||||||
|
aria-selected="true">Mime Types</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" href="#tag" role="tab" aria-controls="profile" aria-selected="false" title="User-defined tags">Tags</a>
|
<a class="nav-link" data-toggle="tab" href="#tag" role="tab" aria-controls="profile"
|
||||||
|
aria-selected="false" title="User-defined tags">Tags</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content" id="myTabContent">
|
<div class="tab-content" id="myTabContent">
|
||||||
@@ -79,6 +88,69 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="help" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Search help</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>+</code></td>
|
||||||
|
<td>signifies AND operation</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>|</code></td>
|
||||||
|
<td>signifies OR operation</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-</code></td>
|
||||||
|
<td>negates a single token</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>""</code></td>
|
||||||
|
<td>wraps a number of tokens to signify a phrase for searching</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>*</code></td>
|
||||||
|
<td>at the end of a term signifies a prefix query</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>(</code> and <code>)</code></td>
|
||||||
|
<td>signify precedence</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>~N</code></td>
|
||||||
|
<td>after a word signifies edit distance (fuzziness)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>~N</code></td>
|
||||||
|
<td>after a phrase signifies slop amount</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>For example: <code>"fried eggs" +(eggplant | potato) -frittata</code> will match the phrase
|
||||||
|
<i>fried eggs</i> and either <i>eggplant</i> or <i>potato</i>, but will ignore results
|
||||||
|
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 the <b>Fuzzy</b> option is checked, partial matches are also returned.</p>
|
||||||
|
<br>
|
||||||
|
<p>For more information, see <a target="_blank"
|
||||||
|
href="//www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html">Elasticsearch
|
||||||
|
documentation</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="searchResults"></div>
|
<div id="searchResults"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user