From 13d2c552060a2e0339e1ac7c6a523f8837d77e09 Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Sat, 31 Aug 2013 21:13:04 -0700 Subject: [PATCH] Adding Planner --- hugolib/planner.go | 9 +++++++++ hugolib/site.go | 24 ++++++++++++++++++++---- hugolib/site_show_plan_test.go | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 hugolib/planner.go create mode 100644 hugolib/site_show_plan_test.go diff --git a/hugolib/planner.go b/hugolib/planner.go new file mode 100644 index 000000000..5b1d42327 --- /dev/null +++ b/hugolib/planner.go @@ -0,0 +1,9 @@ +package hugolib + +import ( + "io" +) + +func (s *Site) ShowPlan(out io.Writer) (err error) { + return +} diff --git a/hugolib/site.go b/hugolib/site.go index 5bbfc45cd..4fae4ebbd 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -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 } diff --git a/hugolib/site_show_plan_test.go b/hugolib/site_show_plan_test.go new file mode 100644 index 000000000..de9d7363e --- /dev/null +++ b/hugolib/site_show_plan_test.go @@ -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) + } +}