mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 10:16:42 +00:00
Document info modal #19
This commit is contained in:
parent
d42129cfcb
commit
919f45c79c
@ -5,7 +5,7 @@ THREADS=$(nproc)
|
|||||||
cd lib
|
cd lib
|
||||||
|
|
||||||
cd mupdf
|
cd mupdf
|
||||||
make USE_SYSTEM_HARFBUZZ=yes USE_SYSTEM_OPENJPEG=yes HAVE_X11=no HAVE_GLUT=no CFLAGS=-fPIC -j $THREADS
|
CFLAGS=-fPIC make USE_SYSTEM_HARFBUZZ=yes USE_SYSTEM_OPENJPEG=yes HAVE_X11=no HAVE_GLUT=no -j $THREADS
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
mv mupdf/build/release/libmupdf.a .
|
mv mupdf/build/release/libmupdf.a .
|
||||||
|
@ -136,7 +136,7 @@ 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 %3d documents (%zukB) <%d>", count, buf_cur / 1024, r->status_code);
|
LOG_INFOF("elastic.c", "Indexed %d documents (%zukB) <%d>", count, buf_cur / 1024, r->status_code);
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -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.1";
|
static const char *const Version = "1.2.2";
|
||||||
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",
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define SIST2_PDF_H
|
#define SIST2_PDF_H
|
||||||
|
|
||||||
#include "src/sist.h"
|
#include "src/sist.h"
|
||||||
#include <tesseract/capi.h>
|
|
||||||
|
|
||||||
|
|
||||||
void parse_pdf(void *buf, size_t buf_len, document_t *doc);
|
void parse_pdf(void *buf, size_t buf_len, document_t *doc);
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include <archive_entry.h>
|
#include <archive_entry.h>
|
||||||
#include <opc/opc.h>
|
#include <opc/opc.h>
|
||||||
#include <libxml/xmlstring.h>
|
#include <libxml/xmlstring.h>
|
||||||
|
#define BOOL int
|
||||||
|
#include <tesseract/capi.h>
|
||||||
|
|
||||||
#include <onion/onion.h>
|
#include <onion/onion.h>
|
||||||
#include <onion/handler.h>
|
#include <onion/handler.h>
|
||||||
|
@ -110,7 +110,7 @@ int thumbnail(void *p, onion_request *req, onion_response *res) {
|
|||||||
int written = onion_response_write(res, data, data_len);
|
int written = onion_response_write(res, data, data_len);
|
||||||
onion_response_flush(res);
|
onion_response_flush(res);
|
||||||
if (written != data_len || data_len == 0) {
|
if (written != data_len || data_len == 0) {
|
||||||
printf("Couldn't write thumb\n");
|
LOG_DEBUG("serve.c", "Couldn't write thumbnail");
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ int chunked_response_file(const char *filename, const char *mime,
|
|||||||
return OCS_PROCESSED;
|
return OCS_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int search(void *p, onion_request *req, onion_response *res) {
|
int search(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||||
|
|
||||||
int flags = onion_request_get_flags(req);
|
int flags = onion_request_get_flags(req);
|
||||||
if ((flags & OR_METHODS) != OR_POST) {
|
if ((flags & OR_METHODS) != OR_POST) {
|
||||||
@ -254,7 +254,7 @@ int search(void *p, onion_request *req, onion_response *res) {
|
|||||||
return OCS_PROCESSED;
|
return OCS_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scroll(void *p, onion_request *req, onion_response *res) {
|
int scroll(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||||
|
|
||||||
int flags = onion_request_get_flags(req);
|
int flags = onion_request_get_flags(req);
|
||||||
if ((flags & OR_METHODS) != OR_GET) {
|
if ((flags & OR_METHODS) != OR_GET) {
|
||||||
@ -327,7 +327,7 @@ int serve_file_from_disk(cJSON *json, index_t *idx, onion_request *req, onion_re
|
|||||||
return chunked_response_file(full_path, mime, 1, req, res);
|
return chunked_response_file(full_path, mime, 1, req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
int index_info(void *p, onion_request *req, onion_response *res) {
|
int index_info(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||||
cJSON *json = cJSON_CreateObject();
|
cJSON *json = cJSON_CreateObject();
|
||||||
cJSON *arr = cJSON_AddArrayToObject(json, "indices");
|
cJSON *arr = cJSON_AddArrayToObject(json, "indices");
|
||||||
|
|
||||||
@ -353,14 +353,47 @@ int index_info(void *p, onion_request *req, onion_response *res) {
|
|||||||
return OCS_PROCESSED;
|
return OCS_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file(void *p, onion_request *req, onion_response *res) {
|
|
||||||
|
int document_info(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||||
|
|
||||||
const char *arg_uuid = onion_request_get_query(req, "1");
|
const char *arg_uuid = onion_request_get_query(req, "1");
|
||||||
if (arg_uuid == NULL) {
|
if (arg_uuid == NULL) {
|
||||||
return OCS_PROCESSED;
|
return OCS_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *next = arg_uuid;
|
cJSON *doc = elastic_get_document(arg_uuid);
|
||||||
|
cJSON *source = cJSON_GetObjectItem(doc, "_source");
|
||||||
|
|
||||||
|
cJSON *index_id = cJSON_GetObjectItem(source, "index");
|
||||||
|
if (index_id == NULL) {
|
||||||
|
cJSON_Delete(doc);
|
||||||
|
return OCS_NOT_PROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
index_t *idx = get_index_by_id(index_id->valuestring);
|
||||||
|
if (idx == NULL) {
|
||||||
|
cJSON_Delete(doc);
|
||||||
|
return OCS_NOT_PROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
onion_response_set_header(res, "Content-Type", "application/json");
|
||||||
|
|
||||||
|
char *json_str = cJSON_PrintUnformatted(source);
|
||||||
|
onion_response_write0(res, json_str);
|
||||||
|
free(json_str);
|
||||||
|
cJSON_Delete(doc);
|
||||||
|
|
||||||
|
return OCS_PROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int file(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||||
|
|
||||||
|
const char *arg_uuid = onion_request_get_query(req, "1");
|
||||||
|
if (arg_uuid == NULL) {
|
||||||
|
return OCS_PROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *next = arg_uuid;
|
||||||
cJSON *doc = NULL;
|
cJSON *doc = NULL;
|
||||||
cJSON *index_id = NULL;
|
cJSON *index_id = NULL;
|
||||||
cJSON *source = NULL;
|
cJSON *source = NULL;
|
||||||
@ -424,6 +457,7 @@ void serve(const char *hostname, const char *port) {
|
|||||||
thumbnail
|
thumbnail
|
||||||
);
|
);
|
||||||
onion_url_add(urls, "^f/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$", file);
|
onion_url_add(urls, "^f/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$", file);
|
||||||
|
onion_url_add(urls, "^d/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$", document_info);
|
||||||
onion_url_add(urls, "i", index_info);
|
onion_url_add(urls, "i", index_info);
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2,6 +2,26 @@
|
|||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-icon {
|
||||||
|
width: 1rem;
|
||||||
|
margin-right: 0.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #757575;
|
||||||
|
line-height: 1rem;
|
||||||
|
height: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-icon:hover {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-title {
|
||||||
|
max-width: calc(100% - 2rem);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.path-row {
|
.path-row {
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -32,7 +52,7 @@ body {
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card, .modal-content {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
background: #212121;
|
background: #212121;
|
||||||
color: #e0e0e0;
|
color: #e0e0e0;
|
||||||
@ -40,6 +60,27 @@ body {
|
|||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table {
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td, .table th {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead th {
|
||||||
|
border-bottom: 1px solid #646464;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header .close {
|
||||||
|
color: #e0e0e0;
|
||||||
|
text-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
border-bottom: 1px solid #646464;
|
||||||
|
}
|
||||||
|
|
||||||
.sub-document {
|
.sub-document {
|
||||||
background: #37474F !important;
|
background: #37474F !important;
|
||||||
}
|
}
|
||||||
@ -134,6 +175,8 @@ body {
|
|||||||
|
|
||||||
.file-title {
|
.file-title {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
line-height: 1rem;
|
||||||
|
height: 1.1rem;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
@ -2,6 +2,25 @@
|
|||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-icon {
|
||||||
|
width: 1rem;
|
||||||
|
margin-right: 0.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #757575;
|
||||||
|
line-height: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-icon:hover {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-title {
|
||||||
|
max-width: calc(100% - 2rem);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.path-row {
|
.path-row {
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -100,6 +119,8 @@ body {
|
|||||||
|
|
||||||
.file-title {
|
.file-title {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
line-height: 1rem;
|
||||||
|
height: 1.1rem;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
@ -153,11 +153,44 @@ function getTags(hit, mimeCategory) {
|
|||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function infoButtonCb(hit) {
|
||||||
*
|
return () => {
|
||||||
* @param hit
|
getDocumentInfo(hit["_id"]).then(doc => {
|
||||||
* @returns {Element}
|
$("#modal-title").text(doc["name"] + (doc["extension"] ? "." + doc["extension"] : ""));
|
||||||
*/
|
|
||||||
|
const tbody = $("<tbody>");
|
||||||
|
$("#modal-body").empty()
|
||||||
|
.append($("<table class='table table-sm'>")
|
||||||
|
.append($("<thead>")
|
||||||
|
.append($("<tr>")
|
||||||
|
.append($("<th>").text("Field"))
|
||||||
|
.append($("<th>").text("Value"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.append(tbody)
|
||||||
|
);
|
||||||
|
|
||||||
|
const displayFields = new Set([
|
||||||
|
"mime", "size", "mtime", "path", "title", "width", "height", "duration", "audioc", "videoc",
|
||||||
|
"bitrate", "artist", "album", "album_artist", "genre", "title", "font_name", "tag"
|
||||||
|
]);
|
||||||
|
Object.keys(doc)
|
||||||
|
.filter(key => key.startsWith("_keyword.") || key.startsWith("_text.") || displayFields.has(key))
|
||||||
|
.forEach(key => {
|
||||||
|
tbody.append($("<tr>")
|
||||||
|
.append($("<td>").text(key))
|
||||||
|
.append($("<td>").text(doc[key]))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (doc.hasOwnProperty("content") && doc["content"]) {
|
||||||
|
$("#modal-body").append($("<div class='content-div'>").text(doc["content"]))
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#modal").modal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createDocCard(hit) {
|
function createDocCard(hit) {
|
||||||
let docCard = document.createElement("div");
|
let docCard = document.createElement("div");
|
||||||
docCard.setAttribute("class", "card");
|
docCard.setAttribute("class", "card");
|
||||||
@ -172,6 +205,7 @@ function createDocCard(hit) {
|
|||||||
let link = document.createElement("a");
|
let link = document.createElement("a");
|
||||||
link.setAttribute("href", "f/" + hit["_id"]);
|
link.setAttribute("href", "f/" + hit["_id"]);
|
||||||
link.setAttribute("target", "_blank");
|
link.setAttribute("target", "_blank");
|
||||||
|
link.style.maxWidth = "calc(100% - 1.2rem)";
|
||||||
link.appendChild(title);
|
link.appendChild(title);
|
||||||
|
|
||||||
if (hit["_source"].hasOwnProperty("parent")) {
|
if (hit["_source"].hasOwnProperty("parent")) {
|
||||||
@ -271,7 +305,15 @@ function createDocCard(hit) {
|
|||||||
sizeTag.setAttribute("class", "text-muted");
|
sizeTag.setAttribute("class", "text-muted");
|
||||||
tagContainer.appendChild(sizeTag);
|
tagContainer.appendChild(sizeTag);
|
||||||
|
|
||||||
docCardBody.appendChild(link);
|
const titleWrapper = document.createElement("div");
|
||||||
|
titleWrapper.style.display = "flex";
|
||||||
|
|
||||||
|
const infoButton = makeInfoButton(hit);
|
||||||
|
|
||||||
|
titleWrapper.appendChild(infoButton);
|
||||||
|
titleWrapper.appendChild(link);
|
||||||
|
|
||||||
|
docCardBody.appendChild(titleWrapper);
|
||||||
docCard.appendChild(docCardBody);
|
docCard.appendChild(docCardBody);
|
||||||
|
|
||||||
docCardBody.appendChild(tagContainer);
|
docCardBody.appendChild(tagContainer);
|
||||||
@ -352,6 +394,14 @@ function makeThumbnail(mimeCategory, hit, imgWrapper, small) {
|
|||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeInfoButton(hit) {
|
||||||
|
const infoButton = document.createElement("span");
|
||||||
|
infoButton.appendChild(document.createTextNode("🛈"));
|
||||||
|
infoButton.setAttribute("class", "info-icon");
|
||||||
|
infoButton.addEventListener("click", infoButtonCb(hit));
|
||||||
|
return infoButton;
|
||||||
|
}
|
||||||
|
|
||||||
function createDocLine(hit) {
|
function createDocLine(hit) {
|
||||||
|
|
||||||
const mime = hit["_source"]["mime"];
|
const mime = hit["_source"]["mime"];
|
||||||
@ -372,6 +422,8 @@ function createDocLine(hit) {
|
|||||||
isSubDocument = true;
|
isSubDocument = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const infoButton = makeInfoButton(hit);
|
||||||
|
|
||||||
const title = makeTitle(hit);
|
const title = makeTitle(hit);
|
||||||
|
|
||||||
let link = document.createElement("a");
|
let link = document.createElement("a");
|
||||||
@ -380,8 +432,13 @@ function createDocLine(hit) {
|
|||||||
link.appendChild(title);
|
link.appendChild(title);
|
||||||
|
|
||||||
const titleDiv = document.createElement("div");
|
const titleDiv = document.createElement("div");
|
||||||
titleDiv.setAttribute("class", "file-title");
|
|
||||||
titleDiv.appendChild(link);
|
const titleWrapper = document.createElement("div");
|
||||||
|
titleWrapper.style.display = "flex";
|
||||||
|
titleWrapper.appendChild(infoButton);
|
||||||
|
titleWrapper.appendChild(link);
|
||||||
|
|
||||||
|
titleDiv.appendChild(titleWrapper);
|
||||||
|
|
||||||
line.appendChild(media);
|
line.appendChild(media);
|
||||||
|
|
||||||
|
@ -81,6 +81,10 @@ $.jsonPost("i").then(resp => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getDocumentInfo(id) {
|
||||||
|
return $.getJSON("d/" + id)
|
||||||
|
}
|
||||||
|
|
||||||
function handleTreeClick(tree) {
|
function handleTreeClick(tree) {
|
||||||
return (event, node, handler) => {
|
return (event, node, handler) => {
|
||||||
event.preventTreeDefault();
|
event.preventTreeDefault();
|
||||||
|
@ -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.1</span>
|
<span class="badge badge-pill version">v1.2.2</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>
|
||||||
@ -65,6 +65,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="modal" 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" id="modal-title"></h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="modal-body"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="searchResults"></div>
|
<div id="searchResults"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user