mirror of
https://github.com/simon987/sist2.git
synced 2025-12-14 15:59:03 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16514fd6b0 | |||
| 27509f97e1 | |||
| 4c540eae1c | |||
| d2b53ff6fc | |||
| 0ef4292abf | |||
| e6fde38c24 | |||
| 5fa343d40f |
@@ -74,6 +74,7 @@ pdf,xps,cbz,cbr,fb2,epub | MuPDF | text+ocr | yes, `png` | title |
|
|||||||
`image/*` | ffmpeg | - | yes, `jpeg` | [Common EXIF tags](https://github.com/simon987/sist2/blob/efdde2734eca9b14a54f84568863b7ffd59bdba3/src/parsing/media.c#L190) |
|
`image/*` | ffmpeg | - | yes, `jpeg` | [Common EXIF tags](https://github.com/simon987/sist2/blob/efdde2734eca9b14a54f84568863b7ffd59bdba3/src/parsing/media.c#L190) |
|
||||||
ttf,ttc,cff,woff,fnt,otf | Freetype2 | - | yes, `bmp` | Name & style |
|
ttf,ttc,cff,woff,fnt,otf | Freetype2 | - | yes, `bmp` | Name & style |
|
||||||
`text/plain` | *(none)* | yes | no | - |
|
`text/plain` | *(none)* | yes | no | - |
|
||||||
|
html, xml | *(none)* | yes | no | - |
|
||||||
tar, zip, rar, 7z, ar ... | Libarchive | yes\* | - | no |
|
tar, zip, rar, 7z, ar ... | Libarchive | yes\* | - | no |
|
||||||
docx, xlsx, pptx | *(none)* | yes | no | creator, modified_by, title |
|
docx, xlsx, pptx | *(none)* | yes | no | creator, modified_by, title |
|
||||||
mobi, azw, azw3 | libmobi | yes | no | author, title |
|
mobi, azw, azw3 | libmobi | yes | no | author, title |
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ Index options
|
|||||||
--batch-size=<int> Index batch size. DEFAULT: 100
|
--batch-size=<int> Index batch size. DEFAULT: 100
|
||||||
-f, --force-reset Reset Elasticsearch mappings and settings. (You must use this option the first time you use the index command)
|
-f, --force-reset Reset Elasticsearch mappings and settings. (You must use this option the first time you use the index command)
|
||||||
|
|
||||||
|
|
||||||
Web options
|
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
|
--bind=<str> Listen on this address. DEFAULT=localhost:4090
|
||||||
--port=<str> Listen on this port. DEFAULT=4090
|
|
||||||
--auth=<str> Basic auth in user:password format
|
--auth=<str> Basic auth in user:password format
|
||||||
Made by simon987 <me@simon987.net>. Released under GPL-3.0
|
Made by simon987 <me@simon987.net>. Released under GPL-3.0
|
||||||
|
|
||||||
@@ -244,14 +244,13 @@ sist2 index --print ./my_index/ | jq | less
|
|||||||
### Web options
|
### Web options
|
||||||
* `--es-url=<str>` Elasticsearch url.
|
* `--es-url=<str>` Elasticsearch url.
|
||||||
* `--bind=<str>` Listen on this address.
|
* `--bind=<str>` Listen on this address.
|
||||||
* `--port=<str>` Listen on this port.
|
|
||||||
* `--auth=<str>` Basic auth in user:password format
|
* `--auth=<str>` Basic auth in user:password format
|
||||||
|
|
||||||
### Web examples
|
### Web examples
|
||||||
|
|
||||||
**Single index**
|
**Single index**
|
||||||
```bash
|
```bash
|
||||||
sist2 web --auth admin:hunter2 --bind 0.0.0.0 --port 8888 my_index
|
sist2 web --auth admin:hunter2 --bind 0.0.0.0:8888 my_index
|
||||||
```
|
```
|
||||||
|
|
||||||
**Multiple indices**
|
**Multiple indices**
|
||||||
|
|||||||
@@ -11,7 +11,16 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"analyzer": "path_analyzer",
|
"analyzer": "path_analyzer",
|
||||||
"fielddata": true,
|
"fielddata": true,
|
||||||
"index_prefixes": {}
|
"fields": {
|
||||||
|
"nGram": {
|
||||||
|
"type": "text",
|
||||||
|
"analyzer": "my_nGram"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "text",
|
||||||
|
"analyzer": "content_analyzer"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"mime": {
|
"mime": {
|
||||||
"type": "keyword"
|
"type": "keyword"
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ struct {
|
|||||||
|
|
||||||
int threads;
|
int threads;
|
||||||
int depth;
|
int depth;
|
||||||
int verbose;
|
|
||||||
int very_verbose;
|
|
||||||
|
|
||||||
size_t stat_tn_size;
|
size_t stat_tn_size;
|
||||||
size_t stat_index_size;
|
size_t stat_index_size;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
12
src/log.c
12
src/log.c
@@ -12,7 +12,7 @@ const char *log_levels[] = {
|
|||||||
"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"
|
"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"
|
||||||
};
|
};
|
||||||
|
|
||||||
void sist_logf(const char *filepath, int level, char *format, ...) {
|
void vsist_logf(const char *filepath, int level, char *format, va_list ap) {
|
||||||
|
|
||||||
static int is_tty = -1;
|
static int is_tty = -1;
|
||||||
if (is_tty == -1) {
|
if (is_tty == -1) {
|
||||||
@@ -46,11 +46,8 @@ void sist_logf(const char *filepath, int level, char *format, ...) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
size_t maxsize = sizeof(log_str) - log_len;
|
size_t maxsize = sizeof(log_str) - log_len;
|
||||||
log_len += vsnprintf(log_str + log_len, maxsize, format, ap);
|
log_len += vsnprintf(log_str + log_len, maxsize, format, ap);
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
if (is_tty) {
|
if (is_tty) {
|
||||||
log_len += sprintf(log_str + log_len, "\033[0m\n");
|
log_len += sprintf(log_str + log_len, "\033[0m\n");
|
||||||
@@ -65,6 +62,13 @@ void sist_logf(const char *filepath, int level, char *format, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sist_logf(const char *filepath, int level, char *format, ...) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
vsist_logf(filepath, level, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
void sist_log(const char *filepath, int level, char *str) {
|
void sist_log(const char *filepath, int level, char *str) {
|
||||||
|
|
||||||
static int is_tty = -1;
|
static int is_tty = -1;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "sist.h"
|
#include "sist.h"
|
||||||
|
|
||||||
void sist_logf(const char *filepath, int level, char *format, ...);
|
void sist_logf(const char *filepath, int level, char *format, ...);
|
||||||
|
void vsist_logf(const char *filepath, int level, char *format, va_list ap);
|
||||||
|
|
||||||
void sist_log(const char *filepath, int level, char *str);
|
void sist_log(const char *filepath, int level, char *str);
|
||||||
|
|
||||||
|
|||||||
12
src/main.c
12
src/main.c
@@ -19,7 +19,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.1.0";
|
static const char *const Version = "2.2.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",
|
||||||
@@ -55,9 +55,9 @@ void _log(const char *filepath, int level, char *str) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScanCtx.verbose) {
|
if (LogCtx.verbose) {
|
||||||
if (level == LEVEL_DEBUG) {
|
if (level == LEVEL_DEBUG) {
|
||||||
if (ScanCtx.very_verbose) {
|
if (LogCtx.very_verbose) {
|
||||||
sist_log(filepath, level, str);
|
sist_log(filepath, level, str);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -76,10 +76,10 @@ void _logf(const char *filepath, int level, char *format, ...) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScanCtx.verbose) {
|
if (LogCtx.verbose) {
|
||||||
if (level == LEVEL_DEBUG) {
|
if (level == LEVEL_DEBUG) {
|
||||||
if (ScanCtx.very_verbose) {
|
if (LogCtx.very_verbose) {
|
||||||
sist_logf(filepath, level, format, args);
|
vsist_logf(filepath, level, format, args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sist_logf(filepath, level, format, args);
|
sist_logf(filepath, level, format, args);
|
||||||
|
|||||||
@@ -45,6 +45,18 @@ function getContentHighlight(hit) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPathHighlight(hit) {
|
||||||
|
if (hit.hasOwnProperty("highlight")) {
|
||||||
|
if (hit["highlight"].hasOwnProperty("path.text")) {
|
||||||
|
return hit["highlight"]["path.text"][0];
|
||||||
|
} else if (hit["highlight"].hasOwnProperty("path.nGram")) {
|
||||||
|
return hit["highlight"]["path.nGram"][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function applyNameToTitle(hit, title, extension) {
|
function applyNameToTitle(hit, title, extension) {
|
||||||
if (hit.hasOwnProperty("highlight")) {
|
if (hit.hasOwnProperty("highlight")) {
|
||||||
if (hit["highlight"].hasOwnProperty("name")) {
|
if (hit["highlight"].hasOwnProperty("name")) {
|
||||||
@@ -443,7 +455,7 @@ function createDocLine(hit) {
|
|||||||
if (contentHl !== undefined) {
|
if (contentHl !== undefined) {
|
||||||
const contentDiv = document.createElement("div");
|
const contentDiv = document.createElement("div");
|
||||||
contentDiv.setAttribute("class", "content-div");
|
contentDiv.setAttribute("class", "content-div");
|
||||||
contentDiv.insertAdjacentHTML('afterbegin', contentHl);
|
contentDiv.insertAdjacentHTML("afterbegin", contentHl);
|
||||||
titleDiv.appendChild(contentDiv);
|
titleDiv.appendChild(contentDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +465,13 @@ function createDocLine(hit) {
|
|||||||
let path = document.createElement("div");
|
let path = document.createElement("div");
|
||||||
path.setAttribute("class", "path-line");
|
path.setAttribute("class", "path-line");
|
||||||
path.setAttribute("title", hit["_source"]["path"] + "/");
|
path.setAttribute("title", hit["_source"]["path"] + "/");
|
||||||
path.appendChild(document.createTextNode(hit["_source"]["path"] + "/"));
|
|
||||||
|
const pathHighlight = getPathHighlight(hit);
|
||||||
|
if (pathHighlight) {
|
||||||
|
path.insertAdjacentHTML("afterbegin", pathHighlight + "/");
|
||||||
|
} else {
|
||||||
|
path.appendChild(document.createTextNode(hit["_source"]["path"] + "/"));
|
||||||
|
}
|
||||||
|
|
||||||
let tagContainer = document.createElement("div");
|
let tagContainer = document.createElement("div");
|
||||||
tagContainer.setAttribute("class", "tag-container");
|
tagContainer.setAttribute("class", "tag-container");
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ const _defaults = {
|
|||||||
display: "grid",
|
display: "grid",
|
||||||
fuzzy: true,
|
fuzzy: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
sort: "score"
|
sort: "score",
|
||||||
|
searchInPath: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
SORT_MODES = {
|
SORT_MODES = {
|
||||||
@@ -66,25 +67,30 @@ SORT_MODES = {
|
|||||||
],
|
],
|
||||||
key: hit => hit["_source"]["size"]
|
key: hit => hit["_source"]["size"]
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
function Settings() {
|
function Settings() {
|
||||||
this.options = {};
|
this.options = {};
|
||||||
|
|
||||||
this._onUpdate = function () {
|
this._onUpdate = function () {
|
||||||
$("#fuzzyToggle").prop("checked", this.options.fuzzy);
|
$("#fuzzyToggle").prop("checked", this.options.fuzzy);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.load = function () {
|
this.load = function () {
|
||||||
const raw = window.localStorage.getItem("options");
|
const raw = window.localStorage.getItem("options");
|
||||||
if (raw === null) {
|
if (raw === null) {
|
||||||
this.options = _defaults;
|
this.options = _defaults;
|
||||||
} else {
|
} else {
|
||||||
this.options = JSON.parse(raw);
|
const j = JSON.parse(raw);
|
||||||
|
if (!j || Object.keys(_defaults).some(k => !j.hasOwnProperty(k))) {
|
||||||
|
this.options = _defaults;
|
||||||
|
} else {
|
||||||
|
this.options = j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._onUpdate();
|
this._onUpdate();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.save = function () {
|
this.save = function () {
|
||||||
window.localStorage.setItem("options", JSON.stringify(this.options));
|
window.localStorage.setItem("options", JSON.stringify(this.options));
|
||||||
@@ -372,8 +378,15 @@ function search(after = null) {
|
|||||||
"font_name^6"
|
"font_name^6"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (CONF.options.searchInPath) {
|
||||||
|
fields.push("path.text^5");
|
||||||
|
}
|
||||||
|
|
||||||
if ($("#fuzzyToggle").prop("checked")) {
|
if ($("#fuzzyToggle").prop("checked")) {
|
||||||
fields.push("content.nGram");
|
fields.push("content.nGram");
|
||||||
|
if (CONF.options.searchInPath) {
|
||||||
|
fields.push("path.nGram");
|
||||||
|
}
|
||||||
fields.push("name.nGram^3");
|
fields.push("name.nGram^3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,6 +453,10 @@ function search(after = null) {
|
|||||||
font_name: {},
|
font_name: {},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (CONF.options.searchInPath) {
|
||||||
|
q.highlight.fields["path.text"] = {};
|
||||||
|
q.highlight.fields["path.nGram"] = {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$.jsonPost("es", q).then(searchResult => {
|
$.jsonPost("es", q).then(searchResult => {
|
||||||
@@ -656,7 +673,7 @@ function createPathTree(target) {
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
children: true
|
children: true
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
|
|
||||||
new InspireTreeDOM(pathTree, {
|
new InspireTreeDOM(pathTree, {
|
||||||
target: target
|
target: target
|
||||||
@@ -669,6 +686,7 @@ function updateSettings() {
|
|||||||
CONF.options.display = $("#settingDisplay").val();
|
CONF.options.display = $("#settingDisplay").val();
|
||||||
CONF.options.fuzzy = $("#settingFuzzy").prop("checked");
|
CONF.options.fuzzy = $("#settingFuzzy").prop("checked");
|
||||||
CONF.options.highlight = $("#settingHighlight").prop("checked");
|
CONF.options.highlight = $("#settingHighlight").prop("checked");
|
||||||
|
CONF.options.searchInPath = $("#settingSearchInPath").prop("checked");
|
||||||
CONF.save();
|
CONF.save();
|
||||||
|
|
||||||
searchDebounced();
|
searchDebounced();
|
||||||
@@ -691,4 +709,5 @@ function loadSettings() {
|
|||||||
$("#settingDisplay").val(CONF.options.display);
|
$("#settingDisplay").val(CONF.options.display);
|
||||||
$("#settingFuzzy").prop("checked", CONF.options.fuzzy);
|
$("#settingFuzzy").prop("checked", CONF.options.fuzzy);
|
||||||
$("#settingHighlight").prop("checked", CONF.options.highlight);
|
$("#settingHighlight").prop("checked", CONF.options.highlight);
|
||||||
|
$("#settingSearchInPath").prop("checked", CONF.options.searchInPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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">2.0.1</span>
|
<span class="badge badge-pill version">2.2.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>
|
||||||
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
||||||
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
||||||
@@ -186,6 +186,11 @@
|
|||||||
<label class="custom-control-label" for="settingFuzzy">Set fuzzy search by default</label>
|
<label class="custom-control-label" for="settingFuzzy">Set fuzzy search by default</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="settingSearchInPath">
|
||||||
|
<label class="custom-control-label" for="settingSearchInPath">Enable matching query against document path</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label for="settingDisplay">Display</label>
|
<label for="settingDisplay">Display</label>
|
||||||
<select id="settingDisplay" class="form-control form-control-sm">
|
<select id="settingDisplay" class="form-control form-control-sm">
|
||||||
<option value="grid">Grid</option>
|
<option value="grid">Grid</option>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
third-party/libscan
vendored
2
third-party/libscan
vendored
Submodule third-party/libscan updated: 621ee64084...f363659936
Reference in New Issue
Block a user