diff --git a/README.md b/README.md index d09ef8d..91422bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Wiki web application models built using `Go` - +![Go](https://img.shields.io/github/go-mod/go-version/rjNemo/go-wiki) [![License](https://img.shields.io/github/license/rjNemo/go-wiki)](LICENSE.md) ![Release](https://img.shields.io/github/v/release/rjNemo/go-wiki) ![Tag](https://img.shields.io/github/v/tag/rjNemo/go-wiki) ## Getting Started @@ -38,6 +38,7 @@ Add additional notes about how to deploy this on a live system - [Go](https://golang.org/) - Build simple, reliable, and efficient software - [Bootstrap](https://getbootstrap.com/) - The most popular HTML, CSS, and JS library in the world +- [Quilljs](https://quilljs.com/) - Your powerful rich text editor ## Contributing diff --git a/TODO.md b/TODO.md index 6cab3a6..a048b8b 100644 --- a/TODO.md +++ b/TODO.md @@ -4,3 +4,4 @@ - [ ] All errors are fatal. Provide proper error handling. - [ ] Refactor UserStore code - [ ] Request-scoped [context](https://www.alexedwards.net/blog/organising-database-access) +- [ ] Post quilljs data to backend diff --git a/controllers/page.go b/controllers/page.go index 206c1cd..74ecf95 100644 --- a/controllers/page.go +++ b/controllers/page.go @@ -41,6 +41,10 @@ func (ph PageHandler) edit(w http.ResponseWriter, r *http.Request, title string) views.Template(w, "edit", p) } +func (ph PageHandler) editor(w http.ResponseWriter, r *http.Request, title string) { + log.Println(r.Body) +} + func (ph PageHandler) save(w http.ResponseWriter, r *http.Request, title string) { body := r.FormValue("body") diff --git a/controllers/router.go b/controllers/router.go index d8ae6ef..e813714 100644 --- a/controllers/router.go +++ b/controllers/router.go @@ -16,6 +16,7 @@ func Router(ctx data.Context) { http.HandleFunc("/index/", ph.index) http.HandleFunc("/view/", makeHandler(ph.view)) http.HandleFunc("/edit/", makeHandler(ph.edit)) + http.HandleFunc("/editor/", makeHandler(ph.editor)) http.HandleFunc("/save/", makeHandler(ph.save)) http.HandleFunc("/new/", ph.new) http.HandleFunc("/contact/", hh.contact) diff --git a/static/main.js b/static/main.js new file mode 100644 index 0000000..538923d --- /dev/null +++ b/static/main.js @@ -0,0 +1,15 @@ +let quill = new Quill("#editor", { + theme: "snow" +}); + +function save() { + let text = quill.getContents(); + console.log(text); + + fetch("http://localhost:8080/editor", { + method: "post", + headers: { Accept: "application/json", "Content-Type": "application/json" } + }); + + console.log("send to backend"); +} diff --git a/views/templates/editor.html b/views/templates/editor.html new file mode 100644 index 0000000..525c386 --- /dev/null +++ b/views/templates/editor.html @@ -0,0 +1,46 @@ +{{define "title"}} {{.Title}} | Go-Wiki {{end}} {{define "content"}} +

Editing {{.Title}}

+ + + + +
+

{{.Title}}

+


+

{{printf "%s" .Body}}

+


+
+ +
+
+ +
+
+ + + + + + +{{end}}