model

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package model is the "model" layer which defines entity structures with ORM and controller.

Index

Constants

View Source
const (
	CorrelationCategoryTag = iota
	CorrelationArticleTag
	CorrelationBlogUser
	CorrelationArticleArchive
)

Correlation types.

View Source
const (
	NavigationOpenMethodBlank = "_blank"
	NavigationOpenMethodSelf  = "_self"
)

Navigation open methods.

View Source
const (
	SettingCategorySystem = "system"

	SettingNameSystemVer = "systemVersion"
)

Setting names of category "system".

View Source
const (
	SettingCategoryTheme = "theme"

	SettingNameThemeName = "themeName"
)

Setting names of category "theme".

View Source
const (
	SettingCategoryBasic = "basic"

	SettingNameBasicBlogURL         = "basicBlogURL"
	SettingNameBasicBlogSubtitle    = "basicBlogSubtitle"
	SettingNameBasicBlogTitle       = "basicBlogTitle"
	SettingNameBasicCommentable     = "basicCommentable"
	SettingNameBasicFooter          = "basicFooter"
	SettingNameBasicHeader          = "basicHeader" // Removed from UI since v1.1.0 caused by issue 54 (https://github.com/b3log/pipe/issues/54)
	SettingNameBasicNoticeBoard     = "basicNoticeBoard"
	SettingNameBasicMetaDescription = "basicMetaDescription"
	SettingNameBasicMetaKeywords    = "basicMetaKeywords"
	SettingNameBasicFaviconURL      = "basicFaviconURL"
	SettingNameBasicLogoURL         = "basicLogoURL"
)

Setting names of category "basic".

View Source
const (
	SettingBasicFooterDefault           = "<!-- 这里可用于放置备案信息等,支持 Markdown -->"
	SettingBasicHeaderDefault           = "<!-- https://github.com/b3log/pipe/issues/54 -->"
	SettingBasicBasicNoticeBoardDefault = "<!-- 支持 Markdown -->本博客由 [Pipe](https://github.com/b3log/pipe) 强力驱动"
)

Setting values of category "basic".

View Source
const (
	SettingCategoryPreference = "preference"

	SettingNamePreferenceArticleListPageSize        = "preferenceArticleListPageSize"
	SettingNamePreferenceArticleListWindowSize      = "preferenceArticleListWindowSize"
	SettingNamePreferenceArticleListStyle           = "preferenceArticleListStyle"
	SettingNamePreferenceMostCommentArticleListSize = "preferenceMostCommentArticleListSize"
	SettingNamePreferenceMostUseTagListSize         = "preferenceMostUseTagListSize"
	SettingNamePreferenceMostViewArticleListSize    = "preferenceMostViewArticleListSize"
	SettingNamePreferenceRecentCommentListSize      = "preferenceRecentCommentListSize"
)

Setting names of category "preference".

View Source
const (
	SettingPreferenceArticleListStyleValueTitle         = 0
	SettingPreferenceArticleListStyleValueTitleAbstract = 1
	SettingPreferenceArticleListStyleValueTitleContent  = 2

	SettingPreferenceArticleListPageSizeDefault        = 20
	SettingPreferenceArticleListWindowSizeDefault      = 7
	SettingPreferenceArticleListStyleDefault           = SettingPreferenceArticleListStyleValueTitleAbstract
	SettingPreferenceMostCommentArticleListSizeDefault = 7
	SettingPreferenceMostUseTagListSizeDefault         = 15
	SettingPreferenceMostViewArticleListSizeDefault    = 15
	SettingPreferenceRecentCommentListSizeDefault      = 7
)

Setting values of category "preference".

View Source
const (
	SettingCategorySign = "sign"

	SettingNameArticleSign = "signArticle"
)

Setting names of category "sign".

View Source
const (
	SettingCategoryI18n = "i18n"

	SettingNameI18nLocale   = "i18nLocale"
	SettingNameI18nTimezone = "i18nTimezone"
)

Setting names of category "i18n".

View Source
const (
	SettingCategoryFeed = "feed"

	SettingNameFeedOutputMode = "feedOutputMode"
)

