Messing around with blog editor

This commit is contained in:
Caleb Gardner
2024-11-09 06:44:10 -06:00
parent 94633293f5
commit 6896266055
4 changed files with 59 additions and 15 deletions
+3 -15
View File
@@ -147,9 +147,12 @@ func setupWebsite(mux *http.ServeMux) {
url, _ := url.Parse("https://localhost:30000")
mux.Handle("rpg.darkstorm.tech/", httputil.NewSingleHostReverseProxy(url))
}
edit := NewBlogEditor(blogApp, back)
mux.HandleFunc("GET /files/{w...}", filesRequest)
mux.HandleFunc("GET /portfolio", portfolioRequest)
mux.HandleFunc("GET /list", blogListHandle)
mux.HandleFunc("GET /login", edit.LoginPage)
mux.HandleFunc("GET /editor/", edit.Editor)
mux.HandleFunc("/", mainHandle)
}
@@ -159,10 +162,6 @@ func mainHandle(w http.ResponseWriter, r *http.Request) {
latestBlogsHandle(w, r)
return
}
if path == "login" {
sendContent(w, r, loginScreen, "", "")
return
}
stat, err := os.Stat(filepath.Join(*webRoot, path))
if err == nil && !stat.IsDir() {
http.ServeFile(w, r, filepath.Join(*webRoot, path))
@@ -177,14 +176,3 @@ func mainHandle(w http.ResponseWriter, r *http.Request) {
}
blogHandle(w, r, path)
}
const loginScreen = `
<script src="https://unpkg.com/htmx-ext-json-enc@2.0.1/json-enc.js"></script>
<form id="loginForm" onsubmit="login(event)">
<label for="username">Username:</label>
<input name="username" id="usernameInput"></input>
<label for="password">Password:</label>
<input name="password" type="password" id="passwordInput"></input>
<button id="loginButton" type="submit">Login</button>
</form>
`