mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 02:43:32 -05:00
hugolib: More TODO fixes
This commit is contained in:
parent
3cd97951f1
commit
b7ed67d425
5 changed files with 11 additions and 62 deletions
|
@ -452,55 +452,6 @@ func doTestSectionPagesMenu(canonifyURLs bool, t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bep) output fix or remove
|
|
||||||
func _TestTaxonomyNodeMenu(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
type taxRenderInfo struct {
|
|
||||||
key string
|
|
||||||
singular string
|
|
||||||
plural string
|
|
||||||
}
|
|
||||||
|
|
||||||
s := setupMenuTests(t, menuPageSources, "canonifyURLs", true)
|
|
||||||
|
|
||||||
for i, this := range []struct {
|
|
||||||
menu string
|
|
||||||
taxInfo taxRenderInfo
|
|
||||||
menuItem *MenuEntry
|
|
||||||
isMenuCurrent bool
|
|
||||||
hasMenuCurrent bool
|
|
||||||
}{
|
|
||||||
{"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"},
|
|
||||||
findTestMenuEntryByID(s, "tax", "1"), true, false},
|
|
||||||
{"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"},
|
|
||||||
findTestMenuEntryByID(s, "tax", "2"), true, false},
|
|
||||||
{"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"},
|
|
||||||
&MenuEntry{Name: "Somewhere else", URL: "/somewhereelse"}, false, false},
|
|
||||||
} {
|
|
||||||
|
|
||||||
p := s.newTaxonomyPage(this.taxInfo.plural, this.taxInfo.key)
|
|
||||||
|
|
||||||
isMenuCurrent := p.IsMenuCurrent(this.menu, this.menuItem)
|
|
||||||
hasMenuCurrent := p.HasMenuCurrent(this.menu, this.menuItem)
|
|
||||||
|
|
||||||
if isMenuCurrent != this.isMenuCurrent {
|
|
||||||
t.Errorf("[%d] Wrong result from IsMenuCurrent: %v", i, isMenuCurrent)
|
|
||||||
}
|
|
||||||
|
|
||||||
if hasMenuCurrent != this.hasMenuCurrent {
|
|
||||||
t.Errorf("[%d] Wrong result for menuItem %v for HasMenuCurrent: %v", i, this.menuItem, hasMenuCurrent)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
menuEntryXML := findTestMenuEntryByID(s, "tax", "xml")
|
|
||||||
|
|
||||||
if strings.HasSuffix(menuEntryXML.URL, "/") {
|
|
||||||
t.Error("RSS menu item should not be padded with trailing slash")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMenuLimit(t *testing.T) {
|
func TestMenuLimit(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
s := setupMenuTests(t, menuPageSources)
|
s := setupMenuTests(t, menuPageSources)
|
||||||
|
|
|
@ -120,7 +120,10 @@ type Page struct {
|
||||||
renderable bool
|
renderable bool
|
||||||
|
|
||||||
Layout string
|
Layout string
|
||||||
layoutsCalculated []string
|
|
||||||
|
// For npn-renderable pages (see IsRenderable), the content itself
|
||||||
|
// is used as template and the template name is stored here.
|
||||||
|
selfLayout string
|
||||||
|
|
||||||
linkTitle string
|
linkTitle string
|
||||||
|
|
||||||
|
@ -1379,13 +1382,12 @@ func (p *Page) prepareLayouts() error {
|
||||||
// TODO(bep): Check the IsRenderable logic.
|
// TODO(bep): Check the IsRenderable logic.
|
||||||
if p.Kind == KindPage {
|
if p.Kind == KindPage {
|
||||||
if !p.IsRenderable() {
|
if !p.IsRenderable() {
|
||||||
// TODO(bep) output
|
|
||||||
self := "__" + p.UniqueID()
|
self := "__" + p.UniqueID()
|
||||||
_, err := p.s.Tmpl.GetClone().New(self).Parse(string(p.Content))
|
_, err := p.s.Tmpl.GetClone().New(self).Parse(string(p.Content))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.layoutsCalculated = []string{self}
|
p.selfLayout = self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -48,8 +48,7 @@ func (p *PageOutput) targetPath(addends ...string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPageOutput(p *Page, createCopy bool, f output.Format) (*PageOutput, error) {
|
func newPageOutput(p *Page, createCopy bool, f output.Format) (*PageOutput, error) {
|
||||||
// For tests
|
// TODO(bep) This is only needed for tests and we should get rid of it.
|
||||||
// TODO(bep) output get rid of this
|
|
||||||
if p.targetPathDescriptorPrototype == nil {
|
if p.targetPathDescriptorPrototype == nil {
|
||||||
if err := p.initTargetPathDescriptor(); err != nil {
|
if err := p.initTargetPathDescriptor(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -87,9 +86,8 @@ func (p *PageOutput) copy() *PageOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PageOutput) layouts(layouts ...string) []string {
|
func (p *PageOutput) layouts(layouts ...string) []string {
|
||||||
// TODO(bep) output the logic here needs to be redone.
|
if len(layouts) == 0 && p.selfLayout != "" {
|
||||||
if len(layouts) == 0 && len(p.layoutsCalculated) > 0 {
|
return []string{p.selfLayout}
|
||||||
return p.layoutsCalculated
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutOverride := ""
|
layoutOverride := ""
|
||||||
|
|
|
@ -79,9 +79,8 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
||||||
|
|
||||||
var layouts []string
|
var layouts []string
|
||||||
|
|
||||||
if len(pageOutput.layoutsCalculated) > 0 {
|
if page.selfLayout != "" {
|
||||||
// TODO(bep) output
|
layouts = []string{page.selfLayout}
|
||||||
layouts = pageOutput.layoutsCalculated
|
|
||||||
} else {
|
} else {
|
||||||
layouts = s.layouts(pageOutput)
|
layouts = s.layouts(pageOutput)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ type LayoutDescriptor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout calculates the layout template to use to render a given output type.
|
// Layout calculates the layout template to use to render a given output type.
|
||||||
// TODO(bep) output improve names
|
|
||||||
type LayoutHandler struct {
|
type LayoutHandler struct {
|
||||||
hasTheme bool
|
hasTheme bool
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue