Skip to content

Commit

Permalink
Merge pull request #38 from noahcampbell/workflow_dotfile
Browse files Browse the repository at this point in the history
Workflow dotfile
  • Loading branch information
spf13 committed Aug 14, 2013
2 parents b4bcc59 + 97eb922 commit 7a51a8a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
25 changes: 25 additions & 0 deletions hugolib/content_directory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package hugolib

import (
"testing"
)

func TestIgnoreDotFiles(t *testing.T) {
tests := []struct {
path string
ignore bool
} {
{"barfoo.md", false},
{"foobar/barfoo.md", false},
{"foobar/.barfoo.md", true},
{".barfoo.md", true},
{".md", true},
{"", true},
}

for _, test := range tests {
if ignored := ignoreDotFile(test.path); test.ignore != ignored {
t.Errorf("File not ignored. Expected: %t, got: %t", test.ignore, ignored)
}
}
}
8 changes: 3 additions & 5 deletions hugolib/path_seperators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestDegenerateMissingFolderInPageFilename(t *testing.T) {
}

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


2 changes: 1 addition & 1 deletion hugolib/path_seperators_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
func TestTemplatePathSeperator(t *testing.T) {
config := Config{
LayoutDir: "c:\\a\\windows\\path\\layout",
Path: "c:\\a\\windows\\path",
Path: "c:\\a\\windows\\path",
}
s := &Site{Config: config}
if name := s.generateTemplateNameFrom("c:\\a\\windows\\path\\layout\\sub1\\index.html"); name != "sub1/index.html" {
Expand Down
13 changes: 11 additions & 2 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ func (site *Site) Render() (err error) {
site.timerStep("render shortcodes")
site.AbsUrlify()
site.timerStep("absolute URLify")
site.RenderIndexes()
if err = site.RenderIndexes(); err != nil {
return
}
site.RenderIndexesIndexes()
site.timerStep("render and write indexes")
site.RenderLists()
Expand Down Expand Up @@ -199,12 +201,15 @@ func (s *Site) initialize() {
site.Directories = append(site.Directories, path)
return nil
} else {
if ignoreDotFile(path) {
return nil
}
site.Files = append(site.Files, path)
return nil
}
}

filepath.Walk(s.Config.GetAbsPath(s.Config.ContentDir), walker)
filepath.Walk(s.absContentDir(), walker)

s.Info = SiteInfo{
BaseUrl: template.URL(s.Config.BaseUrl),
Expand All @@ -216,6 +221,10 @@ func (s *Site) initialize() {
s.Shortcodes = make(map[string]ShortcodeFunc)
}

func ignoreDotFile(path string) bool {
return filepath.Base(path)[0] == '.'
}

func (s *Site) absLayoutDir() string {
return s.Config.GetAbsPath(s.Config.LayoutDir)
}
Expand Down

0 comments on commit 7a51a8a

Please sign in to comment.