diff options
author | Steve <nilslice@gmail.com> | 2017-03-15 13:55:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 13:55:55 -0700 |
commit | 1a62c2bfe3cec71391e51f0c59b6c008179b7e89 (patch) | |
tree | 18a1a89076303acf3d2be40aa4ca371ed27ede3a /examples/createable/README.md | |
parent | 0eaddb8ae0b29937f7514cc83c63e0aa3c377850 (diff) | |
parent | 5ec811b5d1899cfe538ed6d19c8a5ee01a553f03 (diff) |
Merge pull request #99 from ponzu-cms/ponzu-dev
[core] Add api.Deleteable interface, rename Externalable to Createable and rename methods
Diffstat (limited to 'examples/createable/README.md')
-rw-r--r-- | examples/createable/README.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/createable/README.md b/examples/createable/README.md new file mode 100644 index 0000000..44ba03c --- /dev/null +++ b/examples/createable/README.md @@ -0,0 +1,31 @@ +# Createable + +This example shows how to enable outside clients to submit content to your CMS. +All content submitted must be done through a POST request encoded as `multipart/form-data` +to the API endpoint `/api/content/create?type=<Type>` + +## Song example +Imagine an app that lets users add Spotify music to a global playlist, and you need them +to supply songs in the format: +```go +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"` +} +``` + +See the file `content/song.go` and read the comments to understand the various +methods needed to satisfy required interfaces for this kind of activity. + +### Overview +1. Implement `api.Createable` with the `Create(http.ResponseWriter, *http.Request)` method to allow outside POST requests +2. Implement `editor.Mergeable` with the `Approve(http.ResponseWriter, *http.Request)` method so you can control the Approval / Rejection of submitted content OR +3. Implement `api.Trustable` with the `AutoApprove(http.ResponseWriter, *http.Request)` method to bypass `Approve` and auto-approve and publish submitted content + +There are various validation and request checks shown in this example as well. +Please feel free to modify and submit a PR for updates or bug fixes!
\ No newline at end of file |