diff options
| author | Christine Dodrill <me@christine.website> | 2017-12-13 10:49:13 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2017-12-13 11:42:37 -0800 |
| commit | 9003cd5b93421e2942531464ccc07fdd129cf252 (patch) | |
| tree | 053dae2d7d94b77c1d0405234e845f268c3a9f5b | |
| parent | 3a21ef192628f6952eaa981bcdf718a35a4b43c7 (diff) | |
| download | xesite-9003cd5b93421e2942531464ccc07fdd129cf252.tar.xz xesite-9003cd5b93421e2942531464ccc07fdd129cf252.zip | |
fix build
| -rw-r--r-- | html.go | 7 | ||||
| -rw-r--r-- | main.go | 13 | ||||
| -rw-r--r-- | rss.go | 6 |
3 files changed, 14 insertions, 12 deletions
@@ -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() @@ -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) @@ -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, |
