Documentation
¶
Index ¶
- Constants
- type Admin
- type App
- type Loader
- type Post
- type PostService
- func (s *PostService) AttachFile(postID, uploadID uint64) error
- func (s *PostService) DetachFile(postID, uploadID uint64) error
- func (s *PostService) Get(id int) (*Post, error)
- func (s *PostService) GetAttachedFiles(postID uint64) ([]*uploads.Upload, error)
- func (s *PostService) GetSlug(slug string) (*Post, error)
- func (s *PostService) Insert(p *Post) error
- func (s *PostService) InsertArchive(p *Post) error
- func (s *PostService) Save(p *Post) error
- func (s *PostService) Search(query string, publishedFilter int, limit int, offset int) ([]*Post, error)
- func (s *PostService) SearchCount(query string, publishedFilter int) (int, error)
- func (s *PostService) Select(where string, args ...interface{}) ([]*Post, error)
Constants ¶
const ( QueryAll = -1 // Search all posts regardless of published status QueryUnpublished = 0 // Search unpublished posts only QueryPublished = 1 // Search published posts only )
Query filter constants for search functionality
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
BaseURL string
FeedRSSURL string
FeedAtomURL string
PageSize int
// contains filtered or unexported fields
}
func (*App) GetAdmin ¶
Return an Admin object that can render admin homepage panels and register all of the administrative pages.
func (*App) WithBaseURL ¶
type Post ¶
type Post struct {
ID uint64
Title string
Slug string
Content string
ContentRendered string `db:"content_rendered"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
PublishedAt time.Time `db:"published_at"`
Published int
Tags []string `db:"-"`
// OpenGraph Tags
OgDescription string `db:"og_description"`
OgImage string `db:"og_image"`
// contains filtered or unexported fields
}
A Post is an entry in a blog
type PostService ¶
type PostService struct {
// contains filtered or unexported fields
}
func NewPostService ¶
func NewPostService(db db.DB) *PostService
NewPostService returns a cursor for Posts.
func (*PostService) AttachFile ¶
func (s *PostService) AttachFile(postID, uploadID uint64) error
AttachFile associates an upload with a post
func (*PostService) DetachFile ¶
func (s *PostService) DetachFile(postID, uploadID uint64) error
DetachFile removes the association between an upload and a post
func (*PostService) GetAttachedFiles ¶
func (s *PostService) GetAttachedFiles(postID uint64) ([]*uploads.Upload, error)
GetAttachedFiles returns all uploads attached to this post
func (*PostService) GetSlug ¶
func (s *PostService) GetSlug(slug string) (*Post, error)
GetSlug gets a post by its slug.
func (*PostService) Insert ¶
func (s *PostService) Insert(p *Post) error
Insert p into the database db. If successful, p.ID will be set to the auto incremented ID provided by the database.
func (*PostService) InsertArchive ¶
func (s *PostService) InsertArchive(p *Post) error
InsertArchive inserts a post as an archival post, skipping the pre-save
func (*PostService) Save ¶
func (s *PostService) Save(p *Post) error
Save p to the database. If p's ID is 0, it is created with a new ID, otherwise it is updated. Even if the insertion or the update is a failure, preSave routines that modify p will run.
func (*PostService) Search ¶
func (s *PostService) Search(query string, publishedFilter int, limit int, offset int) ([]*Post, error)
Search performs a full-text search on posts with ternary published filter. publishedFilter: QueryAll, QueryUnpublished, or QueryPublished
func (*PostService) SearchCount ¶
func (s *PostService) SearchCount(query string, publishedFilter int) (int, error)
SearchCount returns the count of posts matching the search query. publishedFilter: QueryAll, QueryUnpublished, or QueryPublished