From 04c41b6f74b4762555a56b056db4ab5e123a609a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 24 Feb 2024 14:17:33 +0100 Subject: html/template --- wiki.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'wiki.go') diff --git a/wiki.go b/wiki.go index 8afd5fd..6a7bbf9 100644 --- a/wiki.go +++ b/wiki.go @@ -1,24 +1,15 @@ package main import ( - "flag" + "html/template" "io/ioutil" "net/http" "os" "path" - "text/template" "github.com/russross/blackfriday" ) -var ( - listen = flag.String("listen", ":8080", "Listen at") - listentls = flag.String("listentls", ":8443", "Listen TLS at") - cert = flag.String("cert", "cert/cert.pem", "TLS Certificate") - key = flag.String("key", "cert/key.pem", "TLS Key") - data = flag.String("data", "data", "Data dir") -) - type Page struct { Title string Body []byte @@ -50,12 +41,6 @@ func (p *Page) render(w http.ResponseWriter, tmpl *template.Template) { } } -func (p *Page) HTML() string { - return string(blackfriday.MarkdownCommon([]byte(p.Body))) -} - -func main() { - flag.Parse() - go http.ListenAndServeTLS(*listentls, *cert, *key, nil) - http.ListenAndServe(*listen, nil) +func (p *Page) HTML() template.HTML { + return template.HTML(blackfriday.MarkdownCommon(p.Body)) } -- cgit v1.2.3