Documentation ¶
Index ¶
- Constants
- type Comment
- type Data
- func NewDataForHome(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, ...) *Data
- func NewDataForPost(ctx context.Context, cfg *config.Config, user *auth.User, ...) *Data
- func NewDataForPosts(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, ...) *Data
- func NewDataForSearch(ctx context.Context, cfg *config.Config, user *auth.User, ...) *Data
- func NewDataForTag(ctx context.Context, cfg *config.Config, service proto.TaoBlogServer, ...) *Data
- func NewDataForTags(ctx context.Context, cfg *config.Config, user *auth.User, ...) *Data
- func NewDataForTweets(ctx context.Context, cfg *config.Config, svc proto.TaoBlogServer) *Data
- func (d *Data) Author() string
- func (d *Data) BodyClass() string
- func (d *Data) ExecutePartial(t *template.Template, partial any) error
- func (d *Data) Info() (*proto.GetInfoResponse, error)
- func (d *Data) Partial() (any, error)
- func (d *Data) SiteName() string
- func (d *Data) Strip(obj any) (any, error)
- func (d *Data) Title() string
- func (d *Data) TweetName() string
- type ErrorData
- type HomeData
- type LatestCommentsByPost
- type MetaData
- type Origin
- type Post
- func (p *Post) CommentString() string
- func (p *Post) DateString() string
- func (d *Post) GeoString() string
- func (p *Post) ModifiedString() string
- func (d *Post) Origin() *Origin
- func (d *Post) OriginClass() string
- func (p *Post) Outdated() bool
- func (p *Post) StatusString() string
- func (p *Post) TagsString() template.HTML
- func (p *Post) Wide() bool
- type PostData
- type PostsData
- type SearchData
- type SearchPost
- type TagData
- type TagsData
- type TweetsData
Constants ¶
View Source
const TweetName = `碎碎念`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 (*Data) ExecutePartial ¶
type HomeData ¶
type HomeData struct { Posts []*Post Tweets []*Post Comments []*LatestCommentsByPost PostCount int64 PageCount int64 CommentCount int64 }
HomeData ...
type LatestCommentsByPost ¶
LatestCommentsByPost ...
type PostsData ¶
type PostsData struct { Posts []*Post PostCount int64 PageCount int64 CommentCount int64 ViewCount int64 }
PostsData ...
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 TweetsData ¶
Click to show internal directories.
Click to hide internal directories.