From 9003cd5b93421e2942531464ccc07fdd129cf252 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 13 Dec 2017 10:49:13 -0800 Subject: [PATCH] fix build --- html.go | 7 ++++--- main.go | 13 +++++++------ rss.go | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/html.go b/html.go index a8d4aed..ba304c5 100644 --- a/html.go +++ b/html.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "html/template" "net/http" @@ -11,7 +12,7 @@ import ( func logTemplateTime(name string, from time.Time) { now := time.Now() - ln.Log(ln.F{"action": "template_rendered", "dur": now.Sub(from).String(), "name": name}) + ln.Log(context.Background(), ln.F{"action": "template_rendered", "dur": now.Sub(from).String(), "name": name}) } func (s *Site) renderTemplatePage(templateFname string, data interface{}) http.Handler { @@ -27,11 +28,11 @@ func (s *Site) renderTemplatePage(templateFname string, data interface{}) http.H t, err = template.ParseFiles("templates/base.html", "templates/"+templateFname) if err != nil { w.WriteHeader(http.StatusInternalServerError) - ln.Error(err, ln.F{"action": "renderTemplatePage", "page": templateFname}) + ln.Error(context.Background(), err, ln.F{"action": "renderTemplatePage", "page": templateFname}) fmt.Fprintf(w, "error: %v", err) } - ln.Log(ln.F{"action": "loaded_new_template", "fname": templateFname}) + ln.Log(context.Background(), ln.F{"action": "loaded_new_template", "fname": templateFname}) s.tlock.RUnlock() s.tlock.Lock() diff --git a/main.go b/main.go index 86546b0..e0cc20d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "html/template" "io/ioutil" "net/http" @@ -15,7 +16,7 @@ import ( "github.com/Xe/jsonfeed" "github.com/Xe/ln" "github.com/gorilla/feeds" - "github.com/russross/blackfriday" + blackfriday "github.com/russross/blackfriday" "github.com/tj/front" ) @@ -28,10 +29,10 @@ func main() { s, err := Build() if err != nil { - ln.Fatal(ln.F{"err": err, "action": "Build"}) + ln.FatalErr(context.Background(), err, ln.Action("Build")) } - ln.Log(ln.F{"action": "http_listening", "port": port}) + ln.Log(context.Background(), ln.F{"action": "http_listening", "port": port}) http.ListenAndServe(":"+port, s) } @@ -50,7 +51,7 @@ type Site struct { } func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request) { - ln.Log(ln.F{"action": "Site.ServeHTTP", "user_ip_address": r.RemoteAddr, "path": r.RequestURI}) + ln.Log(r.Context(), ln.F{"action": "Site.ServeHTTP", "user_ip_address": r.RemoteAddr, "path": r.RequestURI}) s.mux.ServeHTTP(w, r) } @@ -114,7 +115,7 @@ func Build() (*Site, error) { return err } - output := blackfriday.MarkdownCommon(remaining) + output := blackfriday.Run(remaining) p := &Post{ Title: fm.Title, @@ -144,7 +145,7 @@ func Build() (*Site, error) { return nil, err } - s.Resume = template.HTML(blackfriday.MarkdownCommon(sb.MustBytes("resume/resume.md"))) + s.Resume = template.HTML(blackfriday.Run(sb.MustBytes("resume/resume.md"))) for _, item := range s.Posts { itime, _ := time.Parse("2006-01-02", item.Date) diff --git a/rss.go b/rss.go index cafcde4..15e9163 100644 --- a/rss.go +++ b/rss.go @@ -20,7 +20,7 @@ func (s *Site) createFeed(w http.ResponseWriter, r *http.Request) { err := s.rssFeed.WriteRss(w) if err != nil { http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(err, ln.F{ + ln.Error(r.Context(), err, ln.F{ "remote_addr": r.RemoteAddr, "action": "generating_rss", "uri": r.RequestURI, @@ -36,7 +36,7 @@ func (s *Site) createAtom(w http.ResponseWriter, r *http.Request) { err := s.rssFeed.WriteAtom(w) if err != nil { http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(err, ln.F{ + ln.Error(r.Context(), err, ln.F{ "remote_addr": r.RemoteAddr, "action": "generating_atom", "uri": r.RequestURI, @@ -54,7 +54,7 @@ func (s *Site) createJsonFeed(w http.ResponseWriter, r *http.Request) { err := e.Encode(s.jsonFeed) if err != nil { http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(err, ln.F{ + ln.Error(r.Context(), err, ln.F{ "remote_addr": r.RemoteAddr, "action": "generating_jsonfeed", "uri": r.RequestURI,