Coder Social home page Coder Social logo

Comments (6)

arjanvaneersel avatar arjanvaneersel commented on April 29, 2024

The issue I'm having with Ponzu in the other thread has to do with exactly the same code.I went back to the recording of the gopher academy training on Ponzu to do the exercise again to get the hang of Ponzu. However the updates to channel.go now result in a panic error as soon as I try to create a new channel via admin. Am i doing something wrong or is this connected to this bug?

package content

import ( 
"fmt"

"github.com/ponzu-cms/ponzu/management/editor" 
"github.com/ponzu-cms/ponzu/system/item" 
"github.com/arjanvaneersel/gotv/addons/github.com/bosssauce/reference" 
)

type Channel struct { 
item.Item

Title string `json:"title"` 
Videos []string `json:"videos"` 
Rating string `json:"rating"` 
Tags []string `json:"tags"` 
}

// MarshalEditor writes a buffer of html to edit a Channel within the CMS 
// and implements editor.Editable 
func (c *Channel) MarshalEditor() ([]byte, error) { 
view, err := editor.Form(c, 
// Take note that the first argument to these Input-like functions 
// is the string version of each Channel field, and must follow 
// this pattern for auto-decoding and auto-encoding reasons: 
editor.Field{ 
View: editor.Input("Title", c, map[string]string{ 
"label": "Title", 
"type": "text", 
"placeholder": "Enter the Title here", 
}), 
}, 
editor.Field{ 
View: reference.SelectRepeater("Videos", c, map[string]string{ 
"label": "Videos", 
}, "Video", `{{.title}} ({{.rating}})`), 
}, 
editor.Field{ 
View: editor.Select("Rating", c, map[string]string{ 
"label": "Rating", 
}, map[string]string{ 
"G": "G", 
"PG": "PG", 
"PG-13": "PG-13", 
"R": "R", 
}), 
}, 
editor.Field{ 
View: editor.Tags("Tags", c, map[string]string{ 
"label": "Tags", 
}), 
}, 
)

if err != nil { 
return nil, fmt.Errorf("Failed to render Channel editor view: %s", err.Error()) 
}

return view, nil 
}

func init() { 
item.Types["Channel"] = func() interface{} { return new(Channel) } 
}

The error I get:
2017/02/19 09:09:07 http: panic serving [::1]:39134: interface conversion: interface {} is nil, not string
goroutine 36 [running]:
net/http.(*conn).serve.func1(0xc4201583c0)
/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0x895a00, 0xc42013da40)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/ponzu-cms/ponzu/system/addon.ContentAll(0x90f229, 0x5, 0xc420017650, 0x0, 0xc420017650)
/home/arjan/Development/Go/src/github.com/ponzu-cms/ponzu/system/addon/api.go:21 +0x3d2
github.com/arjanvaneersel/gotv/addons/github.com/bosssauce/reference.encodeDataToOptions(0x90f229, 0x5, 0x91bd00, 0x18, 0xc420104980, 0x1, 0x1)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/addons/github.com/bosssauce/reference/reference.go:122 +0xac
github.com/arjanvaneersel/gotv/addons/github.com/bosssauce/reference.SelectRepeater(0x90fee4, 0x6, 0x8f7d40, 0xc420151050, 0xc4200175f0, 0x90f229, 0x5, 0x91bd00, 0x18, 0x7f2df8309440, ...)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/addons/github.com/bosssauce/reference/reference.go:57 +0x384
github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content.(*Channel).MarshalEditor(0xc420151050, 0xc420104940, 0xe200000000000000, 0x8, 0xe20fd6032780c56a, 0x0)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/channel.go:37 +0x280
github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/management/manager.Manage(0xb38580, 0xc420151050, 0xc420117e75, 0x7, 0xc420151050, 0x1, 0x0, 0x0, 0x0)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/management/manager/manager.go:122 +0x4c
github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/system/admin.editHandler(0xb3ea80, 0xc4219b4460, 0xc420188000)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/system/admin/handlers.go:1490 +0x27f0
net/http.HandlerFunc.ServeHTTP(0x935828, 0xb3ea80, 0xc4219b4460, 0xc420188000)
/usr/local/go/src/net/http/server.go:1942 +0x44
github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/system/admin/user.Auth.func1(0xb3ea80, 0xc4219b4460, 0xc420188000)
/home/arjan/Development/Go/src/github.com/arjanvaneersel/gotv/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/system/admin/user/auth.go:55 +0xda
net/http.HandlerFunc.ServeHTTP(0xc4201040b0, 0xb3ea80, 0xc4219b4460, 0xc420188000)
/usr/local/go/src/net/http/server.go:1942 +0x44
net/http.(*ServeMux).ServeHTTP(0xb803a0, 0xb3ea80, 0xc4219b4460, 0xc420188000)
/usr/local/go/src/net/http/server.go:2238 +0x130
net/http.serverHandler.ServeHTTP(0xc420090b00, 0xb3ea80, 0xc4219b4460, 0xc420188000)
/usr/local/go/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc4201583c0, 0xb3f380, 0xc420100480)
/usr/local/go/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2668 +0x2ce

from ponzu.

nilslice avatar nilslice commented on April 29, 2024

Hi @arjanvaneersel -

However the updates to channel.go now result in a panic error as soon as I try to create a new channel via admin.

Which updates do you mean?

from ponzu.

arjanvaneersel avatar arjanvaneersel commented on April 29, 2024

I obviously haven't been clear. I'm doing the exercise as shown in the recording of the gopher academy training on Ponzu again. After the creation of alle the content types the go files are being changed in the training, so I follow along. The moment when I "update" the editor.Field for Videos, which was just a normal input type, to reference.SelectRepeater and build and run Ponzu again, then I get this error when going into Ponzu's editor for this content type.

from ponzu.

nilslice avatar nilslice commented on April 29, 2024

from ponzu.

arjanvaneersel avatar arjanvaneersel commented on April 29, 2024

That indeed did it. I relied on the auto import function of gogland and never even thought about something as simple as checking the import path... Thanks for your help.

from ponzu.

nilslice avatar nilslice commented on April 29, 2024

Excellent! Glad it fixed the issue.

from ponzu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.