65 lines
767 B
Go
65 lines
767 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) handleConfig(
|
|
w http.ResponseWriter,
|
|
r *http.Request,
|
|
) {
|
|
|
|
if r.Method == http.MethodPost {
|
|
|
|
homePath := r.FormValue("home_path")
|
|
|
|
err := s.store.SetConfig(
|
|
"home_path",
|
|
homePath,
|
|
)
|
|
|
|
if err != nil {
|
|
http.Error(w, err.Error(), 500)
|
|
return
|
|
}
|
|
|
|
http.Redirect(
|
|
w,
|
|
r,
|
|
"/-/sys/config",
|
|
http.StatusFound,
|
|
)
|
|
|
|
return
|
|
}
|
|
|
|
homePath, err :=
|
|
s.store.GetConfig(
|
|
"home_path",
|
|
)
|
|
|
|
if err != nil {
|
|
http.Error(w, err.Error(), 500)
|
|
return
|
|
}
|
|
|
|
recent, err :=
|
|
s.store.ListRecentObjects(
|
|
50,
|
|
)
|
|
|
|
if err != nil {
|
|
http.Error(w, err.Error(), 500)
|
|
return
|
|
}
|
|
|
|
s.render(
|
|
w,
|
|
"config.gohtml",
|
|
map[string]any{
|
|
"HomePath": homePath,
|
|
"Objects": recent,
|
|
},
|
|
)
|
|
}
|