Setting names of category "feed".

View Source
const (
	SettingFeedOutputModeValueAbstract = 0
	SettingFeedOutputModeValueFull     = 1
)

Setting values of category "feed".

View Source
const (
	SettingCategoryThirdStatistic = "thirdStatistic"

	SettingNameThirdStatisticBaidu = "thirdStatisticBaidu"
)

Setting names of category "thirdStatistic".

View Source
const (
	SettingCategoryStatistic = "statistic"

	SettingNameStatisticArticleCount = "statisticArticleCount"
	SettingNameStatisticCommentCount = "statisticCommentCount"
	SettingNameStatisticViewCount    = "statisticViewCount"
)

Setting names of category "statistic".

View Source
const (
	UserRoleNoLogin = iota
	UserRolePlatformAdmin
	UserRoleBlogAdmin
	UserRoleBlogUser
)

User roles.

View Source
const (
	ArticleStatusOK = iota
)

Article statuses.

View Source
const (
	SettingArticleSignDefault = "<!-- 支持 Markdown;可用变量 {title}, {author}, {url} -->"
)

Setting values of category "sign".

View Source
const SyncCommentAuthorID = math.MaxInt32

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	Model

	Year         string `gorm:"size:4" json:"year"`
	Month        string `gorm:"size:2" json:"month"`
	ArticleCount int    `json:"articleCount"`

	BlogID uint64 `sql:"index" json:"blogID"`
}

Archive model.

type Article

type Article struct {
	Model

	AuthorID     uint64    `json:"authorID"`
	Title        string    `gorm:"size:128" json:"title"`
	Tags         string    `gorm:"type:text" json:"tags"`
	Content      string    `gorm:"type:mediumtext" json:"content"`
	Path         string    `sql:"index" gorm:"size:255" json:"path"`
	Status       int       `sql:"index" json:"status"`
	Topped       bool      `json:"topped"`
	Commentable  bool      `json:"commentable"`
	ViewCount    int       `json:"viewCount"`
	CommentCount int       `json:"commentCount"`
	IP           string    `gorm:"size:128" json:"ip"`
	UserAgent    string    `gorm:"size:255" json:"userAgent"`
	PushedAt     time.Time `json:"pushedAt"`

	BlogID uint64 `sql:"index" json:"blogID"`
}

Article model.

type Category

type Category struct {
	Model

	Title           string `gorm:"size:128" json:"title"`
	Path            string `gorm:"size:255" json:"path"`
	Description     string `gorm:"size:255" json:"description"`
	MetaKeywords    string `gorm:"size:255" json:"metaKeywords"`
	MetaDescription string `gorm:"type:text" json:"metaDescription"`
	Tags            string `gorm:"type:text" json:"tags"`
	Number          int    `json:"number"` // for sorting

	BlogID uint64 `sql:"index" json:"blogID"`
}

Category model.

type Comment

type Comment struct {
	Model

	ArticleID       uint64    `json:"articleID"`
	AuthorID        uint64    `json:"authorID"`
	Content         string    `gorm:"type:text" json:"content"`
	ParentCommentID uint64    `json:"parentCommentID"` // ID of replied comment
	IP              string    `gorm:"size:128" json:"ip"`
	UserAgent       string    `gorm:"size:255" json:"userAgent"`
	PushedAt        time.Time `json:"pushedAt"`

	AuthorName      string `gorm:"size:32" json:"authorName"`       // exist if this comment sync from Sym, https://github.com/b3log/pipe/issues/98
	AuthorAvatarURL string `gorm:"size:255" json:"authorAvatarURL"` // exist if this comment sync from Sym, https://github.com/b3log/pipe/issues/98
	AuthorURL       string `gorm:"size:255" json:"authorURL"`       // exist if this comment sync from Sym, https://github.com/b3log/pipe/issues/98

	BlogID uint64 `sql:"index" json:"blogID"`
}

Comment model.

type Correlation

