data

package
v1.0.1-0...-65d85cd Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const TweetName = `碎碎念`

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	*proto.Comment
}

Comment ...

func (*Comment) Text

func (c *Comment) Text() string

Text ...

type Data

type Data struct {

	// all configuration.
	// It's not safe to export all configs outside.
	Config *config.Config

	// current login user, non-nil.
	User *auth.User

	// The response writer.
	Writer io.Writer

	// The template
	Template *template.Template

	// Metadata
	Meta *MetaData

	// If it is home page.
	Home *HomeData

	// If it is a post (or page).
	Post *PostData

	// If it is the Search.
	Search *SearchData

	// If it is the Posts.
	Posts *PostsData

	// If it is the Tags.
	Tags *TagsData

	// If it is the tag.
	Tag *TagData

	// 碎碎念、叽叽喳喳🦜
	Tweets *TweetsData

	Error *ErrorData

	Partials []any
	// contains filtered or unexported fields
}

Data holds all data for rendering the site.

func NewDataForHome

func NewDataForHome(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, impl service.ToBeImplementedByRpc) *Data

NewDataForHome ...

func NewDataForPost

func NewDataForPost(ctx context.Context, cfg *config.Config, user *auth.User, service proto.TaoBlogServer, post *proto.Post, comments []*proto.Comment) *Data

NewDataForPost ...

func NewDataForPosts

func NewDataForPosts(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, impl service.ToBeImplementedByRpc, r *http.Request) *Data

NewDataForPosts ...

func NewDataForSearch

func NewDataForSearch(ctx context.Context, cfg *config.Config, user *auth.User, service proto.TaoBlogServer, searcher proto.SearchServer, r *http.Request) *Data

NewDataForSearch ...

func NewDataForTag

func NewDataForTag(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, tags []string) *Data

NewDataForTag ...

func NewDataForTags

func NewDataForTags(ctx context.Context, cfg *config.Config, user *auth.User, service proto.TaoBlogServer, impl service.ToBeImplementedByRpc) *Data

NewDataForTags ...

func NewDataForTweets

func NewDataForTweets(ctx context.Context, cfg *config.Config, svc proto.TaoBlogServer) *Data

func (*Data) Author

func (d *Data) Author() string

func (*Data) BodyClass

func (d *Data) BodyClass() string

func (*Data) ExecutePartial

func (d *Data) ExecutePartial(t *template.Template, partial any) error

func (*Data) Info

func (d *Data) Info() (*proto.GetInfoResponse, error)

func (*Data) Partial

func (d *Data) Partial() (any, error)

func (*Data) SiteName

func (d *Data) SiteName() string

func (*Data) Strip

func (d *Data) Strip(obj any) (any, error)

func (*Data) Title

func (d *Data) Title() string

func (*Data) TweetName

func (d *Data) TweetName() string

type ErrorData

type ErrorData struct {
	Message string
}

type HomeData

type HomeData struct {
	Posts    []*Post
	Tweets   []*Post
	Comments []*LatestCommentsByPost

	PostCount    int64
	PageCount    int64
	CommentCount int64
}

HomeData ...

type LatestCommentsByPost

type LatestCommentsByPost struct {
	Post     *Post
	Comments []*Comment
}

LatestCommentsByPost ...

type MetaData

type MetaData struct {
	Title string // 实际上应该为站点标题,但是好像成了文章标题?
}

MetaData ...

type Origin

type Origin proto.Metas_Origin

func (*Origin) PlatformString

func (o *Origin) PlatformString() string

func (*Origin) URL

func (o *Origin) URL() string

type Post

type Post struct {
	*proto.Post
	ID      int64
	Content template.HTML
}

Post ...

func (*Post) CommentString

func (p *Post) CommentString() string

func (*Post) DateString

func (p *Post) DateString() string

DateString ...

func (*Post) GeoString

func (d *Post) GeoString() string

func (*Post) ModifiedString

func (p *Post) ModifiedString() string

ModifiedString ...

func (*Post) Origin

func (d *Post) Origin() *Origin

func (*Post) OriginClass

func (d *Post) OriginClass() string

func (*Post) Outdated

func (p *Post) Outdated() bool

func (*Post) StatusString

func (p *Post) StatusString() string

返回文章的公开状态字符串。

func (*Post) TagsString

func (p *Post) TagsString() template.HTML

TagsString ...

func (*Post) Wide

func (p *Post) Wide() bool

是否开启宽屏?

type PostData

type PostData struct {
	Post     *Post
	Comments []*proto.Comment
}

PostData ...

func (*PostData) CommentsAsJsonArray

func (d *PostData) CommentsAsJsonArray() template.JS

type PostsData

type PostsData struct {
	Posts        []*Post
	PostCount    int64
	PageCount    int64
	CommentCount int64
	ViewCount    int64
}

PostsData ...

type SearchData

type SearchData struct {
	Initialized bool
	Posts       []*SearchPost
}

SearchData ...

type SearchPost

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

func (*SearchPost) Content

func (p *SearchPost) Content() template.HTML

func (*SearchPost) Id

func (p *SearchPost) Id() int

func (*SearchPost) Title

func (p *SearchPost) Title() template.HTML

type TagData

type TagData struct {
	Names []string
	Posts []*Post
}

TagData ...

type TagsData

type TagsData struct {
	Tags []*models.TagWithCount
}

TagsData ...

type TweetsData

type TweetsData struct {
	Name   string
	Tweets []*Post
	Count  int
}

Jump to

Keyboard shortcuts

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