~huyngo/yue

45342cbd397f7cfc76a0aa06926169a7afa59fc3 — Huy Ngo 2 years ago 261b5ce
Add post-related structs
1 files changed, 56 insertions(+), 4 deletions(-)

M structs.go
M structs.go => structs.go +56 -4
@@ 1,6 1,8 @@
package main

import (
	"time"

	"github.com/leonelquinteros/gotext"
)



@@ 11,6 13,7 @@ type RequestContext struct {
	Setting  *Preference
	LoggedIn *User
	Yue      *Meta
	Data     interface{}
}

type PageData struct {


@@ 22,17 25,65 @@ type Preference struct {
	Theme string
}

type TimelinePage struct {
	Name  string
	Posts []Post
	Next  string
}

type Post struct {
	Id        int
	Title     string
	Content   string
	Author    User
	Comm      Community
	Created   time.Time
	Local     bool
	Instance  string
	RemoteURL string
	Score     int
	Sticky    bool
	Comments  []Comment
}

type Comment struct {
	Id              int
	Content         string
	Author          User
	Created         time.Time
	Local           bool
	Instance        string
	RemoteURL       string
	Score           int
	PostId          int
	ParentCommentId int
	Replies         []Comment
}

type Community struct {
	Id        int
	Name      string
	Local     bool
	Instance  string
	RemoteURL string
}

type User struct {
	Id       int
	Username string
	Id        int
	Username  string
	Bot       bool
	AvatarURL string
	Local     bool
	Instance  string
	RemoteURL string
}

type Meta struct {
	Version   string
	Version string
}

func CreateRequestContext(lang string, title string,
	description string, theme string) RequestContext {
	description string, theme string, data interface{}) RequestContext {
	if lang == "" {
		lang = gotext.GetLanguage()
	}


@@ 50,5 101,6 @@ func CreateRequestContext(lang string, title string,
		Setting:  &setting,
		LoggedIn: nil,
		Yue:      &meta,
		Data:     data,
	}
}