diff --git a/main.go b/main.go index 5a7726d..6ebb2a8 100644 --- a/main.go +++ b/main.go @@ -138,6 +138,7 @@ func main() { router.HandleFunc("/_api/pdf/{pagename:.*}", basicAuth(getPDFPage)).Methods("GET") router.HandleFunc("/_api/pinfo/{pagename:.*}", basicAuth(getPageInfo)).Methods("GET") router.HandleFunc("/_api/fts/{searchterm:.*}", basicAuth(getFTS)).Methods("GET") + router.HandleFunc("/_api/config", basicAuth(getWikiConfig)).Methods("GET") router.HandleFunc("/{pagename:.*}", basicAuth(getHTMLPage)).Methods("GET") router.HandleFunc("/{pagename:.*}", basicAuth(postHTMLPage)).Methods("POST") @@ -330,6 +331,29 @@ func getPageInfo(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(data) } +func getWikiConfig(w http.ResponseWriter, r *http.Request) { + + FTS := false + Login := false + + if config.DataPathFTS != "" { + FTS = true + } + if config.WebUser != "" && config.WebPasswd != "" { + Login = true + } + + data := struct { + FTS bool + Login bool + }{ + FTS, + Login, + } + + json.NewEncoder(w).Encode(data) +} + func basicAuth(handler http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { diff --git a/web/index.html b/web/index.html index 846044d..440c96d 100644 --- a/web/index.html +++ b/web/index.html @@ -124,7 +124,7 @@ mark {
  • Preview
  • Save
  • PDF
  • -
  • Logout
  • +
  • Logout