mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Rename Transform to AbsURL
This commit is contained in:
parent
03d1a57fea
commit
f0211b84a1
3 changed files with 10 additions and 6 deletions
|
@ -64,7 +64,7 @@ type Site struct {
|
|||
Info SiteInfo
|
||||
Shortcodes map[string]ShortcodeFunc
|
||||
timer *nitro.B
|
||||
Transformer *transform.Transformer
|
||||
Transformer transform.Transformer
|
||||
Target target.Output
|
||||
Alias target.AliasPublisher
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ func (s *Site) WritePublic(path string, content io.Reader) (err error) {
|
|||
}
|
||||
|
||||
if s.Transformer == nil {
|
||||
s.Transformer = &transform.Transformer{BaseURL: s.Config.BaseUrl}
|
||||
s.Transformer = &transform.AbsURL{BaseURL: s.Config.BaseUrl}
|
||||
}
|
||||
final := new(bytes.Buffer)
|
||||
s.Transformer.Apply(content, final)
|
||||
|
|
|
@ -6,11 +6,15 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
type Transformer struct {
|
||||
type Transformer interface {
|
||||
Apply(io.Reader, io.Writer) error
|
||||
}
|
||||
|
||||
type AbsURL struct {
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
func (t *Transformer) Apply(r io.Reader, w io.Writer) (err error) {
|
||||
func (t *AbsURL) Apply(r io.Reader, w io.Writer) (err error) {
|
||||
var tr *htmltran.Transformer
|
||||
|
||||
if tr, err = htmltran.NewFromReader(r); err != nil {
|
||||
|
@ -28,7 +32,7 @@ type elattr struct {
|
|||
tag, attr string
|
||||
}
|
||||
|
||||
func (t *Transformer) absUrlify(tr *htmltran.Transformer, selectors ...elattr) (err error) {
|
||||
func (t *AbsURL) absUrlify(tr *htmltran.Transformer, selectors ...elattr) (err error) {
|
||||
var baseURL, inURL *url.URL
|
||||
|
||||
if baseURL, err = url.Parse(t.BaseURL); err != nil {
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestAbsUrlify(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
tr := &Transformer{
|
||||
tr := &AbsURL{
|
||||
BaseURL: "http://base",
|
||||
}
|
||||
out := new(bytes.Buffer)
|
||||
|
|
Loading…
Reference in a new issue