ghost

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 8 Imported by: 0

README

go-ghost

GoDoc

Simple library that provides convienence functions to handle authentication and REST slug building for the ghost.io API.

Read more about the API here: https://ghost.org/docs/api/v2/admin/

History

Fork of http://github.com/writeas/go-ghost

Usage

See https://github.com/philips/go-ghost/blob/master/sample/main.go for an example of updating an existing Post.

Documentation

Overview

Package ghost provides the binding for Ghost APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func String

func String(v string) *string

String returns a pointer to the string value passed in.

Types

type Author

type Author struct {
	ID              *string `json:"id"`
	Name            *string `json:"name"`
	Slug            *string `json:"slug"`
	ProfileImage    *string `json:"profile_image"`
	CoverImage      *string `json:"cover_image"`
	Bio             *string `json:"bio"`
	Website         *string `json:"website"`
	Location        *string `json:"location"`
	Facebook        *string `json:"facebook"`
	Twitter         *string `json:"twitter"`
	MetaTitle       *string `json:"meta_title"`
	MetaDescription *string `json:"meta_description"`
	URL             *string `json:"url"`
}

type Client

type Client struct {
	URL       string
	Key       string
	Version   string
	GhostPath string
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url, key string) *Client

NewClient creates a new Ghost API client. URL and Key are explained in the Ghost API docs: https://ghost.org/docs/api/v2/content/#authentication

func (*Client) EndpointForID

func (c *Client) EndpointForID(api, resource, id string) string

EndpointForID is a HTTP Path slug generator for a Ghost resource. e.g. "admin", "post", "abc123".

func (*Client) EndpointForSlug

func (c *Client) EndpointForSlug(api, resource, slug string) string

EndpointForID is a HTTP Path slug generator for a Ghost resource via its slug. e.g. "admin", "post", "my-new-post".

func (*Client) Request

func (c *Client) Request(method, path string, data interface{}) (*http.Response, error)

Request makes an API request to Ghost with the given HTTP method, HTTP Path, and data marshaled to JSON in the body. The JSON object needs to follow the structure of all Ghost Request/Response objects.

https://ghost.org/docs/api/v2/admin/#json-format

type Error

type Error struct {
	ID      *string `json:"id"`
	Message *string `json:"message"`
	Context *string `json:"context"`
	Type    *string `json:"type"`
}

func (Error) Error

func (e Error) Error() string

type Post

type Post struct {
	ID                 *string    `json:"id,omitempty"`
	UUID               *string    `json:"uuid,omitempty"`
	Title              *string    `json:"title,omitempty"`
	Slug               *string    `json:"slug,omitempty"`
	HTML               *string    `json:"html,omitempty"`
	Mobiledoc          *string    `json:"mobiledoc,omitempty"`
	CommentID          *string    `json:"comment_id,omitempty"`
	FeatureImage       *string    `json:"feature_image,omitempty"`
	Featured           *bool      `json:"featured,omitempty"`
	Page               *bool      `json:"page,omitempty"`
	MetaTitle          *string    `json:"meta_title,omitempty"`
	MetaDescription    *string    `json:"meta_description,omitempty"`
	CreatedAt          *time.Time `json:"created_at,omitempty"`
	UpdatedAt          *time.Time `json:"updated_at,omitempty"`
	PublishedAt        *time.Time `json:"published_at,omitempty"`
	CustomExcerpt      *string    `json:"custom_excerpt,omitempty"`
	OGImage            *string    `json:"og_image,omitempty"`
	OGTitle            *string    `json:"og_title,omitempty"`
	OGDescription      *string    `json:"og_description,omitempty"`
	TwitterImage       *string    `json:"twitter_image,omitempty"`
	TwitterTitle       *string    `json:"twitter_title,omitempty"`
	TwitterDescription *string    `json:"twitter_description,omitempty"`
	CustomTemplate     *string    `json:"custom_template,omitempty"`
	PrimaryAuthor      *Author    `json:"primary_author,omitempty"`
	PrimaryTag         *Tag       `json:"primary_tag,omitempty"`
	URL                *string    `json:"url,omitempty"`
	Excerpt            *string    `json:"excerpt,omitempty"`
}

type PostRequest

type PostRequest struct {
	Posts  []Post  `json:"posts,omitempty"`
	Errors []Error `json:"errors,omitempty"`
}

type Tag

type Tag struct {
	ID              *string   `json:"id"`
	Name            *string   `json:"name"`
	Slug            *string   `json:"slug"`
	Description     *string   `json:"description"`
	FeaturedImage   *string   `json:"featured_image"`
	Visibility      *string   `json:"visibility"`
	MetaTitle       *string   `json:"meta_title"`
	MetaDescription *string   `json:"meta_description"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Parent          *Tag      `json:"parent"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL