mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 01:53:34 -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{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
|
@ -37,23 +37,23 @@ func (s *Site) ShowPlan(out io.Writer) (err error) {
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "\n")
|
fmt.Fprintf(out, "\n")
|
||||||
fmt.Fprintf(out, " canonical => ")
|
fmt.Fprintf(out, " canonical => ")
|
||||||
if s.Targets.Page == nil {
|
if s.targets.page == nil {
|
||||||
fmt.Fprintf(out, "%s\n\n", "!no target specified!")
|
fmt.Fprintf(out, "%s\n\n", "!no target specified!")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
trns, err := s.PageTarget().Translate(p.TargetPath())
|
trns, err := s.pageTarget().Translate(p.TargetPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "%s\n", trns)
|
fmt.Fprintf(out, "%s\n", trns)
|
||||||
|
|
||||||
if s.Targets.Alias == nil {
|
if s.targets.alias == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, alias := range p.Aliases {
|
for _, alias := range p.Aliases {
|
||||||
aliasTrans, err := s.AliasTarget().Translate(alias)
|
aliasTrans, err := s.aliasTarget().Translate(alias)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,7 @@ e`,
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: false}},
|
targets: targetList{page: &target.PagePub{UglyURLs: false}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
|
@ -81,7 +81,7 @@ type Site struct {
|
||||||
Info SiteInfo
|
Info SiteInfo
|
||||||
Menus Menus
|
Menus Menus
|
||||||
timer *nitro.B
|
timer *nitro.B
|
||||||
Targets targetList
|
targets targetList
|
||||||
targetListInit sync.Once
|
targetListInit sync.Once
|
||||||
RunMode runmode
|
RunMode runmode
|
||||||
params map[string]interface{}
|
params map[string]interface{}
|
||||||
|
@ -91,10 +91,10 @@ type Site struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type targetList struct {
|
type targetList struct {
|
||||||
Page target.Output
|
page target.Output
|
||||||
PageUgly target.Output
|
pageUgly target.Output
|
||||||
File target.Output
|
file target.Output
|
||||||
Alias target.AliasPublisher
|
alias target.AliasPublisher
|
||||||
}
|
}
|
||||||
|
|
||||||
type SiteInfo struct {
|
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) != "" {
|
if p, ok := d.(*Page); ok && path.Ext(p.URL) != "" {
|
||||||
// user has explicitly set a URL with extension for this page
|
// user has explicitly set a URL with extension for this page
|
||||||
// make sure it sticks even if "ugly URLs" are turned off.
|
// make sure it sticks even if "ugly URLs" are turned off.
|
||||||
pageTarget = s.PageUglyTarget()
|
pageTarget = s.pageUglyTarget()
|
||||||
} else {
|
} else {
|
||||||
pageTarget = s.PageTarget()
|
pageTarget = s.pageTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
transformLinks := transform.NewEmptyTransforms()
|
transformLinks := transform.NewEmptyTransforms()
|
||||||
|
@ -2040,47 +2040,47 @@ func (s *Site) NewXMLBuffer() *bytes.Buffer {
|
||||||
return bytes.NewBufferString(header)
|
return bytes.NewBufferString(header)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) PageTarget() target.Output {
|
func (s *Site) pageTarget() target.Output {
|
||||||
s.initTargetList()
|
s.initTargetList()
|
||||||
return s.Targets.Page
|
return s.targets.page
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) PageUglyTarget() target.Output {
|
func (s *Site) pageUglyTarget() target.Output {
|
||||||
s.initTargetList()
|
s.initTargetList()
|
||||||
return s.Targets.PageUgly
|
return s.targets.pageUgly
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) FileTarget() target.Output {
|
func (s *Site) fileTarget() target.Output {
|
||||||
s.initTargetList()
|
s.initTargetList()
|
||||||
return s.Targets.File
|
return s.targets.file
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) AliasTarget() target.AliasPublisher {
|
func (s *Site) aliasTarget() target.AliasPublisher {
|
||||||
s.initTargetList()
|
s.initTargetList()
|
||||||
return s.Targets.Alias
|
return s.targets.alias
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) initTargetList() {
|
func (s *Site) initTargetList() {
|
||||||
s.targetListInit.Do(func() {
|
s.targetListInit.Do(func() {
|
||||||
if s.Targets.Page == nil {
|
if s.targets.page == nil {
|
||||||
s.Targets.Page = &target.PagePub{
|
s.targets.page = &target.PagePub{
|
||||||
PublishDir: s.absPublishDir(),
|
PublishDir: s.absPublishDir(),
|
||||||
UglyURLs: viper.GetBool("UglyURLs"),
|
UglyURLs: viper.GetBool("UglyURLs"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.Targets.PageUgly == nil {
|
if s.targets.pageUgly == nil {
|
||||||
s.Targets.PageUgly = &target.PagePub{
|
s.targets.pageUgly = &target.PagePub{
|
||||||
PublishDir: s.absPublishDir(),
|
PublishDir: s.absPublishDir(),
|
||||||
UglyURLs: true,
|
UglyURLs: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.Targets.File == nil {
|
if s.targets.file == nil {
|
||||||
s.Targets.File = &target.Filesystem{
|
s.targets.file = &target.Filesystem{
|
||||||
PublishDir: s.absPublishDir(),
|
PublishDir: s.absPublishDir(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.Targets.Alias == nil {
|
if s.targets.alias == nil {
|
||||||
s.Targets.Alias = &target.HTMLRedirectAlias{
|
s.targets.alias = &target.HTMLRedirectAlias{
|
||||||
PublishDir: s.absPublishDir(),
|
PublishDir: s.absPublishDir(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2089,7 +2089,7 @@ func (s *Site) initTargetList() {
|
||||||
|
|
||||||
func (s *Site) WriteDestFile(path string, reader io.Reader) (err error) {
|
func (s *Site) WriteDestFile(path string, reader io.Reader) (err error) {
|
||||||
jww.DEBUG.Println("creating file:", path)
|
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) {
|
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) {
|
func (s *Site) WriteDestAlias(path string, permalink string) (err error) {
|
||||||
jww.DEBUG.Println("creating alias:", path)
|
jww.DEBUG.Println("creating alias:", path)
|
||||||
return s.AliasTarget().Publish(path, permalink)
|
return s.aliasTarget().Publish(path, permalink)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) draftStats() string {
|
func (s *Site) draftStats() string {
|
||||||
|
|
|
@ -97,8 +97,8 @@ func TestFileTarget(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
}
|
}
|
||||||
s.AliasTarget()
|
s.aliasTarget()
|
||||||
s.PageTarget()
|
s.pageTarget()
|
||||||
must(s.CreatePages())
|
must(s.CreatePages())
|
||||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file/index.html\n\n" +
|
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file/index.html\n\n" +
|
||||||
"alias/test/file1.md (renderer: markdown)\n" +
|
"alias/test/file1.md (renderer: markdown)\n" +
|
||||||
|
@ -117,10 +117,10 @@ func TestPageTargetUgly(t *testing.T) {
|
||||||
viper.Set("UglyURLs", true)
|
viper.Set("UglyURLs", true)
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
}
|
}
|
||||||
s.AliasTarget()
|
s.aliasTarget()
|
||||||
|
|
||||||
s.CreatePages()
|
s.CreatePages()
|
||||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file.html\n\n" +
|
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{
|
s := &Site{
|
||||||
|
|
||||||
Targets: targetList{
|
targets: targetList{
|
||||||
Page: &target.PagePub{PublishDir: "../public"},
|
page: &target.PagePub{PublishDir: "../public"},
|
||||||
Alias: &target.HTMLRedirectAlias{PublishDir: "../public"},
|
alias: &target.HTMLRedirectAlias{PublishDir: "../public"},
|
||||||
},
|
},
|
||||||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -383,7 +383,7 @@ THE END.`, refShortcode))},
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}},
|
targets: targetList{page: &target.PagePub{UglyURLs: uglyURLs}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -450,7 +450,7 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: uglyURLs}},
|
targets: targetList{page: &target.PagePub{UglyURLs: uglyURLs}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -545,7 +545,7 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: uglify}},
|
targets: targetList{page: &target.PagePub{UglyURLs: uglify}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -610,7 +610,7 @@ func TestSkipRender(t *testing.T) {
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseurl", "http://auth/bub")
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
Targets: targetList{Page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -666,7 +666,7 @@ func TestAbsURLify(t *testing.T) {
|
||||||
viper.Set("BaseURL", "http://auth/bub")
|
viper.Set("BaseURL", "http://auth/bub")
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
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)
|
t.Logf("Rendering with BaseURL %q and CanonifyURLs set %v", viper.GetString("baseURL"), canonify)
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
Loading…
Reference in a new issue