Documentation ¶
Index ¶
- func URLSafeSlug(input string) string
- type Handler
- func (h Handler) AddPost(w http.ResponseWriter, r *http.Request)
- func (h Handler) AddTag(w http.ResponseWriter, r *http.Request)
- func (h Handler) AddTagToPost(w http.ResponseWriter, r *http.Request)
- func (h Handler) GetPost(w http.ResponseWriter, r *http.Request)
- func (h Handler) GetTag(w http.ResponseWriter, r *http.Request)
- func (h Handler) GetTagWithPosts(w http.ResponseWriter, r *http.Request)
- func (h Handler) ListPosts(w http.ResponseWriter, r *http.Request)
- func (h Handler) ListTags(w http.ResponseWriter, r *http.Request)
- func (h Handler) RegisterRoutes(mux *chi.Mux)
- func (h Handler) RemoveTagFromPost(w http.ResponseWriter, r *http.Request)
- func (h Handler) ToggleActive(w http.ResponseWriter, r *http.Request)
- func (h Handler) ToggleFeatured(w http.ResponseWriter, r *http.Request)
- func (h Handler) UpdatePost(w http.ResponseWriter, r *http.Request)
- func (h Handler) UpdateTag(w http.ResponseWriter, r *http.Request)
- type Manager
- func (m Manager) AddTagToPost(pid, tid string) error
- func (m Manager) GetPost(pid string) (Post, error)
- func (m Manager) GetPostWithSlug(slug string) (Post, error)
- func (m Manager) GetTagWithPosts(tid string, limit, offset int) (Tag, error)
- func (m Manager) ListActiveFeaturedPosts() ([]Post, error)
- func (m Manager) ListActivePosts(limit, offset int) ([]Post, error)
- func (m Manager) ListPosts(limit, offset int) ([]Post, error)
- func (m Manager) ListSlugUpdatedActive() ([]Post, error)
- func (m Manager) ListTags() ([]Tag, error)
- func (m Manager) NewPost(r io.Reader) (Post, error)
- func (m Manager) NewTag(r io.Reader) (Tag, error)
- func (m Manager) PageActivePosts(limit, page int) ([]Post, Paginator, error)
- func (m Manager) RemoveTagFromPost(pid, tid string) error
- func (m Manager) ToggleActive(pid string) error
- func (m Manager) ToggleFeatured(pid string) error
- func (m Manager) UpdatePost(r io.Reader) error
- func (m Manager) UpdateTag(r io.Reader) error
- type Paginator
- type ParamExtractor
- type Post
- func (p *Post) BeforeCreate(scope *gorm.DB) error
- func (p *Post) BeforeUpdate(scope *gorm.DB) error
- func (p Post) GetDescription(def string) string
- func (p Post) GetFbAppId(def string) string
- func (p Post) GetOgDescription(def string) string
- func (p Post) GetOgImage(def string) string
- func (p Post) GetOgLocale() string
- func (p Post) GetOgTitle(def string) string
- func (p Post) GetOgType() string
- func (p Post) GetOgUrl(def string) string
- func (p Post) GetTitle(def string) string
- func (p Post) GetTwitterCard(def string) string
- func (p Post) GetTwitterCreator(def string) string
- func (p Post) GetTwitterDescription(def string) string
- func (p Post) GetTwitterImage(def string) string
- func (p Post) GetTwitterSite(def string) string
- func (p Post) GetTwitterTitle(def string) string
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func URLSafeSlug ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(m Manager, pe ParamExtractor) Handler
func (Handler) AddTagToPost ¶
func (h Handler) AddTagToPost(w http.ResponseWriter, r *http.Request)
func (Handler) GetTag ¶ added in v0.3.0
func (h Handler) GetTag(w http.ResponseWriter, r *http.Request)
func (Handler) GetTagWithPosts ¶
func (h Handler) GetTagWithPosts(w http.ResponseWriter, r *http.Request)
func (Handler) RegisterRoutes ¶
RegisterRoutes takes a mux, should be a sub router with the desired auth middleware attached All of these routes are intended to be secure as they are for authoring of the posts.
func (Handler) RemoveTagFromPost ¶
func (h Handler) RemoveTagFromPost(w http.ResponseWriter, r *http.Request)
func (Handler) ToggleActive ¶
func (h Handler) ToggleActive(w http.ResponseWriter, r *http.Request)
func (Handler) ToggleFeatured ¶
func (h Handler) ToggleFeatured(w http.ResponseWriter, r *http.Request)
func (Handler) UpdatePost ¶
func (h Handler) UpdatePost(w http.ResponseWriter, r *http.Request)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (Manager) AddTagToPost ¶
func (Manager) GetTagWithPosts ¶
func (Manager) ListActiveFeaturedPosts ¶
func (Manager) ListActivePosts ¶
func (Manager) ListSlugUpdatedActive ¶
func (Manager) PageActivePosts ¶
func (Manager) RemoveTagFromPost ¶
func (Manager) ToggleActive ¶
func (Manager) ToggleFeatured ¶
type Post ¶
type Post struct { ID string `gorm:"type:varchar(48)" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:",omitempty"` Title string `json:"title" gorm:"type:varchar(2048)"` Slug string `json:"slug" gorm:"index:idx_slug;type:varchar(2048)"` Body string `json:"body" gorm:"type:text"` Description string `json:"description" gorm:"type:text"` Featured bool `json:"featured"` Active bool `json:"active"` AuthorID string `json:"authorId" gorm:"type:varchar(1024)"` Tags []*Tag `gorm:"many2many:post_tags;" json:"tags"` Cover string `json:"cover" gorm:"type:varchar(2048)"` CoverAlt string `json:"coverAlt" gorm:"type:text"` OgURL string `json:"ogurl"` OgTitle string `json:"ogtitle"` OgDescription string `json:"ogdescription"` OgImage string `json:"ogimage"` OgImageType string `json:"ogimagetype"` OgImageWidth string `json:"ogimagewidth"` OgImageHeight string `json:"ogimageheight"` FbAppID string `json:"fbappid"` OgType string `json:"ogtype"` OgLocale string `json:"oglocale"` TwitterCard string `json:"twittercard"` TwitterSite string `json:"twittersite"` TwitterTitle string `json:"twittertitle"` TwitterDescription string `json:"twitterdescription"` TwitterCreator string `json:"twittercreator"` TwitterImage string `json:"twitterimage"` }
func (Post) GetDescription ¶
GetDescription returns page description, intended to be called from the template with a default value
func (Post) GetFbAppId ¶
GetFbAppId returns the fb app id or the default value passed in
func (Post) GetOgDescription ¶
GetOgDescription returns the open graph description, the regular description, or the default value passed in
func (Post) GetOgImage ¶
GetOgImage returns the open graph image or the default value passed in
func (Post) GetOgLocale ¶
GetOgLocale returns the open graph locale or the default locale
func (Post) GetOgTitle ¶
GetOgTitle returns the open graph title for the page, or the regular title, or the default value passed in
func (Post) GetTitle ¶
GetTitle returns the page title, intended to be called from the template with a default value
func (Post) GetTwitterCard ¶
GetTwitterCard returns the twitter card summary
func (Post) GetTwitterCreator ¶
GetTwitterCreator returns the twitter creator or default
func (Post) GetTwitterDescription ¶
GetTwitterDescription returns the twitter description or the page description or the default
func (Post) GetTwitterImage ¶
GetTwitterImage returns the twitter image or default
func (Post) GetTwitterSite ¶
GetTwitterSite returns the twitter site or default. i.e. @KendellFab
func (Post) GetTwitterTitle ¶
GetTwitterTitle returns the twitter title or the page title or the default
type Tag ¶
type Tag struct { ID string `gorm:"type:varchar(48)" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:",omitempty"` Title string `json:"title"` Slug string `json:"slug"` Body string `json:"body"` Posts []*Post `gorm:"many2many:post_tags;"` Cover string `json:"cover" gorm:"type:varchar(2048)"` CoverAlt string `json:"coverAlt" gorm:"type:text"` }