Compare commits

..

No commits in common. "c575fca91d3d16d0a364c8ff88b37750ec9cc34c" and "2b639bd4ac40a1988af3098dc4a6a6e94aa439c2" have entirely different histories.

8 changed files with 57 additions and 82 deletions

File diff suppressed because one or more lines are too long

View File

@ -69,7 +69,7 @@ interface SortMode {
class Sist2Query { class Sist2Query {
searchQuery(blankSearch: boolean = false): any { searchQuery(): any {
const getters = store.getters; const getters = store.getters;
@ -93,6 +93,22 @@ class Sist2Query {
{terms: {index: selectedIndexIds}} {terms: {index: selectedIndexIds}}
] as any[]; ] as any[];
if (sizeMin && sizeMax) {
filters.push({range: {size: {gte: sizeMin, lte: sizeMax}}})
} else if (sizeMin) {
filters.push({range: {size: {gte: sizeMin}}})
} else if (sizeMax) {
filters.push({range: {size: {lte: sizeMax}}})
}
if (dateMin && dateMax) {
filters.push({range: {mtime: {gte: dateMin, lte: dateMax}}})
} else if (dateMin) {
filters.push({range: {mtime: {gte: dateMin}}})
} else if (dateMax) {
filters.push({range: {mtime: {lte: dateMax}}})
}
const fields = [ const fields = [
"name^8", "name^8",
"content^3", "content^3",
@ -112,39 +128,20 @@ class Sist2Query {
fields.push("name.nGram^3"); fields.push("name.nGram^3");
} }
if (!blankSearch) { const path = pathText.replace(/\/$/, "").toLowerCase(); //remove trailing slashes
if (sizeMin && sizeMax) { if (path !== "") {
filters.push({range: {size: {gte: sizeMin, lte: sizeMax}}}) filters.push({term: {path: path}})
} else if (sizeMin) { }
filters.push({range: {size: {gte: sizeMin}}})
} else if (sizeMax) {
filters.push({range: {size: {lte: sizeMax}}})
}
if (dateMin && dateMax) { if (selectedMimeTypes.length > 0) {
filters.push({range: {mtime: {gte: dateMin, lte: dateMax}}}) filters.push({terms: {"mime": selectedMimeTypes}});
} else if (dateMin) { }
filters.push({range: {mtime: {gte: dateMin}}})
} else if (dateMax) {
filters.push({range: {mtime: {lte: dateMax}}})
}
const path = pathText.replace(/\/$/, "").toLowerCase(); //remove trailing slashes if (selectedTags.length > 0) {
if (getters.optTagOrOperator) {
if (path !== "") { filters.push({terms: {"tag": selectedTags}});
filters.push({term: {path: path}}) } else {
} selectedTags.forEach((tag: string) => filters.push({term: {"tag": tag}}));
if (selectedMimeTypes.length > 0) {
filters.push({terms: {"mime": selectedMimeTypes}});
}
if (selectedTags.length > 0) {
if (getters.optTagOrOperator) {
filters.push({terms: {"tag": selectedTags}});
} else {
selectedTags.forEach((tag: string) => filters.push({term: {"tag": tag}}));
}
} }
} }
@ -185,7 +182,7 @@ class Sist2Query {
size: size, size: size,
} as any; } as any;
if (!empty && !blankSearch) { if (!empty) {
q.query.bool.must = query; q.query.bool.must = query;
} }
@ -240,7 +237,7 @@ class Sist2Query {
} }
} }
if (!empty && !blankSearch) { if (!empty) {
q.query.function_score.query.bool.must.push(query); q.query.function_score.query.bool.must.push(query);
} }
} }

View File

