Coder Social home page Coder Social logo

Comments (16)

nilslice avatar nilslice commented on April 28, 2024 1

@fbaube - very glad to hear it is working for you now.

In order to use Ponzu with Buffalo or any other web framework, you need to think of Ponzu as the data layer (DB/backend/etc) and Buffalo as the frontend. You will make HTTP calls to fetch your Ponzu CMS data from the controllers/models in the frontend, and use that JSON data to populate your views with content or conversely send data to Ponzu from Buffalo in a controller/model via the same HTTP API.

Since your Ponzu content types are all exported from the content package, you can easily re-use them in any other Go app, so unmarshaling your JSON from a Ponzu API response back into Go structs is simple: import the content package from your Ponzu project and use your content types.

At the moment, I do not have plans to make a video for Ponzu+Buffalo specifically, but I am working on a set of videos to show how one might use Ponzu with a smaller web framework (maybe in Go, maybe not) or just net/http to make a simple frontend that talks to Ponzu over HTTP.

I believe the GopherCon website is the current best available combination of Ponzu+Buffalo:

You can see how they import the Ponzu content types from within the Buffalo models package:
https://github.com/gopheracademy/gcon/blob/master/models/workshop.go#L6 and @bketelsen wrote an optional, but super useful cache & content API generator to work with Ponzu data:
https://github.com/bketelsen/ponzi
https://github.com/bketelsen/ponzigen

That's about all I can offer from a "how to use" Ponzu+Buffalo, so I hope it helps.. Both the #buffalo and #ponzu channels on the Gopher's Slack are pretty active with people who can help. So I'd suggest that those be the next places you check for more specific questions. I'm happy to help, but don't know much about Buffalo specifically.

Steve

from ponzu.

 avatar commented on April 28, 2024 1

thats all.
looks really useful. Will give it a whirl now

from ponzu.

fbaube avatar fbaube commented on April 28, 2024

I have this in content/myfields.go:

type Myfields struct {
        item.Item
        Mytitle      string   `json:"mytitle"`
        Myrich1      string   `json:"myrich1"`
        Myrich2      string   `json:"myrich2"`
        Myrich3      string   `json:"myrich3"`
        Mystringlist []string `json:"mystringlist"`
        Mycheckbox   string   `json:"mycheckbox"`
        Myfile       string   `json:"myfile"`
        Myselect     string   `json:"myselect"`
        Mytags       string   `json:"mytags"`
        Mytextarea   string   `json:"mytextarea"`
        Mytimestamp  string   `json:"mytimestamp"`
}

I assume I have some incorrect values in the code block above (all the "string" entries), but it's generating a UI without any visible errors (except, there is no UI widget generated for the "[]string" item).

I'll keep experimenting :)

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

from ponzu.

fbaube avatar fbaube commented on April 28, 2024

Like, just paste in the whole thing ?

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

from ponzu.

fbaube avatar fbaube commented on April 28, 2024

Here's my content/myfields.go. Note that I did not use "ponzu gen" for this; I hacked it custom.

myfields.go.txt

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

from ponzu.

fbaube avatar fbaube commented on April 28, 2024

Ah, right you are, I added an entry and it appeared. But the widget only displays as a single text field, so are the list entries separated by whitespace ?

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

from ponzu.

fbaube avatar fbaube commented on April 28, 2024

The new "gen c" syntax works nicely. After the following command, and "ponzu build", I only had to go in and change the editor for "mystringlist" from Input(..) to InputRepeater(..).The UI looks fine; I'll exercise it next. Now I'm curious how it all integrates with Buffalo, mainly bcos Buffalo's DB access layer is based on "sqlx"; is there any chance of that video demo happening soon ?

ponzu gen c myfields
mytitle:string:text
mydesc:string:textarea
myrich1:string:richtext
myrich2:string:richtext
myrich3:string:richtext
mystringlist:"[]string"
mycheckbox:string:checkbox
myfile:string:file
myselect:string:select

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

@fbaube - I finally have a walk-through introduction to Ponzu recorded:
https://www.youtube.com/watch?v=T_1ncPoLgrg

I hope its helpful! Feel free to comment here after I close the issue.

from ponzu.

iharsuvorau avatar iharsuvorau commented on April 28, 2024

@nilslice the video is very helpful to start and get the overall understanding

but it seems that it is worth to have the 'kitchen sink' example somewhere written in the docs, because it's not very convenient to navigate the video to find, for example, the checkbox usage example, it would be better to work with searchable text

by the way, I've noticed that the General Usage command example:

$ ponzu gen content review title:"string" body:"string":richtext rating:"int"

produces:

type Review struct {
    item.Item

    Title  string   `json:"title"`
    Body   string   `json:"body"`
    Rating int      `json:"rating"`
    Tags   []string `json:"tags"`
}

The field Tags wasn't mentioned in the command but exists in the struct. It seems like a little bit confusing.

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

@iharsuvorau - thanks for calling that out, I can definitely edit it unless you want to open a PR to remove the Tags field from the struct in the docs?

from ponzu.

iharsuvorau avatar iharsuvorau commented on April 28, 2024

@nilslice I'm trying to push but have the same error as in #192:

$  git push origin ponzu-dev
remote: Permission to ponzu-cms/ponzu.git denied to iharsuvorau.
fatal: unable to access 'https://github.com/ponzu-cms/ponzu/': The requested URL returned error: 403

.git/config:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = https://github.com/ponzu-cms/ponzu
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[branch "ponzu-dev"]
	remote = origin
	merge = refs/heads/ponzu-dev

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

@iharsuvorau - thank you! you'll need to make a pull request on the Github repo page itself, not through Git. Fork the repo, clone it and checkout a ponzu-dev branch, make your changes locally, then push to your repo. Then open a PR to ponzu, to merge into the ponzu-dev branch from your ponzu-dev branch.

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.