model

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Package util defines variety of utilities.

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 (
	SettingCategoryAd = "ad"

	SettingNameAdGoogleAdSenseArticleEmbed = "adGoogleAdSenseArticleEmbed"
)

Setting names of category "ad".

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

SyncCommentAuthorID is the id of sync comment bot.

View Source
const Version = "1.8.5"

Version of Pipe.

Variables

View Source
var Models = []interface{}{
	&User{}, &Article{}, &Comment{}, &Navigation{}, &Tag{},
	&Category{}, &Archive{}, &Setting{}, &Correlation{},
}

Models represents all models..

View Source
var UserAgent = "Pipe/" + Version + "; +https://github.com/b3log/pipe"

UserAgent represents HTTP client user agent.

View Source
var ZeroPushTime, _ = time.Parse("2006-01-02 15:04:05", "2006-01-02 15:04:05")

ZeroPushTime represents zero push time.

Functions

func LoadConf added in v1.7.0

func LoadConf()

LoadConf loads the configurations. Command-line arguments will override configuration file.

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" structs:"authorID"`
	Title        string    `gorm:"size:128" json:"title" structs:"title"`
	Abstract     string    `gorm:"type:mediumtext" json:"abstract" structs:"abstract"`
	Tags         string    `gorm:"type:text" json:"tags" structs:"tags"`
	Content      string    `gorm:"type:mediumtext" json:"content" structs:"content"`
	Path         string    `sql:"index" gorm:"size:255" json:"path" structs:"path"`
	Status       int       `sql:"index" json:"status" structs:"status"`
	Topped       bool      `json:"topped" structs:"topped"`
	Commentable  bool      `json:"commentable" structs:"commentable"`
	ViewCount    int       `json:"viewCount" structs:"viewCount"`
	CommentCount int       `json:"commentCount" structs:"commentCount"`
	IP           string    `gorm:"size:128" json:"ip" structs:"ip"`
	UserAgent    string    `gorm:"size:255" json:"userAgent" structs:"userAgent"`
	PushedAt     time.Time `json:"pushedAt" structs:"pushedAt"`

	BlogID uint64 `sql:"index" json:"blogID" structs:"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 Configuration added in v1.7.0

type Configuration struct {
	Server                string // server scheme, host and port
	StaticServer          string // static resources server scheme, host and port
	StaticResourceVersion string // version of static resources
	OpenRegister          bool   // whether open register
	LogLevel              string // logging level: trace/debug/info/warn/error/fatal
	ShowSQL               bool   // whether print sql in log
	SessionSecret         string // HTTP session secret
	SessionMaxAge         int    // HTTP session max age (in seciond)
	RuntimeMode           string // runtime mode (dev/prod)
	SQLite                string // SQLite database file path
	MySQL                 string // MySQL connection URL
	StaticRoot            string // static resources file root path
	Port                  string // listen port
	AxiosBaseURL          string // axio base URL
	MockServer            string // mock server
}

Configuration (pipe.json).

var Conf *Configuration

Conf of Pipe.

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" structs:"id"`
	CreatedAt time.Time  `json:"createdAt" structs:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt" structs:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt" structs:"deletedAt"`
}

Model represents meta data of entity.

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
}

ThemeArchive represents theme archive.

type ThemeArticle

type ThemeArticle struct {
	ID             uint64        `json:",omitempty"`
	Abstract       template.HTML `json:"abstract"`
	Author         *ThemeAuthor  `json:",omitempty"`
	CreatedAt      string        `json:",omitempty"`
	CreatedAtYear  string        `json:",omitempty"`
	CreatedAtMonth string        `json:",omitempty"`
	CreatedAtDay   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"`
}

ThemeArticle represents theme article.

type ThemeAuthor

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

ThemeAuthor represents theme author.

func (*ThemeAuthor) AvatarURLWithSize

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

AvatarURLWithSize returns avatar URL with the specified size.

type ThemeCategory

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

ThemeCategory represents theme category.

type ThemeComment

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

ThemeComment represents theme comment.

type ThemeReply

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

ThemeReply represents theme reply.

type ThemeTag

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

ThemeTag represents theme tag.

type User

type User struct {
	Model

	Name              string `gorm:"size:32" json:"name"`
	Password          string `gorm:"size:255" json:"password"` // https://github.com/b3log/pipe/issues/130
	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"`
	GithubId          string `gorm:"255" json:"githubId"` // 支持 GitHub 登录 https://github.com/b3log/pipe/issues/150
}

User model.

func (*User) AvatarURLWithSize

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

AvatarURLWithSize returns avatar URL with the specified size.

Jump to

Keyboard shortcuts

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