type Correlation struct {
	Model

	ID1  uint64 `json:"id1"`
	ID2  uint64 `json:"id2"`
	Str1 string `gorm:"size:255" json:"str1"`
	Str2 string `gorm:"size:255" json:"str2"`
	Str3 string `gorm:"size:255" json:"str3"`
	Str4 string `gorm:"size:255" json:"str4"`
	Int1 int    `json:"int1"`
	Int2 int    `json:"int2"`
	Int3 int    `json:"int3"`
	Int4 int    `json:int4`
	Type int    `json:"type"`

	BlogID uint64 `sql:"index" json:"blogID"`
}

Correlation model.

id1(category_id) - id2(tag_id)
id1(article_id) - id2(tag_id)
id1(blog_id) - id2(user_id) - int1(role) - int2(article_count)
id1(article_id) - id2(archive_id)

type Model

type Model struct {
	ID        uint64     `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt"`
}
type Navigation struct {
	Model

	Title      string `gorm:"size:128" json:"title"`
	URL        string `gorm:"size:255" json:"url"`
	IconURL    string `gorm:"size:255" json:"iconURL"`
	OpenMethod string `gorm:"size:32" json:"openMethod"`
	Number     int    `json:"number"` // for sorting

	BlogID uint64 `sql:"index" json:"blogID"`
}

Navigation model.

type Setting

type Setting struct {
	Model

	Category string `sql:"index" gorm:"size:32" json:"category"`
	Name     string `sql:"index" gorm:"size:64" json:"name"`
	Value    string `gorm:"type:text" json:"value"`

	BlogID uint64 `sql:"index" json:"blogID"`
}

Setting model.

type Tag

type Tag struct {
	Model

	Title        string `gorm:"size:128" json:"title"`
	ArticleCount int    `json:"articleCount"`

	BlogID uint64 `sql:"index" json:"blogID"`
}

Tag model.

type ThemeArchive

type ThemeArchive struct {
	Title        string
	URL          string
	ArticleCount int
}

type ThemeArticle

type ThemeArticle struct {
	ID           uint64        `json:",omitempty"`
	Abstract     template.HTML `json:"abstract"`
	Author       *ThemeAuthor  `json:",omitempty"`
	CreatedAt    string        `json:",omitempty"`
	Title        string        `json:"title"`
	Tags         []*ThemeTag   `json:"tags"`
	URL          string        `json:"url"`
	Topped       bool          `json:",omitempty"`
	ViewCount    int           `json:",omitempty"`
	CommentCount int           `json:",omitempty"`
	ThumbnailURL string        `json:",omitempty"`
	Content      template.HTML `json:",omitempty"`
	Editable     bool          `json:",omitempty"`
}

type ThemeAuthor

type ThemeAuthor struct {
	Name         string
	AvatarURL    string
	URL          string
	ArticleCount int
}

func (*ThemeAuthor) AvatarURLWithSize

func (author *ThemeAuthor) AvatarURLWithSize(size int) string

type ThemeCategory

type ThemeCategory struct {
	Title        string
	URL          string
	Description  string
	Tags         []*ThemeTag
	ArticleCount int
}

type ThemeComment

type ThemeComment struct {
	ID         uint64
	Title      string
	Content    template.HTML
	URL        string
	Author     *ThemeAuthor
	CreatedAt  string
	Removable  bool
	ReplyCount int
	Parent     *ThemeComment
}

type ThemeReply

type ThemeReply struct {
	ID        uint64
	Content   template.HTML
	URL       string
	Author    *ThemeAuthor
	CreatedAt string
}

type ThemeTag

type ThemeTag struct {
	Title        string `json:"title"`
	URL          string `json:"url"`
	ArticleCount int    `json:",omitempty"`
}

type User

type User struct {
	Model

	Name              string `gorm:"size:32" json:"name"`
	Nickname          string `gorm:"size:32" json:"nickname"`
	AvatarURL         string `gorm:"size:255" json:"avatarURL"`
	B3Key             string `gorm:"size:32" json:"b3Key"`
	Locale            string `gorm:"size:32 json:"locale"`
	TotalArticleCount int    `json:"totalArticleCount"`
}

User model.

func (*User) AvatarURLWithSize

func (u *User) AvatarURLWithSize(size int) string

Jump to

Keyboard shortcuts

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