|
|
|
@ -1,9 +1,9 @@ |
|
|
|
|
|
|
|
|
|
import { create_photo, create_album } from './media.js'; |
|
|
|
|
|
|
|
|
|
export function escape_regex(string) { |
|
|
|
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
|
|
|
} |
|
|
|
|
export function escape_regex(s) { |
|
|
|
|
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export function do_image_query(query, database, collection_path, collection_thumbs_path) { |
|
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
@ -173,12 +173,12 @@ function filter_from_text_segment(result_type, segment) { |
|
|
|
|
|
|
|
|
|
if (result_type == ResultTypeEnum.IMAGE) { |
|
|
|
|
match_type = MatchTypeEnum.MATCH_EQUALS; |
|
|
|
|
match_text = "\"" + segment['text'] + "\""; |
|
|
|
|
match_text = '"' + segment['text'] + '"'; |
|
|
|
|
match_against = "Images.name"; |
|
|
|
|
} else if (result_type == ResultTypeEnum.ALBUM) { |
|
|
|
|
// Match against the album "name", which is the basename of its relative path.
|
|
|
|
|
match_type = MatchTypeEnum.MATCH_REGEXP; |
|
|
|
|
match_text = "\"" + '\/(.*\/)*' + escape_regex(segment['text']) + "\""; |
|
|
|
|
match_text = '"' + '\/(.*\/)*' + escape_regex(segment['text']) + '"'; |
|
|
|
|
match_against = "Albums.relativePath"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -207,8 +207,8 @@ export function user_query_from_search_string(search_string) { |
|
|
|
|
|
|
|
|
|
export function user_query_from_album_path(album_path) { |
|
|
|
|
var r = new UserQuery(); |
|
|
|
|
var match_type = MatchTypeEnum.MATCH_EQUALS; |
|
|
|
|
var match_text = "\"" + album_path + "\""; |
|
|
|
|
var match_type = MatchTypeEnum.MATCH_REGEXP; |
|
|
|
|
var match_text = '"' + escape_regex(album_path) + '(\/[^\/]+)*' + '"'; |
|
|
|
|
var match_against = "Albums.relativePath"; |
|
|
|
|
r.image_filter = new MatchingFilter(ResultTypeEnum.ALBUM, match_against, match_text, match_type, false); |
|
|
|
|
r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false); |
|
|
|
|