necessário
This commit is contained in:
parent
92b0a902ca
commit
7edb0a17ed
5 changed files with 199 additions and 162 deletions
64
main.go
64
main.go
|
|
@ -111,7 +111,7 @@ func main() {
|
|||
Port: ":2323",
|
||||
Root: "/home/xi/seed/gallery-dl/",
|
||||
Galleries: make([]gallery.Gallery, 0, 50),
|
||||
UniqueTags: make(map[gallery.Tag]int),
|
||||
UniqueTags: make(map[string]int),
|
||||
UniqueArtists: make(map[string]int),
|
||||
UniqueGroups: make(map[string]int),
|
||||
UniqueParodies: make(map[string]int),
|
||||
|
|
@ -276,35 +276,35 @@ func main() {
|
|||
_ = png.Encode(io.MultiWriter(imageCache, w), destImage)
|
||||
})
|
||||
|
||||
// http.DefaultServeMux.HandleFunc("POST /filter/{tag}/{sex}", func(w http.ResponseWriter, r *http.Request) {
|
||||
// tagLookup := r.PathValue("tag")
|
||||
// if tagLookup == "" {
|
||||
// panic(fmt.Errorf("tag could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// if tagLookup == "clear" {
|
||||
// state.Filtered = []gallery.Tag{}
|
||||
// view.GalleriesListing(state.Galleries).Render(w)
|
||||
// return
|
||||
// }
|
||||
// tagSexLookup := r.PathValue("sex")
|
||||
// if tagSexLookup == "" {
|
||||
// panic(fmt.Errorf("tag sex could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// sex := gallery.ToGender(tagSexLookup)
|
||||
// i := slices.IndexFunc(state.TagKeys, func(a gallery.Tag) bool {
|
||||
// return a.Name == tagLookup && a.Sex == sex
|
||||
// })
|
||||
// if i < 0 {
|
||||
// panic(fmt.Errorf("tag could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// tag := state.TagKeys[i]
|
||||
// i = slices.Index(state.Filtered, tag)
|
||||
// if i < 0 {
|
||||
// state.Filtered = append(state.Filtered, tag)
|
||||
// } else {
|
||||
// state.Filtered = slices.Delete(state.Filtered, i, i+1)
|
||||
// }
|
||||
// view.GalleriesListing(state.FilterGalleries()).Render(w)
|
||||
// http.DefaultServeMux.HandleFunc("GET /filter/{tag}/{sex}", func(w http.ResponseWriter, r *http.Request) {
|
||||
// tagLookup := r.PathValue("tag")
|
||||
// if tagLookup == "" {
|
||||
// panic(fmt.Errorf("tag could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// if tagLookup == "clear" {
|
||||
// state.Filtered = []gallery.Tag{}
|
||||
// view.SearchResults(state.Galleries).Render(w)
|
||||
// return
|
||||
// }
|
||||
// tagSexLookup := r.PathValue("sex")
|
||||
// if tagSexLookup == "" {
|
||||
// panic(fmt.Errorf("tag sex could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// sex := gallery.Gender(tagSexLookup)
|
||||
// i := slices.IndexFunc(state.TagKeys, func(a gallery.Tag) bool {
|
||||
// return a.Name == tagLookup && a.Sex == sex
|
||||
// })
|
||||
// if i < 0 {
|
||||
// panic(fmt.Errorf("tag could not be found: %s", r.URL.Path))
|
||||
// }
|
||||
// tag := state.TagKeys[i]
|
||||
// i = slices.Index(state.Filtered, tag)
|
||||
// if i < 0 {
|
||||
// state.Filtered = append(state.Filtered, tag)
|
||||
// } else {
|
||||
// state.Filtered = slices.Delete(state.Filtered, i, i+1)
|
||||
// }
|
||||
// view.SearchResults(state.FilterGalleries()).Render(w)
|
||||
// })
|
||||
|
||||
http.DefaultServeMux.HandleFunc("GET /stats", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -328,7 +328,7 @@ func main() {
|
|||
query := r.FormValue("search")
|
||||
log.Println("search form result:", query)
|
||||
if query == "" {
|
||||
view.SearchResults(state.Galleries, 0).Render(w)
|
||||
view.SearchResults(state.Galleries).Render(w)
|
||||
return
|
||||
}
|
||||
// ranks := fuzzy.RankFindFold(search, state.GalleryNames)
|
||||
|
|
@ -362,7 +362,7 @@ func main() {
|
|||
}
|
||||
galleries = append(galleries, state.Galleries[r.OriginalIndex])
|
||||
}
|
||||
view.SearchResults(galleries, 0).Render(w)
|
||||
view.SearchResults(galleries).Render(w)
|
||||
})
|
||||
|
||||
log.Fatal(server.Serve(ln))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue