blogstore

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

README

Blog Store

Tests Status Go Report Card PkgGoDev

Stores blog posts to a database table.

MCP (Model Context Protocol)

Blog Store includes an MCP (Model Context Protocol) HTTP handler that allows LLM clients (for example Windsurf) to manage blog posts via JSON-RPC tools.

  • The MCP handler lives in the mcp package
  • It supports MCP JSON-RPC methods (initialize, tools/list, tools/call) and legacy aliases (list_tools, call_tool)
  • It exposes tools such as post_list, post_create, post_get, post_update, and post_delete

See the detailed documentation and examples in: mcp/README.md

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Installation

go get -u github.com/dracory/blogstore

Setup

blogStore = blogstore.NewStore(blog.NewStoreOptions{
	DB:                 databaseInstance,
	PostTableName:     "blog_post",
	AutomigrateEnabled: true,
	DebugEnabled:       false,
})

Documentation

Index

Constants

View Source
const COLUMN_AUTHOR_ID = "author_id"
View Source
const COLUMN_CANONICAL_URL = "canonical_url"
View Source
const COLUMN_CONTENT = "content"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_FEATURED = "featured"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_IMAGE_URL = "image_url"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_META_DESCRIPTION = "meta_description"
View Source
const COLUMN_META_KEYWORDS = "meta_keywords"
View Source
const COLUMN_META_ROBOTS = "meta_robots"
View Source
const COLUMN_PUBLISHED_AT = "published_at"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_SUMMARY = "summary"
View Source
const COLUMN_TITLE = "title"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const NO = "no"
View Source
const POST_CONTENT_TYPE_BLOCKS = "blocks"
View Source
const POST_CONTENT_TYPE_HTML = "html"
View Source
const POST_CONTENT_TYPE_MARKDOWN = "markdown"
View Source
const POST_CONTENT_TYPE_PLAIN_TEXT = "plain_text"
View Source
const POST_EDITOR_BLOCKAREA = "BlockArea"
View Source
const POST_EDITOR_BLOCKEDITOR = "BlockEditor"
View Source
const POST_EDITOR_HTMLAREA = "HtmlArea"
View Source
const POST_EDITOR_MARKDOWN = "Markdown"
View Source
const POST_EDITOR_TEXTAREA = "TextArea"
View Source
const POST_STATUS_DRAFT = "draft"
View Source
const POST_STATUS_PUBLISHED = "published"
View Source
const POST_STATUS_TRASH = "trash"
View Source
const POST_STATUS_UNPUBLISHED = "unpublished"
View Source
const VERSIONING_TYPE_POST = "post"
View Source
const YES = "yes"

Variables

This section is empty.

Functions

func BlogNoImageUrl

func BlogNoImageUrl() string

func GenerateShortID added in v1.5.0

func GenerateShortID() string

GenerateShortID generates a new 9-character shortened ID using TimestampMicro

func IsShortID added in v1.5.0

func IsShortID(id string) bool

IsShortID checks if an ID appears to be shortened (9-21 chars, alphanumeric)

func NormalizeID added in v1.5.0

func NormalizeID(id string) string

NormalizeID normalizes an ID for lookup (lowercase)

func ShortenID added in v1.5.0

func ShortenID(id string) string

ShortenID shortens any numeric ID string using Crockford Base32

func UnshortenID added in v1.5.0

func UnshortenID(shortID string) (string, error)

UnshortenID attempts to unshorten a Crockford Base32 ID

Types

type NewStoreOptions

type NewStoreOptions struct {
	PostTableName      string
	DB                 *sql.DB
	DbDriverName       string
	TimeoutSeconds     int64
	AutomigrateEnabled bool
	DebugEnabled       bool

	VersioningEnabled   bool
	VersioningTableName string
}

NewStoreOptions define the options for creating a new block store

type Post

type Post struct {
	dataobject.DataObject
}

func NewPost

func NewPost() *Post

func NewPostFromExistingData

func NewPostFromExistingData(data map[string]string) *Post

func (*Post) AddMetas

func (o *Post) AddMetas(metas map[string]string) error

func (*Post) AuthorID

func (o *Post) AuthorID() string

func (*Post) CanonicalURL

func (o *Post) CanonicalURL() string

func (*Post) Content

func (o *Post) Content() string

func (*Post) ContentType added in v1.3.1

func (o *Post) ContentType() string

func (*Post) CreatedAt

func (o *Post) CreatedAt() string

func (*Post) CreatedAtCarbon

func (o *Post) CreatedAtCarbon() *carbon.Carbon

func (*Post) CreatedAtTime

func (o *Post) CreatedAtTime() time.Time

func (*Post) Editor

func (o *Post) Editor() string

func (*Post) Featured

func (o *Post) Featured() string

func (*Post) ID

func (o *Post) ID() string

func (*Post) ImageUrl

func (o *Post) ImageUrl() string

func (*Post) ImageUrlOrDefault

func (o *Post) ImageUrlOrDefault() string

func (*Post) IsContentBlocks added in v1.3.1

func (o *Post) IsContentBlocks() bool

func (*Post) IsContentHtml added in v1.3.1

func (o *Post) IsContentHtml() bool

func (*Post) IsContentMarkdown added in v1.3.1

func (o *Post) IsContentMarkdown() bool

func (*Post) IsContentPlainText added in v1.3.1

func (o *Post) IsContentPlainText() bool

func (*Post) IsDraft

func (o *Post) IsDraft() bool

func (*Post) IsPublished

func (o *Post) IsPublished() bool

func (*Post) IsTrashed

func (o *Post) IsTrashed() bool

func (*Post) IsUnpublished

func (o *Post) IsUnpublished() bool

func (*Post) MarshalToVersioning added in v1.4.0

func (o *Post) MarshalToVersioning() (string, error)

