Handlers WIP (builds)

This commit is contained in:
spf13 2014-10-20 17:51:53 -04:00
parent 93f3d604c6
commit 30d4a26ba0
3 changed files with 9 additions and 10 deletions

View file

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

View file

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

View file

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