photoprism/pkg/txt/strings.go
Michael Mayer 24eff21aa4 Search: Default to photo names and keywords #1517 #1560
Default to photo name when search term is too short or on the stop list.
Search full text index otherwise, which now include names of people
(requires reindexing).
2021-09-29 20:09:34 +02:00

49 lines
754 B
Go

package txt
import (
"strings"
)
// Bool casts a string to bool.
func Bool(s string) bool {
s = strings.TrimSpace(s)
if s == "" || No(s) {
return false
}
return true
}
// Yes returns true if a string represents "yes".
func Yes(s string) bool {
if s == "" {
return false
}
s = strings.ToLower(strings.TrimSpace(s))
return strings.IndexAny(s, "ytjposiд") == 0
}
// No returns true if a string represents "no".
func No(s string) bool {
if s == "" {
return false
}
s = strings.ToLower(strings.TrimSpace(s))
return strings.IndexAny(s, "0nhufeн") == 0
}
// New returns true if a string represents "new".
func New(s string) bool {
if s == "" {
return false
}
s = strings.ToLower(strings.TrimSpace(s))
return s == "new"
}