Documentation
¶
Index ¶
- type ContentWatcher
- type DB
- type PopularPost
- type Post
- type PostRepository
- func (r *PostRepository) CountPublished() (int, error)
- func (r *PostRepository) Create(post *Post) error
- func (r *PostRepository) Delete(id int64) error
- func (r *PostRepository) GetByID(id int64) (*Post, error)
- func (r *PostRepository) GetBySlug(slug string) (*Post, error)
- func (r *PostRepository) IndexPost(postID int64, title, tags, content string) error
- func (r *PostRepository) ListAll(limit, offset int) ([]*Post, error)
- func (r *PostRepository) ListPublished(limit, offset int) ([]*Post, error)
- func (r *PostRepository) RemoveFromIndex(postID int64) error
- func (r *PostRepository) Search(query string, limit int) ([]*Post, error)
- func (r *PostRepository) Update(post *Post) error
- func (r *PostRepository) UpsertBySlug(post *Post) error
- type PostStatus
- type PreferenceRepository
- type ViewRepository
- func (r *ViewRepository) GetAllViewStats() (map[int64]*ViewStats, error)
- func (r *ViewRepository) GetPopularPosts(limit int) ([]*PopularPost, error)
- func (r *ViewRepository) GetRecentViewers(postID int64, limit int) ([]time.Time, error)
- func (r *ViewRepository) GetViewStats(postID int64) (*ViewStats, error)
- func (r *ViewRepository) RecordView(postID int64, viewerHash string) error
- type ViewStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentWatcher ¶ added in v0.3.0
type ContentWatcher struct {
// contains filtered or unexported fields
}
ContentWatcher watches a directory for changes and triggers sync callbacks
func NewContentWatcher ¶ added in v0.3.0
func NewContentWatcher(contentDir string, callback func() error) (*ContentWatcher, error)
NewContentWatcher creates a new file system watcher
func (*ContentWatcher) Start ¶ added in v0.3.0
func (cw *ContentWatcher) Start() error
Start begins watching for file changes
func (*ContentWatcher) Stop ¶ added in v0.3.0
func (cw *ContentWatcher) Stop() error
Stop stops the watcher
type PopularPost ¶ added in v0.4.0
PopularPost represents a post with its view count
type Post ¶
type Post struct {
ID int64
Slug string
Title string
Filepath string
Status PostStatus
CreatedAt time.Time
UpdatedAt time.Time
PublishedAt *time.Time
Tags []string
}
Post represents a blog post in the database
type PostRepository ¶
type PostRepository struct {
// contains filtered or unexported fields
}
PostRepository handles database operations for posts
func NewPostRepository ¶
func NewPostRepository(db *DB) *PostRepository
NewPostRepository creates a new PostRepository
func (*PostRepository) CountPublished ¶
func (r *PostRepository) CountPublished() (int, error)
CountPublished returns the total number of published posts
func (*PostRepository) Create ¶
func (r *PostRepository) Create(post *Post) error
Create inserts a new post into the database
func (*PostRepository) Delete ¶
func (r *PostRepository) Delete(id int64) error
Delete removes a post from the database and its FTS index
func (*PostRepository) GetByID ¶
func (r *PostRepository) GetByID(id int64) (*Post, error)
GetByID retrieves a post by its ID
func (*PostRepository) GetBySlug ¶
func (r *PostRepository) GetBySlug(slug string) (*Post, error)
GetBySlug retrieves a post by its slug
func (*PostRepository) IndexPost ¶ added in v0.4.0
func (r *PostRepository) IndexPost(postID int64, title, tags, content string) error
IndexPost adds or updates a post in the FTS5 search index
func (*PostRepository) ListAll ¶
func (r *PostRepository) ListAll(limit, offset int) ([]*Post, error)
ListAll returns all posts regardless of status
func (*PostRepository) ListPublished ¶
func (r *PostRepository) ListPublished(limit, offset int) ([]*Post, error)
ListPublished returns all published posts, ordered by published date descending
func (*PostRepository) RemoveFromIndex ¶ added in v0.4.0
func (r *PostRepository) RemoveFromIndex(postID int64) error
RemoveFromIndex removes a post from the FTS5 search index
func (*PostRepository) Search ¶
func (r *PostRepository) Search(query string, limit int) ([]*Post, error)
Search finds posts matching a query using FTS5 full-text search Falls back to LIKE-based search if FTS5 table is empty
func (*PostRepository) Update ¶
func (r *PostRepository) Update(post *Post) error
Update updates an existing post
func (*PostRepository) UpsertBySlug ¶
func (r *PostRepository) UpsertBySlug(post *Post) error
UpsertBySlug creates or updates a post based on its slug
type PostStatus ¶
type PostStatus string
PostStatus represents the publication status of a post
const ( StatusDraft PostStatus = "draft" StatusPublished PostStatus = "published" StatusScheduled PostStatus = "scheduled" )
type PreferenceRepository ¶ added in v0.2.0
type PreferenceRepository struct {
// contains filtered or unexported fields
}
PreferenceRepository handles database operations for user preferences
func NewPreferenceRepository ¶ added in v0.2.0
func NewPreferenceRepository(db *DB) *PreferenceRepository
NewPreferenceRepository creates a new PreferenceRepository
func (*PreferenceRepository) GetTheme ¶ added in v0.2.0
func (r *PreferenceRepository) GetTheme(fingerprint string) (string, error)
GetTheme retrieves the saved theme for a user (identified by SSH fingerprint)
func (*PreferenceRepository) SetTheme ¶ added in v0.2.0
func (r *PreferenceRepository) SetTheme(fingerprint, themeName string) error
SetTheme saves the theme preference for a user
type ViewRepository ¶ added in v0.4.0
type ViewRepository struct {
// contains filtered or unexported fields
}
ViewRepository handles database operations for post views
func NewViewRepository ¶ added in v0.4.0
func NewViewRepository(db *DB) *ViewRepository
NewViewRepository creates a new ViewRepository
func (*ViewRepository) GetAllViewStats ¶ added in v0.4.0
func (r *ViewRepository) GetAllViewStats() (map[int64]*ViewStats, error)
GetAllViewStats returns view statistics for all posts
func (*ViewRepository) GetPopularPosts ¶ added in v0.4.0
func (r *ViewRepository) GetPopularPosts(limit int) ([]*PopularPost, error)
GetPopularPosts returns the most viewed posts
func (*ViewRepository) GetRecentViewers ¶ added in v0.4.0
GetRecentViewers returns recent viewers for a post (for debugging/admin)
func (*ViewRepository) GetViewStats ¶ added in v0.4.0
func (r *ViewRepository) GetViewStats(postID int64) (*ViewStats, error)
GetViewStats returns view statistics for a post
func (*ViewRepository) RecordView ¶ added in v0.4.0
func (r *ViewRepository) RecordView(postID int64, viewerHash string) error
RecordView records a view for a post viewerHash should be SSH fingerprint, session ID, or IP hash