hugolib: More TODO fixes
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 25 Mar 2017 17:28:38 +0000 (18:28 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 27 Mar 2017 13:43:56 +0000 (15:43 +0200)
hugolib/menu_old_test.go
hugolib/page.go
hugolib/page_output.go
hugolib/site_render.go
output/layout.go

index 6076d90628174f6ac17bd1dcc000693271bc7325..704a6f70a63973df9f9988cf267a1c6dbd37d385 100644 (file)
@@ -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) {
        t.Parallel()
        s := setupMenuTests(t, menuPageSources)
index e23f8e1e8782bc7fbb0cfa68517ce51a788bfa30..f32f1ac0bdc641a1e29f6ae4e699532d59414420 100644 (file)
@@ -119,8 +119,11 @@ type Page struct {
        contentType string
        renderable  bool
 
-       Layout            string
-       layoutsCalculated []string
+       Layout 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
 
@@ -1379,13 +1382,12 @@ func (p *Page) prepareLayouts() error {
        // TODO(bep): Check the IsRenderable logic.
        if p.Kind == KindPage {
                if !p.IsRenderable() {
-                       // TODO(bep) output
                        self := "__" + p.UniqueID()
                        _, err := p.s.Tmpl.GetClone().New(self).Parse(string(p.Content))
                        if err != nil {
                                return err
                        }
-                       p.layoutsCalculated = []string{self}
+                       p.selfLayout = self
                }
        }
        return nil
index 5e1a341fc9d1534e9f365b1a183b23301b48a3fc..20d051e8cd7b81687840b3815cd32a9f53797421 100644 (file)
@@ -48,8 +48,7 @@ func (p *PageOutput) targetPath(addends ...string) (string, error) {
 }
 
 func newPageOutput(p *Page, createCopy bool, f output.Format) (*PageOutput, error) {
-       // For tests
-       // TODO(bep) output get rid of this
+       // TODO(bep) This is only needed for tests and we should get rid of it.
        if p.targetPathDescriptorPrototype == nil {
                if err := p.initTargetPathDescriptor(); err != nil {
                        return nil, err
@@ -87,9 +86,8 @@ func (p *PageOutput) copy() *PageOutput {
 }
 
 func (p *PageOutput) layouts(layouts ...string) []string {
-       // TODO(bep) output the logic here needs to be redone.
-       if len(layouts) == 0 && len(p.layoutsCalculated) > 0 {
-               return p.layoutsCalculated
+       if len(layouts) == 0 && p.selfLayout != "" {
+               return []string{p.selfLayout}
        }
 
        layoutOverride := ""
index a63b57e4d01171b75ec3116fdefb2626ecf03f3d..be512fe48eea53799b06f4a16642d286080f70a8 100644 (file)
@@ -79,9 +79,8 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
 
                        var layouts []string
 
-                       if len(pageOutput.layoutsCalculated) > 0 {
-                               // TODO(bep) output
-                               layouts = pageOutput.layoutsCalculated
+                       if page.selfLayout != "" {
+                               layouts = []string{page.selfLayout}
                        } else {
                                layouts = s.layouts(pageOutput)
                        }
index 70bf6f7c2d7dd3f59275907c3971e3c2f81343f5..01dcba6ed4dbfea23a7cc35cd106638a01bcb305 100644 (file)
@@ -30,7 +30,6 @@ type LayoutDescriptor struct {
 }
 
 // Layout calculates the layout template to use to render a given output type.
-// TODO(bep) output improve names
 type LayoutHandler struct {
        hasTheme bool