From 30d4a26ba07591e423f9a391d58debc990dd087c Mon Sep 17 00:00:00 2001 From: spf13 Date: Mon, 20 Oct 2014 17:51:53 -0400 Subject: [PATCH] Handlers WIP (builds) --- hugolib/handler_page.go | 5 ++++- hugolib/handlers.go | 8 ++++---- hugolib/site.go | 6 +----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hugolib/handler_page.go b/hugolib/handler_page.go index 47fa85cdd..7f96ba3c8 100644 --- a/hugolib/handler_page.go +++ b/hugolib/handler_page.go @@ -24,7 +24,7 @@ var Pager interface { var markdown = Handle{ extensions: []string{"mdown", "markdown", "md"}, - readrun: func(f *source.File, results HandleResults) { + readrun: func(f *source.File, s *Site, results HandleResults) { page, err := NewPage(f.Path()) if err != nil { results <- HandledResult{file: f, err: err} @@ -34,6 +34,9 @@ var markdown = Handle{ results <- HandledResult{file: f, err: err} } + page.Site = &s.Info + page.Tmpl = s.Tmpl + results <- HandledResult{file: f, page: page, err: err} }, } diff --git a/hugolib/handlers.go b/hugolib/handlers.go index 2aaf8cc48..f406744b8 100644 --- a/hugolib/handlers.go +++ b/hugolib/handlers.go @@ -16,7 +16,7 @@ package hugolib import "github.com/spf13/hugo/source" type Handler interface { - Read(*source.File, HandleResults) + Read(*source.File, *Site, HandleResults) //Render() //Convert() Extensions() []string @@ -30,7 +30,7 @@ type HandledResult struct { type HandleResults chan<- HandledResult -type ReadFunc func(*source.File, HandleResults) +type ReadFunc func(*source.File, *Site, HandleResults) type Handle struct { extensions []string @@ -43,8 +43,8 @@ func (h Handle) Extensions() []string { return h.extensions } -func (h Handle) Read(s *source.File, results HandleResults) { - h.readrun(s, results) +func (h Handle) Read(f *source.File, s *Site, results HandleResults) { + h.readrun(f, s, results) } func RegisterHandler(h Handler) { diff --git a/hugolib/site.go b/hugolib/site.go index 2db711543..ab464f7a1 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -402,14 +402,10 @@ func sourceReader(s *Site, files <-chan *source.File, results chan<- HandledResu for file := range files { h := FindHandler(file.Extension()) if h != nil { - h.Read(file, results) + h.Read(file, s, results) } else { jww.ERROR.Println("Unsupported File Type", file.Path()) } - - // TODO: Figure out Site stuff - //page.Site = &s.Info - //page.Tmpl = s.Tmpl } }