huge blog refactor
tidying up data structures; improvements to blog admin UI/UX, etc.
This commit is contained in:
parent
eaa2f6587d
commit
0c2aaa0b38
18 changed files with 432 additions and 239 deletions
|
|
@ -1,27 +1,38 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
BlueskyRecord struct {
|
||||
ActorDID string `json:"actor"`
|
||||
RecordID string `json:"record"`
|
||||
}
|
||||
FediverseActivity struct {
|
||||
AccountID string `json:"account"`
|
||||
StatusID string `json:"status"`
|
||||
}
|
||||
|
||||
BlogAuthor struct {
|
||||
ID string `json:"id"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
BlogPost struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
Title string `json:"title" db:"title"`
|
||||
Description string `json:"description" db:"description"`
|
||||
Visible bool `json:"visible" db:"visible"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
ModifiedAt sql.NullTime `json:"modified_at" db:"modified_at"`
|
||||
AuthorID string `json:"author" db:"author"`
|
||||
Markdown string `json:"markdown" db:"markdown"`
|
||||
HTML template.HTML `json:"html" db:"html"`
|
||||
BlueskyActorID *string `json:"bluesky_actor" db:"bluesky_actor"`
|
||||
BlueskyPostID *string `json:"bluesky_post" db:"bluesky_post"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Visible bool `json:"visible"`
|
||||
PublishDate time.Time `json:"publish_date"`
|
||||
Author BlogAuthor `json:"author"`
|
||||
Markdown string `json:"markdown"`
|
||||
Bluesky *BlueskyRecord `json:"bluesky"`
|
||||
Fediverse *FediverseActivity `json:"fediverse"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -36,16 +47,13 @@ func (b *BlogPost) TitleNormalised() string {
|
|||
}
|
||||
|
||||
func (b *BlogPost) GetMonth() string {
|
||||
return fmt.Sprintf("%02d", int(b.CreatedAt.Month()))
|
||||
return fmt.Sprintf("%02d", int(b.PublishDate.Month()))
|
||||
}
|
||||
|
||||
func (b *BlogPost) PrintDate() string {
|
||||
return b.CreatedAt.Format("2 January 2006, 15:04")
|
||||
return b.PublishDate.Format("2 January 2006, 15:04")
|
||||
}
|
||||
|
||||
func (b *BlogPost) PrintModifiedDate() string {
|
||||
if !b.ModifiedAt.Valid {
|
||||
return ""
|
||||
}
|
||||
return b.ModifiedAt.Time.Format("2 January 2006, 15:04")
|
||||
func (b *BlogPost) TextPublishDate() string {
|
||||
return b.PublishDate.Format("2006-01-02T15:04")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue