blog

package
v0.0.0-...-5f86a77 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	BaseURL string
	// contains filtered or unexported fields
}

func NewBlogAdmin

func NewBlogAdmin(db db.DB) *Admin

func (*Admin) Bind

func (a *Admin) Bind(r chi.Router)

func (*Admin) Panels

func (a *Admin) Panels(r *http.Request) ([]string, error)

Render a blog admin panel.

type App

type App struct {
	BaseURL     string
	FeedRSSURL  string
	FeedAtomURL string

	PageSize int
	// contains filtered or unexported fields
}

func NewApp

func NewApp(db db.DB) *App

NewApp instantiates a new blog app.

func (*App) Bind

func (a *App) Bind(r chi.Router)

Attach the blog to r at base.

func (*App) GetAdmin

func (a *App) GetAdmin() (app.Admin, error)

Return an Admin object that can render admin homepage panels and register all of the administrative pages.

func (*App) Migrate

func (a *App) Migrate() error

Migrate the blog backend.

func (*App) Name

func (a *App) Name() string

func (*App) Register

func (a *App) Register(reg *mtr.Registry)

func (*App) WithBaseURL

func (a *App) WithBaseURL(url string) *App

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader(db db.DB) *Loader

func (*Loader) Load

func (l *Loader) Load(r io.Reader) error

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:"-"`
	// 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) Get

func (s *PostService) Get(id int) (*Post, error)

Get a post by its id.

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) Select

func (s *PostService) Select(where string, args ...interface{}) ([]*Post, error)

Select multiple posts via a query.

Jump to

Keyboard shortcuts

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