@ -89,6 +89,7 @@ export default {
switch (e.key) { switch (e.key) {
case " ": { case " ": {
console.log("SPACE")
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -97,12 +98,16 @@ export default {
[...document.getElementsByClassName("fslightbox-absoluted")].forEach(elem => { [...document.getElementsByClassName("fslightbox-absoluted")].forEach(elem => {
if (elem.style.transform === "translate(0px)" || elem.style.transform === "translate(0px, 0px)") { if (elem.style.transform === "translate(0px)" || elem.style.transform === "translate(0px, 0px)") {
const vid = elem.getElementsByTagName("video")[0]; const vid = elem.getElementsByTagName("video")[0];
console.log(elem)
console.log(vid)
if (vid) { if (vid) {
if (vid.paused) { if (vid.paused) {
vid.play(); vid.play();
console.log("PLAY")
} else { } else {
vid.pause() vid.pause()
console.log("PAUSE")
} }
} }
} }
@ -114,28 +119,24 @@ export default {
} }
case "ArrowUp": case "ArrowUp":
case "k": { case "k": {
if (!lightboxStore.data.isThumbing && lightboxStore.core.thumbsToggler) { if (!lightboxStore.data.isThumbing) {
lightboxStore.core.thumbsToggler.toggleThumbs(); lightboxStore.core.thumbsToggler.toggleThumbs();
} }
return false; return false;
} }
case "ArrowDown": case "ArrowDown":
case "j": { case "j": {
if (lightboxStore.data.isThumbing && lightboxStore.core.thumbsToggler) { if (lightboxStore.data.isThumbing) {
lightboxStore.core.thumbsToggler.toggleThumbs(); lightboxStore.core.thumbsToggler.toggleThumbs();
} }
return false; return false;
} }
case "h": { case "h": {
if (lightboxStore.core.stageManager.getPreviousSlideIndex) { lightboxStore.core.slideIndexChanger.jumpTo(lightboxStore.core.stageManager.getPreviousSlideIndex());
lightboxStore.core.slideIndexChanger.jumpTo(lightboxStore.core.stageManager.getPreviousSlideIndex()); break;
}
return false;
} }
case "l": { case "l": {
if (lightboxStore.core.stageManager.getNextSlideIndex) { lightboxStore.core.slideIndexChanger.jumpTo(lightboxStore.core.stageManager.getNextSlideIndex());
lightboxStore.core.slideIndexChanger.jumpTo(lightboxStore.core.stageManager.getNextSlideIndex());
}
return false; return false;
} }
} }

View File

@ -241,11 +241,6 @@ export default new Vuex.Store({
} }
}, },
async updateArgs({state}, router: VueRouter) { async updateArgs({state}, router: VueRouter) {
if (router.currentRoute.path !== "/") {
return;
}
await router.push({ await router.push({
query: { query: {
q: state.searchText.trim() ? state.searchText.trim().replace(/\s+/g, " ") : undefined, q: state.searchText.trim() ? state.searchText.trim().replace(/\s+/g, " ") : undefined,

View File

@ -139,9 +139,7 @@ export default Vue.extend({
this.setSist2Info(data); this.setSist2Info(data);
this.setIndices(data.indices); this.setIndices(data.indices);
const doBlankSearch = !this.$store.state.optUpdateMimeMap; Sist2Api.getMimeTypes(Sist2Query.searchQuery()).then(({mimeMap}) => {
Sist2Api.getMimeTypes(Sist2Query.searchQuery(doBlankSearch)).then(({mimeMap}) => {
this.$store.commit("setUiMimeMap", mimeMap); this.$store.commit("setUiMimeMap", mimeMap);
this.uiLoading = false; this.uiLoading = false;
this.search(true); this.search(true);

View File

@ -214,13 +214,7 @@ void print_errors(response_t *r) {
*(tmp + r->size) = '\0'; *(tmp + r->size) = '\0';
cJSON *ret_json = cJSON_Parse(tmp); cJSON *ret_json = cJSON_Parse(tmp);
cJSON *errors = cJSON_GetObjectItem(ret_json, "errors"); if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) {
if (errors == NULL) {
char *str = cJSON_Print(ret_json);
LOG_ERRORF("elastic.c", "%s\n", str);
cJSON_free(str);
} else if (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) {

File diff suppressed because one or more lines are too long

View File

@ -4,12 +4,7 @@
#define MIN_SIZE 32 #define MIN_SIZE 32
#define AVIO_BUF_SIZE 8192 #define AVIO_BUF_SIZE 8192
#define IS_VIDEO(fmt) ( \ #define IS_VIDEO(fmt) ((fmt)->iformat->name && strcmp((fmt)->iformat->name, "image2") != 0)
(fmt)->iformat->name && strcmp((fmt)->iformat->name, "image2") != 0 \
&& strcmp((fmt)->iformat->name, "jpeg_pipe") != 0 \
&& strcmp((fmt)->iformat->name, "webp_pipe") != 0 \
&& strcmp((fmt)->iformat->name, "png_pipe") != 0 \
)
#define STORE_AS_IS ((void*)-1) #define STORE_AS_IS ((void*)-1)
@ -284,22 +279,18 @@ static void
append_video_meta(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx, AVFrame *frame, document_t *doc, int is_video) { append_video_meta(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx, AVFrame *frame, document_t *doc, int is_video) {
if (is_video) { if (is_video) {
if (pFormatCtx->duration / AV_TIME_BASE != 0) { meta_line_t *meta_duration = malloc(sizeof(meta_line_t));
meta_line_t *meta_duration = malloc(sizeof(meta_line_t)); meta_duration->key = MetaMediaDuration;
meta_duration->key = MetaMediaDuration; meta_duration->long_val = pFormatCtx->duration / AV_TIME_BASE;
meta_duration->long_val = pFormatCtx->duration / AV_TIME_BASE; if (meta_duration->long_val > INT32_MAX) {
if (meta_duration->long_val > INT32_MAX) { meta_duration->long_val = 0;
meta_duration->long_val = 0;
}
APPEND_META(doc, meta_duration)
} }
APPEND_META(doc, meta_duration)
if (pFormatCtx->bit_rate != 0) { meta_line_t *meta_bitrate = malloc(sizeof(meta_line_t));
meta_line_t *meta_bitrate = malloc(sizeof(meta_line_t)); meta_bitrate->key = MetaMediaBitrate;
meta_bitrate->key = MetaMediaBitrate; meta_bitrate->long_val = pFormatCtx->bit_rate;
meta_bitrate->long_val = pFormatCtx->bit_rate; APPEND_META(doc, meta_bitrate)
APPEND_META(doc, meta_bitrate)
}
} }
AVDictionaryEntry *tag = NULL; AVDictionaryEntry *tag = NULL;
@ -586,8 +577,7 @@ void parse_media_format_ctx(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx,
int video_duration_in_seconds = (int) (pFormatCtx->duration / AV_TIME_BASE); int video_duration_in_seconds = (int) (pFormatCtx->duration / AV_TIME_BASE);
int thumbnails_to_generate = (IS_VIDEO(pFormatCtx) && stream->codecpar->codec_id != AV_CODEC_ID_GIF && int thumbnails_to_generate = (IS_VIDEO(pFormatCtx) && stream->codecpar->codec_id != AV_CODEC_ID_GIF && video_duration_in_seconds >= 15)
video_duration_in_seconds >= 15)
// Limit to ~1 thumbnail every 7s // Limit to ~1 thumbnail every 7s
? MAX(MIN(ctx->tn_count, video_duration_in_seconds / 7 + 1), 1) + 1 ? MAX(MIN(ctx->tn_count, video_duration_in_seconds / 7 + 1), 1) + 1
: 1; : 1;