func (*Post) Memo

func (o *Post) Memo() string

func (*Post) Meta

func (o *Post) Meta(key string) string

func (*Post) MetaDescription

func (o *Post) MetaDescription() string

func (*Post) MetaKeywords

func (o *Post) MetaKeywords() string

func (*Post) MetaRobots

func (o *Post) MetaRobots() string

func (*Post) Metas

func (o *Post) Metas() (map[string]string, error)

func (*Post) PublishedAt

func (o *Post) PublishedAt() string

func (*Post) PublishedAtCarbon

func (o *Post) PublishedAtCarbon() *carbon.Carbon

func (*Post) PublishedAtTime

func (o *Post) PublishedAtTime() time.Time

func (*Post) SetAuthorID

func (o *Post) SetAuthorID(authorID string) *Post

func (*Post) SetCanonicalURL

func (o *Post) SetCanonicalURL(canonicalURL string) *Post

func (*Post) SetContent

func (o *Post) SetContent(content string) *Post

func (*Post) SetContentType added in v1.3.1

func (o *Post) SetContentType(contentType string) *Post

func (*Post) SetCreatedAt

func (o *Post) SetCreatedAt(createdAt string) *Post

func (*Post) SetEditor

func (o *Post) SetEditor(editor string) *Post

func (*Post) SetFeatured

func (o *Post) SetFeatured(featured string) *Post

func (*Post) SetID

func (o *Post) SetID(id string) *Post

func (*Post) SetImageUrl

func (o *Post) SetImageUrl(imageURL string) *Post

func (*Post) SetMemo

func (o *Post) SetMemo(memo string) *Post

func (*Post) SetMeta

func (o *Post) SetMeta(key string, value string) error

func (*Post) SetMetaDescription

func (o *Post) SetMetaDescription(metaDescription string) *Post

func (*Post) SetMetaKeywords

func (o *Post) SetMetaKeywords(metaKeywords string) *Post

func (*Post) SetMetaRobots

func (o *Post) SetMetaRobots(metaRobots string) *Post

func (*Post) SetMetas

func (o *Post) SetMetas(metas map[string]string) error

func (*Post) SetPublishedAt

func (o *Post) SetPublishedAt(status string) *Post

func (*Post) SetSoftDeletedAt added in v1.2.1

func (o *Post) SetSoftDeletedAt(deletedAt string) *Post

func (*Post) SetStatus

func (o *Post) SetStatus(status string) *Post

func (*Post) SetSummary

func (o *Post) SetSummary(summary string) *Post

func (*Post) SetTitle

func (o *Post) SetTitle(title string) *Post

func (*Post) SetUpdatedAt

func (o *Post) SetUpdatedAt(updatedAt string) *Post

func (*Post) Slug

func (o *Post) Slug() string

================================== METHODS ==================================

func (*Post) SoftDeletedAt added in v1.2.1

func (o *Post) SoftDeletedAt() string

func (*Post) SoftDeletedAtCarbon added in v1.2.1

func (o *Post) SoftDeletedAtCarbon() *carbon.Carbon

func (*Post) Status

func (o *Post) Status() string

func (*Post) Summary

func (o *Post) Summary() string

func (*Post) Title

func (o *Post) Title() string

func (*Post) UnmarshalFromVersioning added in v1.4.3

func (o *Post) UnmarshalFromVersioning(content string) error

func (*Post) UpdatedAt

func (o *Post) UpdatedAt() string

func (*Post) UpdatedAtCarbon

func (o *Post) UpdatedAtCarbon() *carbon.Carbon

type PostQueryOptions

type PostQueryOptions struct {
	ID                   string
	IDIn                 []string
	Status               string
	StatusIn             []string
	Search               string
	CreatedAtLessThan    string
	CreatedAtGreaterThan string
	Offset               int
	Limit                int
	SortOrder            string
	OrderBy              string
	CountOnly            bool
	WithDeleted          bool
}

type StoreInterface

type StoreInterface interface {
	AutoMigrate() error
	EnableDebug(debug bool) StoreInterface
	VersioningEnabled() bool

	PostCount(ctx context.Context, options PostQueryOptions) (int64, error)
	PostCreate(ctx context.Context, post *Post) error
	PostDelete(ctx context.Context, post *Post) error
	PostDeleteByID(ctx context.Context, postID string) error
	PostFindByID(ctx context.Context, id string) (*Post, error)
	PostList(ctx context.Context, options PostQueryOptions) ([]Post, error)
	PostSoftDelete(ctx context.Context, post *Post) error
	PostSoftDeleteByID(ctx context.Context, postID string) error
	PostTrash(ctx context.Context, post *Post) error
	PostUpdate(ctx context.Context, post *Post) error

	// Versioning
	VersioningCreate(ctx context.Context, versioning VersioningInterface) error
	VersioningDelete(ctx context.Context, versioning VersioningInterface) error
	VersioningDeleteByID(ctx context.Context, id string) error
	VersioningFindByID(ctx context.Context, versioningID string) (VersioningInterface, error)
	VersioningList(ctx context.Context, query VersioningQueryInterface) ([]VersioningInterface, error)
	VersioningSoftDelete(ctx context.Context, versioning VersioningInterface) error
	VersioningSoftDeleteByID(ctx context.Context, id string) error
	VersioningUpdate(ctx context.Context, versioning VersioningInterface) error
}

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new block store

type VersioningInterface added in v1.4.0

type VersioningInterface = versionstore.VersionInterface

func NewVersioning added in v1.4.0

func NewVersioning() VersioningInterface

type VersioningQueryInterface added in v1.4.0

type VersioningQueryInterface = versionstore.VersionQueryInterface

func NewVersioningQuery added in v1.4.0

func NewVersioningQuery() VersioningQueryInterface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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