fix build

This commit is contained in:
Cadey Ratio 2017-12-13 10:49:13 -08:00
parent 3a21ef1926
commit 9003cd5b93
3 changed files with 14 additions and 12 deletions

View File

@ -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()

13
main.go
View File

@ -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)

6
rss.go
View File

@ -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,