diff options
author | bep <[email protected]> | 2015-03-19 01:55:49 +0100 |
---|---|---|
committer | bep <[email protected]> | 2015-03-19 02:07:57 +0100 |
commit | 66cf3bdc77d43f92333cd48a351d59d7a5abe1f8 (patch) | |
tree | 395f711d96b4528e4da842ff4da8f92a245bfc94 /transform | |
parent | efb564775afd319b953a386cf9e8cc1aca0b585e (diff) | |
download | hugo-66cf3bdc77d43f92333cd48a351d59d7a5abe1f8.tar.gz hugo-66cf3bdc77d43f92333cd48a351d59d7a5abe1f8.zip |
Rename interface contentRewriter to contentTransformer
Is is a much better name.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/absurl.go | 4 | ||||
-rw-r--r-- | transform/absurlreplacer.go | 14 | ||||
-rw-r--r-- | transform/chain.go | 8 | ||||
-rw-r--r-- | transform/chain_test.go | 16 | ||||
-rw-r--r-- | transform/livereloadinject.go | 10 |
5 files changed, 26 insertions, 26 deletions
diff --git a/transform/absurl.go b/transform/absurl.go index 1c721071d..0bd579b4c 100644 --- a/transform/absurl.go +++ b/transform/absurl.go @@ -18,7 +18,7 @@ func absURLFromURL(URL string) (trs []link, err error) { } func absURLFromReplacer(ar *absURLReplacer) (trs []link, err error) { - trs = append(trs, func(rw contentRewriter) { + trs = append(trs, func(rw contentTransformer) { ar.replaceInHTML(rw) }) return @@ -34,7 +34,7 @@ func absURLInXMLFromURL(URL string) (trs []link, err error) { } func absURLInXMLFromReplacer(ar *absURLReplacer) (trs []link, err error) { - trs = append(trs, func(rw contentRewriter) { + trs = append(trs, func(rw contentTransformer) { ar.replaceInXML(rw) }) return diff --git a/transform/absurlreplacer.go b/transform/absurlreplacer.go index 13a34c738..9acdfc8de 100644 --- a/transform/absurlreplacer.go +++ b/transform/absurlreplacer.go @@ -176,11 +176,11 @@ func (l *contentlexer) replace() { } } -func doReplace(rw contentRewriter, matchers []absURLMatcher) { +func doReplace(ct contentTransformer, matchers []absURLMatcher) { lexer := &contentlexer{ - content: rw.Content(), - w: rw, + content: ct.Content(), + w: ct, prefixLookup: &prefixes{pr: mainPrefixRunes}, matchers: matchers} @@ -226,10 +226,10 @@ func newAbsURLReplacer(baseURL string) *absURLReplacer { } -func (au *absURLReplacer) replaceInHTML(rw contentRewriter) { - doReplace(rw, au.htmlMatchers) +func (au *absURLReplacer) replaceInHTML(ct contentTransformer) { + doReplace(ct, au.htmlMatchers) } -func (au *absURLReplacer) replaceInXML(rw contentRewriter) { - doReplace(rw, au.xmlMatchers) +func (au *absURLReplacer) replaceInXML(ct contentTransformer) { + doReplace(ct, au.xmlMatchers) } diff --git a/transform/chain.go b/transform/chain.go index a42660245..6c41c4199 100644 --- a/transform/chain.go +++ b/transform/chain.go @@ -6,7 +6,7 @@ import ( "io" ) -type trans func(rw contentRewriter) +type trans func(rw contentTransformer) type link trans @@ -20,14 +20,14 @@ func NewEmptyTransforms() []link { return make([]link, 0, 20) } -// contentRewriter is an interface that enables rotation +// contentTransformer is an interface that enables rotation // of pooled buffers in the transformer chain. -type contentRewriter interface { +type contentTransformer interface { Content() []byte io.Writer } -// Implements contentRewriter +// Implements contentTransformer // Content is read from the from-buffer, // and rewritten to to the to-buffer. type fromToBuffer struct { diff --git a/transform/chain_test.go b/transform/chain_test.go index c69b2eb82..683ac77c1 100644 --- a/transform/chain_test.go +++ b/transform/chain_test.go @@ -56,18 +56,18 @@ func TestChainZeroTransformers(t *testing.T) { } func TestChaingMultipleTransformers(t *testing.T) { - f1 := func(rw contentRewriter) { - rw.Write(bytes.Replace(rw.Content(), []byte("f1"), []byte("f1r"), -1)) + f1 := func(ct contentTransformer) { + ct.Write(bytes.Replace(ct.Content(), []byte("f1"), []byte("f1r"), -1)) } - f2 := func(rw contentRewriter) { - rw.Write(bytes.Replace(rw.Content(), []byte("f2"), []byte("f2r"), -1)) + f2 := func(ct contentTransformer) { + ct.Write(bytes.Replace(ct.Content(), []byte("f2"), []byte("f2r"), -1)) } - f3 := func(rw contentRewriter) { - rw.Write(bytes.Replace(rw.Content(), []byte("f3"), []byte("f3r"), -1)) + f3 := func(ct contentTransformer) { + ct.Write(bytes.Replace(ct.Content(), []byte("f3"), []byte("f3r"), -1)) } - f4 := func(rw contentRewriter) { - rw.Write(bytes.Replace(rw.Content(), []byte("f4"), []byte("f4r"), -1)) + f4 := func(ct contentTransformer) { + ct.Write(bytes.Replace(ct.Content(), []byte("f4"), []byte("f4r"), -1)) } tr := NewChain(f1, f2, f3, f4) diff --git a/transform/livereloadinject.go b/transform/livereloadinject.go index 1399533fc..e5c100960 100644 --- a/transform/livereloadinject.go +++ b/transform/livereloadinject.go @@ -5,19 +5,19 @@ import ( "github.com/spf13/viper" ) -func LiveReloadInject(rw contentRewriter) { +func LiveReloadInject(ct contentTransformer) { match := []byte("</body>") port := viper.GetString("port") replace := []byte(`<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':` + port + `/livereload.js?mindelay=10"></' + 'script>')</script></body>`) - newcontent := bytes.Replace(rw.Content(), match, replace, -1) + newcontent := bytes.Replace(ct.Content(), match, replace, -1) - if len(newcontent) == len(rw.Content()) { + if len(newcontent) == len(ct.Content()) { match := []byte("</BODY>") - newcontent = bytes.Replace(rw.Content(), match, replace, -1) + newcontent = bytes.Replace(ct.Content(), match, replace, -1) } - rw.Write(newcontent) + ct.Write(newcontent) } |