diff options
author | Noah Campbell <[email protected]> | 2013-11-05 22:28:06 +0000 |
---|---|---|
committer | Noah Campbell <[email protected]> | 2013-11-05 22:28:06 +0000 |
commit | 86233c00a0a04e8f0130a5970de8d40e6738ef74 (patch) | |
tree | 772e16697927e7bc564e640f6524781699437f02 /hugolib | |
parent | 1cebce12ad2335e1140646763dd56009c57d6495 (diff) | |
download | hugo-86233c00a0a04e8f0130a5970de8d40e6738ef74.tar.gz hugo-86233c00a0a04e8f0130a5970de8d40e6738ef74.zip |
Remove the hugo-nav function
Remove the hugo-nav since it relied on a slow library. The current
build reimplements the absurl functionality based on string replace.
Discovered that my prior implementation missed the requirement for
making absolute paths (/path) absolute with the host, whereas a relative
path is left untouched. Updated the test cases to support this if this
is reimplemented.
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/site.go | 10 | ||||
-rw-r--r-- | hugolib/site_test.go | 30 | ||||
-rw-r--r-- | hugolib/site_url_test.go | 2 |
3 files changed, 19 insertions, 23 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index fbebed94c..5e22fd969 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -576,19 +576,11 @@ func (s *Site) render(d interface{}, out string, layouts ...string) (err error) return } - - section := "" - if page, ok := d.(*Page); ok { - section, _ = page.RelPermalink() - } - absURL, err := transform.AbsURL(s.Config.BaseUrl) if err != nil { return } - transformer := transform.NewChain( - append(absURL, transform.NavActive(section, "hugo-nav")...)..., - ) + transformer := transform.NewChain(absURL...) var renderBuffer *bytes.Buffer diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 3a47b7ff7..2ef184415 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -23,7 +23,8 @@ content` TEMPLATE_CONTENT = "{{ .Content }}" TEMPLATE_DATE = "{{ .Date }}" INVALID_TEMPLATE_FORMAT_DATE = "{{ .Date.Format time.RFC3339 }}" - TEMPLATE_WITH_URL = "<a href=\"foobar.jpg\">Going</a>" + TEMPLATE_WITH_URL_REL = "<a href=\"foobar.jpg\">Going</a>" + TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>" PAGE_URL_SPECIFIED = `--- title: simple template url: "mycategory/my-whatever-content/" @@ -128,7 +129,7 @@ func TestRenderThing(t *testing.T) { } func HTML(in string) string { - return fmt.Sprintf("<html><head></head><body>%s</body></html>", in) + return in } func TestRenderThingOrDefault(t *testing.T) { @@ -224,12 +225,13 @@ func TestSkipRender(t *testing.T) { {"sect/doc3.md", []byte("# doc3\n*some* content"), "sect"}, {"sect/doc4.md", []byte("---\ntitle: doc4\n---\n# doc4\n*some content*"), "sect"}, {"sect/doc5.html", []byte("<!doctype html><html>{{ template \"head\" }}<body>body5</body></html>"), "sect"}, + {"sect/doc6.html", []byte("<!doctype html><html>{{ template \"head_abs\" }}<body>body5</body></html>"), "sect"}, {"doc7.html", []byte("<html><body>doc7 content</body></html>"), ""}, } s := &Site{ Target: target, - Config: Config{Verbose: true, BaseUrl: "http://auth/bub/"}, + Config: Config{Verbose: true, BaseUrl: "http://auth/bub"}, Source: &source.InMemorySource{sources}, } s.initializeSiteInfo() @@ -237,6 +239,7 @@ func TestSkipRender(t *testing.T) { must(s.addTemplate("_default/single.html", "{{.Content}}")) must(s.addTemplate("head", "<head><script src=\"script.js\"></script></head>")) + must(s.addTemplate("head_abs", "<head><script src=\"/script.js\"></script></head>")) if err := s.CreatePages(); err != nil { t.Fatalf("Unable to create pages: %s", err) @@ -254,12 +257,13 @@ func TestSkipRender(t *testing.T) { doc string expected string }{ - {"sect/doc1.html", "<html><head></head><body><h1>title</h1>\n\n<p>some <em>content</em></p>\n</body></html>"}, - {"sect/doc2.html", "<!DOCTYPE html><html><head></head><body>more content</body></html>"}, - {"sect/doc3.html", "<html><head></head><body><h1>doc3</h1>\n\n<p><em>some</em> content</p>\n</body></html>"}, - {"sect/doc4.html", "<html><head></head><body><h1>doc4</h1>\n\n<p><em>some content</em></p>\n</body></html>"}, - {"sect/doc5.html", "<!DOCTYPE html><html><head><script src=\"http://auth/bub/script.js\"></script></head><body>body5</body></html>"}, - {"doc7.html", "<html><head></head><body>doc7 content</body></html>"}, + {"sect/doc1.html", "<h1>title</h1>\n\n<p>some <em>content</em></p>\n"}, + {"sect/doc2.html", "<!doctype html><html><body>more content</body></html>"}, + {"sect/doc3.html", "<h1>doc3</h1>\n\n<p><em>some</em> content</p>\n"}, + {"sect/doc4.html", "<h1>doc4</h1>\n\n<p><em>some content</em></p>\n"}, + {"sect/doc5.html", "<!doctype html><html><head><script src=\"script.js\"></script></head><body>body5</body></html>"}, + {"sect/doc6.html", "<!doctype html><html><head><script src=\"http://auth/bub/script.js\"></script></head><body>body5</body></html>"}, + {"doc7.html", "<html><body>doc7 content</body></html>"}, } for _, test := range tests { @@ -283,12 +287,12 @@ func TestAbsUrlify(t *testing.T) { } s := &Site{ Target: target, - Config: Config{BaseUrl: "http://auth/bub/"}, + Config: Config{BaseUrl: "http://auth/bub"}, Source: &source.InMemorySource{sources}, } s.initializeSiteInfo() s.prepTemplates() - must(s.addTemplate("blue/single.html", TEMPLATE_WITH_URL)) + must(s.addTemplate("blue/single.html", TEMPLATE_WITH_URL_ABS)) if err := s.CreatePages(); err != nil { t.Fatalf("Unable to create pages: %s", err) @@ -305,8 +309,8 @@ func TestAbsUrlify(t *testing.T) { tests := []struct { file, expected string }{ - {"content/blue/doc2.html", "<html><head></head><body><a href=\"http://auth/bub/foobar.jpg\">Going</a></body></html>"}, - {"sect/doc1.html", "<!DOCTYPE html><html><head></head><body><a href=\"#frag1\">link</a></body></html>"}, + {"content/blue/doc2.html", "<a href=\"http://auth/bub/foobar.jpg\">Going</a>"}, + {"sect/doc1.html", "<!doctype html><html><head></head><body><a href=\"#frag1\">link</a></body></html>"}, } for _, test := range tests { diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 27be0721f..9d41c2046 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -81,7 +81,7 @@ func TestPageCount(t *testing.T) { t.Errorf("No indexed rendered. %v", target.Files) } - expected := "<html><head></head><body>..</body></html>" + expected := ".." if string(blueIndex) != expected { t.Errorf("Index template does not match expected: %q, got: %q", expected, string(blueIndex)) } |