mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Unexport the target handlers
These are of no interest outside the package.
This commit is contained in:
parent
27f8d8f963
commit
023992abad
6 changed files with 44 additions and 44 deletions
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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},
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue