24 lines
475 B
Go
Executable File
24 lines
475 B
Go
Executable File
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"path"
|
|
|
|
"github.com/gomarkdown/markdown"
|
|
)
|
|
|
|
func notesFile(p Path, w http.ResponseWriter, r *http.Request) {
|
|
b, _ := ioutil.ReadFile(p.Local)
|
|
notesFileHead(p, w)
|
|
content := markdown.ToHTML(b, nil, nil)
|
|
fmt.Fprintf(w, "%s\n", content)
|
|
}
|
|
|
|
func notesFileHead(p Path, w http.ResponseWriter) {
|
|
fmt.Fprintf(w, `
|
|
<a href=%q><input type="button" value="Edit"></input></a>
|
|
`, path.Join("/edit/", p.BaseHREF))
|
|
}
|