Adding Planner

This commit is contained in:
Noah Campbell 2013-08-31 21:13:04 -07:00
parent 79d9f82e79
commit 13d2c55206
3 changed files with 43 additions and 4 deletions

9
hugolib/planner.go Normal file
View file

@ -0,0 +1,9 @@
package hugolib
import (
"io"
)
func (s *Site) ShowPlan(out io.Writer) (err error) {
return
}

View file

@ -47,6 +47,23 @@ func PrintErr(str string, a ...interface{}) {
fmt.Fprintln(os.Stderr, str, a)
}
// Site contains all the information relevent for constructing a static
// site. The basic flow of information is as follows:
//
// 1. A list of Files is parsed and then converted into Pages.
//
// 2. Pages contain sections (based on the file they were generated from),
// aliases and slugs (included in a pages frontmatter) which are the
// various targets that will get generated. There will be canonical
// listing.
//
// 3. Indexes are created via configuration and will present some aspect of
// the final page and typically a perm url.
//
// 4. All Pages are passed through a template based on their desired
// layout based on numerous different elements.
//
// 5. The entire collection of files is written to disk.
type Site struct {
Config Config
Pages Pages
@ -85,10 +102,9 @@ func (s *Site) Build() (err error) {
return
}
if err = s.Render(); err != nil {
fmt.Printf("Error rendering site: %s\n", err)
fmt.Printf("Available templates:")
for _, tpl := range s.Tmpl.Templates() {
fmt.Printf("\t%s\n", tpl.Name())
fmt.Printf("Error rendering site: %s\nAvailable templates:\n", err)
for _, template := range s.Tmpl.Templates() {
fmt.Printf("\t%s\n", template.Name())
}
return
}

View file

@ -0,0 +1,14 @@
package hugolib
import (
"bytes"
"testing"
)
func TestDegenerateNoTarget(t *testing.T) {
s := new(Site)
out := new(bytes.Buffer)
if err := s.ShowPlan(out); err != nil {
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
}
}