mirror of
https://github.com/simon987/sist2.git
synced 2025-12-16 16:59:03 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 046edea0e2 | |||
| a011b7e97b |
@@ -22,7 +22,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.4.1";
|
static const char *const Version = "2.4.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",
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ mark {
|
|||||||
margin: 3px;
|
margin: 3px;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
color: rgb(224, 224, 224);
|
color: rgb(224, 224, 224);
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.irs-single, .irs-from, .irs-to {
|
.irs-single, .irs-from, .irs-to {
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ mark {
|
|||||||
margin: 3px;
|
margin: 3px;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
color: #000;
|
color: #000;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.irs-single, .irs-from, .irs-to {
|
.irs-single, .irs-from, .irs-to {
|
||||||
|
|||||||
@@ -27,18 +27,12 @@ function gifOver(thumbnail, hit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getContentHighlight(hit) {
|
function getContentHighlight(hit) {
|
||||||
const re = RegExp(/<mark>/g);
|
|
||||||
|
|
||||||
const sortByMathCount = (a, b) => {
|
|
||||||
return b.match(re).length - a.match(re).length;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (hit.hasOwnProperty("highlight")) {
|
if (hit.hasOwnProperty("highlight")) {
|
||||||
if (hit["highlight"].hasOwnProperty("content")) {
|
if (hit["highlight"].hasOwnProperty("content")) {
|
||||||
return hit["highlight"]["content"].sort(sortByMathCount)[0];
|
return hit["highlight"]["content"][0];
|
||||||
|
|
||||||
} else if (hit["highlight"].hasOwnProperty("content.nGram")) {
|
} else if (hit["highlight"].hasOwnProperty("content.nGram")) {
|
||||||
return hit["highlight"]["content.nGram"].sort(sortByMathCount)[0];
|
return hit["highlight"]["content.nGram"][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -417,6 +417,9 @@ function search(after = null) {
|
|||||||
q.highlight = {
|
q.highlight = {
|
||||||
pre_tags: ["<mark>"],
|
pre_tags: ["<mark>"],
|
||||||
post_tags: ["</mark>"],
|
post_tags: ["</mark>"],
|
||||||
|
fragment_size: CONF.options.fragmentSize,
|
||||||
|
number_of_fragments: 1,
|
||||||
|
order: "score",
|
||||||
fields: {
|
fields: {
|
||||||
content: {},
|
content: {},
|
||||||
// "content.nGram": {},
|
// "content.nGram": {},
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ const _defaults = {
|
|||||||
treemapGroupingDepth: 3,
|
treemapGroupingDepth: 3,
|
||||||
treemapColor: "PuBuGn",
|
treemapColor: "PuBuGn",
|
||||||
treemapSize: "large",
|
treemapSize: "large",
|
||||||
suggestPath: true
|
suggestPath: true,
|
||||||
|
fragmentSize: 100
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
@@ -116,6 +117,7 @@ function loadSettings() {
|
|||||||
$("#settingTreemapSize").val(CONF.options.treemapSize);
|
$("#settingTreemapSize").val(CONF.options.treemapSize);
|
||||||
$("#settingTreemapType").val(CONF.options.treemapType);
|
$("#settingTreemapType").val(CONF.options.treemapType);
|
||||||
$("#settingSuggestPath").prop("checked", CONF.options.suggestPath);
|
$("#settingSuggestPath").prop("checked", CONF.options.suggestPath);
|
||||||
|
$("#settingFragmentSize").val(CONF.options.fragmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Settings() {
|
function Settings() {
|
||||||
@@ -158,6 +160,7 @@ function updateSettings() {
|
|||||||
CONF.options.treemapSize = $("#settingTreemapSize").val();
|
CONF.options.treemapSize = $("#settingTreemapSize").val();
|
||||||
CONF.options.treemapType = $("#settingTreemapType").val();
|
CONF.options.treemapType = $("#settingTreemapType").val();
|
||||||
CONF.options.suggestPath = $("#settingSuggestPath").prop("checked");
|
CONF.options.suggestPath = $("#settingSuggestPath").prop("checked");
|
||||||
|
CONF.options.fragmentSize = $("#settingFragmentSize").val();
|
||||||
CONF.save();
|
CONF.save();
|
||||||
|
|
||||||
if (typeof searchDebounced !== "undefined") {
|
if (typeof searchDebounced !== "undefined") {
|
||||||
|
|||||||
@@ -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.4.1</span>
|
<span class="badge badge-pill version">2.4.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 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>
|
||||||
@@ -197,6 +197,12 @@
|
|||||||
<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/>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="number" class="form-control" id="settingFragmentSize">
|
||||||
|
<label for="settingFragmentSize">Highlight context size in characters</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>
|
||||||
|
|||||||
@@ -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.4.1</span>
|
<span class="badge badge-pill version">2.4.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" 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"
|
||||||
@@ -71,15 +71,21 @@
|
|||||||
<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>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<div class="custom-control custom-checkbox">
|
<br/>
|
||||||
<input type="checkbox" class="custom-control-input" id="settingSearchInPath">
|
<div class="form-group">
|
||||||
<label class="custom-control-label" for="settingSearchInPath">Enable matching query against document
|
<input type="number" class="form-control" id="settingFragmentSize">
|
||||||
path</label>
|
<label for="settingFragmentSize">Highlight context size in characters</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label for="settingDisplay">Display</label>
|
<label for="settingDisplay">Display</label>
|
||||||
|
|||||||
22
src/util.c
22
src/util.c
@@ -42,16 +42,34 @@ char *abspath(const char *path) {
|
|||||||
return abs;
|
return abs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shell_escape(char *dst, const char *src) {
|
||||||
|
const char *ptr = src;
|
||||||
|
char *out = dst;
|
||||||
|
while ((*ptr)) {
|
||||||
|
char c = *ptr++;
|
||||||
|
|
||||||
|
if (c == '&' || c == '\n' || c == '|' || c == ';' || c == '<' ||
|
||||||
|
c == '>' || c == '(' || c == ')' || c == '{' || c == '}') {
|
||||||
|
*out++ = '\\';
|
||||||
|
}
|
||||||
|
*out++ = c;
|
||||||
|
}
|
||||||
|
*out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
char *expandpath(const char *path) {
|
char *expandpath(const char *path) {
|
||||||
char tmp[PATH_MAX * 2] = {0,};
|
char tmp[PATH_MAX * 2];
|
||||||
|
|
||||||
|
shell_escape(tmp, path);
|
||||||
|
|
||||||
wordexp_t w;
|
wordexp_t w;
|
||||||
wordexp(path, &w, 0);
|
wordexp(tmp, &w, 0);
|
||||||
|
|
||||||
if (w.we_wordv == NULL) {
|
if (w.we_wordv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*tmp = '\0';
|
||||||
for (int i = 0; i < w.we_wordc; i++) {
|
for (int i = 0; i < w.we_wordc; i++) {
|
||||||
strcat(tmp, w.we_wordv[i]);
|
strcat(tmp, w.we_wordv[i]);
|
||||||
if (i != w.we_wordc - 1) {
|
if (i != w.we_wordc - 1) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user