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.
This commit is contained in:
Noah Campbell
2013-11-05 22:28:06 +00:00
parent 1cebce12ad
commit 86233c00a0
9 changed files with 68 additions and 137 deletions

View File

@@ -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
}