Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Field Blank With Ponzu #119

Closed
Nemesisesq opened this issue Apr 13, 2017 · 9 comments
Closed

Content Field Blank With Ponzu #119

Nemesisesq opened this issue Apr 13, 2017 · 9 comments

Comments

@Nemesisesq
Copy link

I love what you guys have done with ponzu unfortunately it's not working for me.

I followed the quickstart performing the following steps

I installed ponzu with go get

I created a new 'ponzu' project in my go path

I changed directories to the new project

I ran ponzu generate content review title:”string” author:”string” rating:”float64” body:”string” website_url:”string” items:”[]string” photos:”[]string”

I ran ponzu build

I ran ponzu run

then I navigated to localhost:8080

this is the directory
screen shot 2017-04-13 at 10 41 43 am

this is my terminal
screen shot 2017-04-13 at 10 41 27 am

this is the admin running
screen shot 2017-04-13 at 10 40 48 am

@Nemesisesq
Copy link
Author

I am running go1.8

ponzu version 0.9.1

ponzu --cli version 0.9.1

@nilslice
Copy link
Contributor

Could you paste the generated review.go file here too? Did you edit it at all or immediate just build and run?

Also, can you try visiting http://localhost:8080/admin/edit?type=Review

It's strange that you're able to run the project but the content type isn't showing.

@Nemesisesq
Copy link
Author

Nemesisesq commented Apr 13, 2017

package content

import (
	"fmt"

	"github.com/ponzu-cms/ponzu/management/editor"
	"github.com/ponzu-cms/ponzu/system/item"
)

type Review struct {
	item.Item

	Title      string   `json:"title"`
	Author     string   `json:"author"`
	Rating     float64  `json:"rating"`
	Body       string   `json:"body"`
	WebsiteUrl string   `json:"website_url"`
	Items      []string `json:"items"`
	Photos     []string `json:"photos"`
}

// MarshalEditor writes a buffer of html to edit a Review within the CMS
// and implements editor.Editable
func (r *Review) MarshalEditor() ([]byte, error) {
	view, err := editor.Form(r,
		// Take note that the first argument to these Input-like functions
		// is the string version of each Review field, and must follow
		// this pattern for auto-decoding and auto-encoding reasons:
		editor.Field{
			View: editor.Input("Title", r, map[string]string{
				"label":       "Title",
				"type":        "text",
				"placeholder": "Enter the Title here",
			}),
		},
		editor.Field{
			View: editor.Input("Author", r, map[string]string{
				"label":       "Author",
				"type":        "text",
				"placeholder": "Enter the Author here",
			}),
		},
		editor.Field{
			View: editor.Input("Rating", r, map[string]string{
				"label":       "Rating",
				"type":        "text",
				"placeholder": "Enter the Rating here",
			}),
		},
		editor.Field{
			View: editor.Input("Body", r, map[string]string{
				"label":       "Body",
				"type":        "text",
				"placeholder": "Enter the Body here",
			}),
		},
		editor.Field{
			View: editor.Input("WebsiteUrl", r, map[string]string{
				"label":       "WebsiteUrl",
				"type":        "text",
				"placeholder": "Enter the WebsiteUrl here",
			}),
		},
		editor.Field{
			View: editor.Input("Items", r, map[string]string{
				"label":       "Items",
				"type":        "text",
				"placeholder": "Enter the Items here",
			}),
		},
		editor.Field{
			View: editor.Input("Photos", r, map[string]string{
				"label":       "Photos",
				"type":        "text",
				"placeholder": "Enter the Photos here",
			}),
		},
	)

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

	return view, nil
}

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

@Nemesisesq
Copy link
Author

Error:
There is no type registered for Review

Add this to the file which defines Review{} in the 'content' package:

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

This is what I get when I visit the link above

@nilslice
Copy link
Contributor

Hmm.. what is the output of pwd from within the directory you are executing ponzu run ?

@Nemesisesq
Copy link
Author

/Users/nem/go/src/github.com/wearevest/vestCMS is the output of pwd

I just got it working when I reinstalled it in a different place. i'm going to try to reinstall

@nilslice
Copy link
Contributor

Ok, great - go ahead and close this issue if your new build works. Otherwise let me know and I will try to continue help w/ debugging.

@Nemesisesq
Copy link
Author

It's working now, I'm not exactly sure why. If I have any other problems I will let you know thank you.

@nilslice
Copy link
Contributor

Sounds good! Glad it's working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants