25 lines
576 B
Go
Executable File
25 lines
576 B
Go
Executable File
package notes
|
|
|
|
import (
|
|
"html"
|
|
"gitea.inhome.blapointe.com/local/notes-server/filetree"
|
|
"net/http"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
func (n *Notes) Create(w http.ResponseWriter, r *http.Request) {
|
|
content := r.FormValue("base")
|
|
content = html.UnescapeString(content)
|
|
content = strings.ReplaceAll(content, "\r", "")
|
|
urlPath := path.Join(r.URL.Path, content)
|
|
p := filetree.NewPathFromURL(urlPath)
|
|
if p.IsDir() {
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
return
|
|
}
|
|
url := *r.URL
|
|
url.Path = path.Join("/edit/", p.BaseHREF)
|
|
http.Redirect(w, r, url.String(), http.StatusSeeOther)
|
|
}
|