From 023992abad74760cad50996b3c023ac50c534729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 5 Mar 2016 20:56:38 +0100 Subject: [PATCH] Unexport the target handlers These are of no interest outside the package. --- hugolib/handler_test.go | 2 +- hugolib/planner.go | 8 +++--- hugolib/shortcode_test.go | 2 +- hugolib/site.go | 50 +++++++++++++++++----------------- hugolib/site_show_plan_test.go | 14 +++++----- hugolib/site_test.go | 12 ++++---- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/hugolib/handler_test.go b/hugolib/handler_test.go index 8f206f75f..1e8f16c79 100644 --- a/hugolib/handler_test.go +++ b/hugolib/handler_test.go @@ -47,7 +47,7 @@ func TestDefaultHandler(t *testing.T) { s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: true}}, + targets: targetList{page: &target.PagePub{UglyURLs: true}}, } s.initializeSiteInfo() diff --git a/hugolib/planner.go b/hugolib/planner.go index 8dd82c0f5..41a1676f6 100644 --- a/hugolib/planner.go +++ b/hugolib/planner.go @@ -37,23 +37,23 @@ func (s *Site) ShowPlan(out io.Writer) (err error) { } fmt.Fprintf(out, "\n") fmt.Fprintf(out, " canonical => ") - if s.Targets.Page == nil { + if s.targets.page == nil { fmt.Fprintf(out, "%s\n\n", "!no target specified!") continue } - trns, err := s.PageTarget().Translate(p.TargetPath()) + trns, err := s.pageTarget().Translate(p.TargetPath()) if err != nil { return err } fmt.Fprintf(out, "%s\n", trns) - if s.Targets.Alias == nil { + if s.targets.alias == nil { continue } for _, alias := range p.Aliases { - aliasTrans, err := s.AliasTarget().Translate(alias) + aliasTrans, err := s.aliasTarget().Translate(alias) if err != nil { return err } diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index 7b4d1c810..26854562e 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -443,7 +443,7 @@ e`, s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: false}}, + targets: targetList{page: &target.PagePub{UglyURLs: false}}, } s.initializeSiteInfo() diff --git a/hugolib/site.go b/hugolib/site.go index 326f25f8c..93128bbbf 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -81,7 +81,7 @@ type Site struct { Info SiteInfo Menus Menus timer *nitro.B - Targets targetList + targets targetList targetListInit sync.Once RunMode runmode params map[string]interface{} @@ -91,10 +91,10 @@ type Site struct { } type targetList struct { - Page target.Output - PageUgly target.Output - File target.Output - Alias target.AliasPublisher + page target.Output + pageUgly target.Output + file target.Output + alias target.AliasPublisher } type SiteInfo struct { @@ -1944,9 +1944,9 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou if p, ok := d.(*Page); ok && path.Ext(p.URL) != "" { // user has explicitly set a URL with extension for this page // make sure it sticks even if "ugly URLs" are turned off. - pageTarget = s.PageUglyTarget() + pageTarget = s.pageUglyTarget() } else { - pageTarget = s.PageTarget() + pageTarget = s.pageTarget() } transformLinks := transform.NewEmptyTransforms() @@ -2040,47 +2040,47 @@ func (s *Site) NewXMLBuffer() *bytes.Buffer { return bytes.NewBufferString(header) } -func (s *Site) PageTarget() target.Output { +func (s *Site) pageTarget() target.Output { s.initTargetList() - return s.Targets.Page + return s.targets.page } -func (s *Site) PageUglyTarget() target.Output { +func (s *Site) pageUglyTarget() target.Output { s.initTargetList() - return s.Targets.PageUgly + return s.targets.pageUgly } -func (s *Site) FileTarget() target.Output { +func (s *Site) fileTarget() target.Output { s.initTargetList() - return s.Targets.File + return s.targets.file } -func (s *Site) AliasTarget() target.AliasPublisher { +func (s *Site) aliasTarget() target.AliasPublisher { s.initTargetList() - return s.Targets.Alias + return s.targets.alias } func (s *Site) initTargetList() { s.targetListInit.Do(func() { - if s.Targets.Page == nil { - s.Targets.Page = &target.PagePub{ + if s.targets.page == nil { + s.targets.page = &target.PagePub{ PublishDir: s.absPublishDir(), UglyURLs: viper.GetBool("UglyURLs"), } } - if s.Targets.PageUgly == nil { - s.Targets.PageUgly = &target.PagePub{ + if s.targets.pageUgly == nil { + s.targets.pageUgly = &target.PagePub{ PublishDir: s.absPublishDir(), UglyURLs: true, } } - if s.Targets.File == nil { - s.Targets.File = &target.Filesystem{ + if s.targets.file == nil { + s.targets.file = &target.Filesystem{ PublishDir: s.absPublishDir(), } } - if s.Targets.Alias == nil { - s.Targets.Alias = &target.HTMLRedirectAlias{ + if s.targets.alias == nil { + s.targets.alias = &target.HTMLRedirectAlias{ PublishDir: s.absPublishDir(), } } @@ -2089,7 +2089,7 @@ func (s *Site) initTargetList() { func (s *Site) WriteDestFile(path string, reader io.Reader) (err error) { jww.DEBUG.Println("creating file:", path) - return s.FileTarget().Publish(path, reader) + return s.fileTarget().Publish(path, reader) } func (s *Site) WriteDestPage(path string, target target.Output, reader io.Reader) (err error) { @@ -2099,7 +2099,7 @@ func (s *Site) WriteDestPage(path string, target target.Output, reader io.Reader func (s *Site) WriteDestAlias(path string, permalink string) (err error) { jww.DEBUG.Println("creating alias:", path) - return s.AliasTarget().Publish(path, permalink) + return s.aliasTarget().Publish(path, permalink) } func (s *Site) draftStats() string { diff --git a/hugolib/site_show_plan_test.go b/hugolib/site_show_plan_test.go index 74b49082f..91b0e2a1a 100644 --- a/hugolib/site_show_plan_test.go +++ b/hugolib/site_show_plan_test.go @@ -97,8 +97,8 @@ func TestFileTarget(t *testing.T) { s := &Site{ Source: &source.InMemorySource{ByteSource: fakeSource}, } - s.AliasTarget() - s.PageTarget() + s.aliasTarget() + s.pageTarget() must(s.CreatePages()) expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file/index.html\n\n" + "alias/test/file1.md (renderer: markdown)\n" + @@ -117,10 +117,10 @@ func TestPageTargetUgly(t *testing.T) { viper.Set("UglyURLs", true) s := &Site{ - Targets: targetList{Page: &target.PagePub{UglyURLs: true}}, + targets: targetList{page: &target.PagePub{UglyURLs: true}}, Source: &source.InMemorySource{ByteSource: fakeSource}, } - s.AliasTarget() + s.aliasTarget() s.CreatePages() expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file.html\n\n" + @@ -139,9 +139,9 @@ func TestFileTargetPublishDir(t *testing.T) { s := &Site{ - Targets: targetList{ - Page: &target.PagePub{PublishDir: "../public"}, - Alias: &target.HTMLRedirectAlias{PublishDir: "../public"}, + targets: targetList{ + page: &target.PagePub{PublishDir: "../public"}, + alias: &target.HTMLRedirectAlias{PublishDir: "../public"}, }, Source: &source.InMemorySource{ByteSource: fakeSource}, } diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 66b58aa33..f7e92cd30 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -78,7 +78,7 @@ func TestReadPagesFromSourceWithEmptySource(t *testing.T) { s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: true}}, + targets: targetList{page: &target.PagePub{UglyURLs: true}}, } var err error @@ -383,7 +383,7 @@ THE END.`, refShortcode))}, s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}}, + targets: targetList{page: &target.PagePub{UglyURLs: uglyURLs}}, } s.initializeSiteInfo() @@ -450,7 +450,7 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) { s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}}, + targets: targetList{page: &target.PagePub{UglyURLs: uglyURLs}}, } s.initializeSiteInfo() @@ -545,7 +545,7 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) { s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: uglify}}, + targets: targetList{page: &target.PagePub{UglyURLs: uglify}}, } s.initializeSiteInfo() @@ -610,7 +610,7 @@ func TestSkipRender(t *testing.T) { viper.Set("baseurl", "http://auth/bub") s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: true}}, + targets: targetList{page: &target.PagePub{UglyURLs: true}}, } s.initializeSiteInfo() @@ -666,7 +666,7 @@ func TestAbsURLify(t *testing.T) { viper.Set("BaseURL", "http://auth/bub") s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, - Targets: targetList{Page: &target.PagePub{UglyURLs: true}}, + targets: targetList{page: &target.PagePub{UglyURLs: true}}, } t.Logf("Rendering with BaseURL %q and CanonifyURLs set %v", viper.GetString("baseURL"), canonify) s.initializeSiteInfo()