summaryrefslogtreecommitdiff
path: root/examples/docker/admin
diff options
context:
space:
mode:
Diffstat (limited to 'examples/docker/admin')
-rw-r--r--examples/docker/admin/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/song.go73
-rw-r--r--examples/docker/admin/content/song.go73
2 files changed, 146 insertions, 0 deletions
diff --git a/examples/docker/admin/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/song.go b/examples/docker/admin/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/song.go
new file mode 100644
index 0000000..fa5e802
--- /dev/null
+++ b/examples/docker/admin/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/song.go
@@ -0,0 +1,73 @@
+package content
+
+import (
+ "fmt"
+
+ "github.com/ponzu-cms/ponzu/management/editor"
+ "github.com/ponzu-cms/ponzu/system/item"
+)
+
+type Song struct {
+ item.Item
+
+ Title string `json:"title"`
+ Artist string `json:"artist"`
+ Rating int `json:"rating"`
+ Opinion string `json:"opinion"`
+ SpotifyUrl string `json:"spotify_url"`
+}
+
+// MarshalEditor writes a buffer of html to edit a Song within the CMS
+// and implements editor.Editable
+func (s *Song) MarshalEditor() ([]byte, error) {
+ view, err := editor.Form(s,
+ // Take note that the first argument to these Input-like functions
+ // is the string version of each Song field, and must follow
+ // this pattern for auto-decoding and auto-encoding reasons:
+ editor.Field{
+ View: editor.Input("Title", s, map[string]string{
+ "label": "Title",
+ "type": "text",
+ "placeholder": "Enter the Title here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Artist", s, map[string]string{
+ "label": "Artist",
+ "type": "text",
+ "placeholder": "Enter the Artist here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Rating", s, map[string]string{
+ "label": "Rating",
+ "type": "text",
+ "placeholder": "Enter the Rating here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Opinion", s, map[string]string{
+ "label": "Opinion",
+ "type": "text",
+ "placeholder": "Enter the Opinion here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("SpotifyUrl", s, map[string]string{
+ "label": "SpotifyUrl",
+ "type": "text",
+ "placeholder": "Enter the SpotifyUrl here",
+ }),
+ },
+ )
+
+ if err != nil {
+ return nil, fmt.Errorf("Failed to render Song editor view: %s", err.Error())
+ }
+
+ return view, nil
+}
+
+func init() {
+ item.Types["Song"] = func() interface{} { return new(Song) }
+}
diff --git a/examples/docker/admin/content/song.go b/examples/docker/admin/content/song.go
new file mode 100644
index 0000000..fa5e802
--- /dev/null
+++ b/examples/docker/admin/content/song.go
@@ -0,0 +1,73 @@
+package content
+
+import (
+ "fmt"
+
+ "github.com/ponzu-cms/ponzu/management/editor"
+ "github.com/ponzu-cms/ponzu/system/item"
+)
+
+type Song struct {
+ item.Item
+
+ Title string `json:"title"`
+ Artist string `json:"artist"`
+ Rating int `json:"rating"`
+ Opinion string `json:"opinion"`
+ SpotifyUrl string `json:"spotify_url"`
+}
+
+// MarshalEditor writes a buffer of html to edit a Song within the CMS
+// and implements editor.Editable
+func (s *Song) MarshalEditor() ([]byte, error) {
+ view, err := editor.Form(s,
+ // Take note that the first argument to these Input-like functions
+ // is the string version of each Song field, and must follow
+ // this pattern for auto-decoding and auto-encoding reasons:
+ editor.Field{
+ View: editor.Input("Title", s, map[string]string{
+ "label": "Title",
+ "type": "text",
+ "placeholder": "Enter the Title here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Artist", s, map[string]string{
+ "label": "Artist",
+ "type": "text",
+ "placeholder": "Enter the Artist here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Rating", s, map[string]string{
+ "label": "Rating",
+ "type": "text",
+ "placeholder": "Enter the Rating here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("Opinion", s, map[string]string{
+ "label": "Opinion",
+ "type": "text",
+ "placeholder": "Enter the Opinion here",
+ }),
+ },
+ editor.Field{
+ View: editor.Input("SpotifyUrl", s, map[string]string{
+ "label": "SpotifyUrl",
+ "type": "text",
+ "placeholder": "Enter the SpotifyUrl here",
+ }),
+ },
+ )
+
+ if err != nil {
+ return nil, fmt.Errorf("Failed to render Song editor view: %s", err.Error())
+ }
+
+ return view, nil
+}
+
+func init() {
+ item.Types["Song"] = func() interface{} { return new(Song) }
+}