Formatting cleanup

This commit is contained in:
Noah Campbell 2013-08-13 14:58:50 -07:00
parent 1b2d053216
commit d876629b46
4 changed files with 12 additions and 17 deletions

View file

@ -1,8 +1,8 @@
package hugolib package hugolib
import ( import (
"testing"
"strings" "strings"
"testing"
) )
func TestSitePossibleIndexes(t *testing.T) { func TestSitePossibleIndexes(t *testing.T) {
@ -14,5 +14,3 @@ func TestSitePossibleIndexes(t *testing.T) {
t.Fatalf("possible indexes do not match [tags categories]. Got: %s", indexes) t.Fatalf("possible indexes do not match [tags categories]. Got: %s", indexes)
} }
} }

View file

@ -23,10 +23,10 @@ func TestDegenerateMissingFolderInPageFilename(t *testing.T) {
} }
func TestNewPageWithFilePath(t *testing.T) { func TestNewPageWithFilePath(t *testing.T) {
toCheck := []struct{ toCheck := []struct {
input string input string
section string section string
layout string layout string
}{ }{
{filepath.Join("sub", "foobar.html"), "sub", "sub/single.html"}, {filepath.Join("sub", "foobar.html"), "sub", "sub/single.html"},
{filepath.Join("content", "sub", "foobar.html"), "sub", "sub/single.html"}, {filepath.Join("content", "sub", "foobar.html"), "sub", "sub/single.html"},
@ -47,5 +47,3 @@ func TestNewPageWithFilePath(t *testing.T) {
} }
} }
} }

View file

@ -7,7 +7,7 @@ import (
func TestTemplatePathSeperator(t *testing.T) { func TestTemplatePathSeperator(t *testing.T) {
config := Config{ config := Config{
LayoutDir: "c:\\a\\windows\\path\\layout", LayoutDir: "c:\\a\\windows\\path\\layout",
Path: "c:\\a\\windows\\path", Path: "c:\\a\\windows\\path",
} }
s := &Site{Config: config} s := &Site{Config: config}
if name := s.generateTemplateNameFrom("c:\\a\\windows\\path\\layout\\sub1\\index.html"); name != "sub1/index.html" { if name := s.generateTemplateNameFrom("c:\\a\\windows\\path\\layout\\sub1\\index.html"); name != "sub1/index.html" {

View file

@ -27,7 +27,6 @@ import (
//"sync" //"sync"
) )
var DefaultTimer = nitro.Initalize() var DefaultTimer = nitro.Initalize()
type Site struct { type Site struct {
@ -377,7 +376,7 @@ func (s *Site) RenderPages() error {
func (s *Site) WritePages() { func (s *Site) WritePages() {
for _, p := range s.Pages { for _, p := range s.Pages {
s.WritePublic(p.Section + "/" + p.OutFile, p.RenderedContent.Bytes()) s.WritePublic(p.Section+"/"+p.OutFile, p.RenderedContent.Bytes())
} }
} }
@ -399,7 +398,7 @@ func (s *Site) setOutFile(p *Page) {
p.OutFile = replaceExtension(strings.TrimSpace(t), p.Extension) p.OutFile = replaceExtension(strings.TrimSpace(t), p.Extension)
} else { } else {
file, _ := fileExt(strings.TrimSpace(t)) file, _ := fileExt(strings.TrimSpace(t))
p.OutFile = filepath.Join(file, "index." + p.Extension) p.OutFile = filepath.Join(file, "index."+p.Extension)
} }
} }
} }
@ -435,7 +434,7 @@ func (s *Site) RenderIndexes() error {
base = plural + "/" + k + "/" + "index" base = plural + "/" + k + "/" + "index"
} }
s.WritePublic(base + ".html", x.Bytes()) s.WritePublic(base+".html", x.Bytes())
if a := s.Tmpl.Lookup("rss.xml"); a != nil { if a := s.Tmpl.Lookup("rss.xml"); a != nil {
// XML Feed // XML Feed
@ -447,7 +446,7 @@ func (s *Site) RenderIndexes() error {
} }
n.Permalink = template.HTML(string(n.Site.BaseUrl) + n.Url) n.Permalink = template.HTML(string(n.Site.BaseUrl) + n.Url)
s.Tmpl.ExecuteTemplate(y, "rss.xml", n) s.Tmpl.ExecuteTemplate(y, "rss.xml", n)
s.WritePublic(base + ".xml", y.Bytes()) s.WritePublic(base+".xml", y.Bytes())
} }
} }
} }
@ -469,7 +468,7 @@ func (s *Site) RenderIndexesIndexes() (err error) {
n.Data["OrderedIndex"] = s.Info.Indexes[plural] n.Data["OrderedIndex"] = s.Info.Indexes[plural]
x, err := s.RenderThing(n, layout) x, err := s.RenderThing(n, layout)
s.WritePublic(plural + "/index.html", x.Bytes()) s.WritePublic(plural+"/index.html", x.Bytes())
return err return err
} }
} }
@ -491,7 +490,7 @@ func (s *Site) RenderLists() error {
if err != nil { if err != nil {
return err return err
} }
s.WritePublic(section + "/index.html", x.Bytes()) s.WritePublic(section+"/index.html", x.Bytes())
if a := s.Tmpl.Lookup("rss.xml"); a != nil { if a := s.Tmpl.Lookup("rss.xml"); a != nil {
// XML Feed // XML Feed
@ -499,7 +498,7 @@ func (s *Site) RenderLists() error {
n.Permalink = template.HTML(string(n.Site.BaseUrl) + n.Url) n.Permalink = template.HTML(string(n.Site.BaseUrl) + n.Url)
y := s.NewXMLBuffer() y := s.NewXMLBuffer()
s.Tmpl.ExecuteTemplate(y, "rss.xml", n) s.Tmpl.ExecuteTemplate(y, "rss.xml", n)
s.WritePublic(section + "/index.xml", y.Bytes()) s.WritePublic(section+"/index.xml", y.Bytes())
} }
} }
return nil return nil