Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-11-06 02:28:06 +0400
committerNoah Campbell <noahcampbell@gmail.com>2013-11-06 02:28:06 +0400
commit86233c00a0a04e8f0130a5970de8d40e6738ef74 (patch)
tree772e16697927e7bc564e640f6524781699437f02 /transform/chain.go
parent1cebce12ad2335e1140646763dd56009c57d6495 (diff)
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 'transform/chain.go')
-rw-r--r--transform/chain.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/transform/chain.go b/transform/chain.go
index a4929b70d..fb3c2985c 100644
--- a/transform/chain.go
+++ b/transform/chain.go
@@ -1,25 +1,30 @@
package transform
import (
- htmltran "code.google.com/p/go-html-transform/html/transform"
+ "bytes"
"io"
)
-type chain []*htmltran.Transform
+type trans func([]byte) []byte
-func NewChain(trs ...*htmltran.Transform) chain {
+type link trans
+
+type chain []link
+
+func NewChain(trs ...link) chain {
return trs
}
func (c *chain) Apply(w io.Writer, r io.Reader) (err error) {
- var tr *htmltran.Transformer
-
- if tr, err = htmltran.NewFromReader(r); err != nil {
- return
+ buffer := new(bytes.Buffer)
+ buffer.ReadFrom(r)
+ b := buffer.Bytes()
+ for _, tr := range *c {
+ b = tr(b)
}
-
- tr.ApplyAll(*c...)
-
- return tr.Render(w)
+ buffer.Reset()
+ buffer.Write(b)
+ buffer.WriteTo(w)
+ return
}