blog

package
v0.0.0-...-da8a449 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_CONFIG_FILENAME = "app.conf"
	APP_DEFAULT_CONFIG  = "app.default.conf"
)
View Source
const (
	Everyone          PerType = 1 << 0                            //访客             001
	Authenticated             = 1 << 1                            //已登陆           010
	AdministratorOnly         = 1 << 2                            //管理员           100
	Administrator             = AdministratorOnly | Authenticated //管理员也要已登陆 110
)
View Source
const (
	BASEHTML  = "base.html"
	ADMINHTML = "admin/base.html"
)

两个基础模版

View Source
const INVALID_VALUE = 0xFFFFFFFF

Variables

View Source
var (
	// 能被上传的文件扩展名
	IMAGES_EXT = []string{".jpg", ".jpeg", ".gif", ".png", ".bmp"}
)
View Source
var QQwryData *qqwry.QQWry

全局 纯真ip数据库

Functions

func StartBlogServer

func StartBlogServer()

启动服务

Types

type AppSvrConf

type AppSvrConf struct {
	Port       int    `json:"port"`
	DB         string `json:"database"`
	SessionKey string `json:"sessionkey"`
	WebSite    string `json:"website"`
	UploadPath string `json:"uploadpath"`
}

定义可配置的服务器信息

type ArticleComments

type ArticleComments struct {
	Id        int
	ArticleId int
	Author    string
	Time      time.Time
	Body      string
	IP        string
}

type Handlder

type Handlder struct {
	http.ResponseWriter
	*http.Request
	HTMLFile  string // 渲染的静态文件
	StartTime time.Time
	DB        *MDB //*sql.DB
}

回调的参数类型

func NewHandler

func NewHandler(w http.ResponseWriter, r *http.Request, file string) *Handlder

新建带有请求的handler,在这里可以启动数据库等等操作吧

func (*Handlder) PBool

func (self *Handlder) PBool(key string) bool

func (*Handlder) PEqInt

func (self *Handlder) PEqInt(key string, value int) bool

func (*Handlder) PEqStr

func (self *Handlder) PEqStr(key, value string) bool

func (*Handlder) PEqUInt

func (self *Handlder) PEqUInt(key string, value uint) bool

func (*Handlder) PInt

func (self *Handlder) PInt(key string) int

Post表单中的

func (*Handlder) PStr

func (self *Handlder) PStr(key string) string

func (*Handlder) PUint

func (self *Handlder) PUint(key string) uint

func (*Handlder) QBool

func (self *Handlder) QBool(key string) bool

func (*Handlder) QEqInt

func (self *Handlder) QEqInt(key string, value int) bool

func (*Handlder) QEqStr

func (self *Handlder) QEqStr(key, value string) bool

func (*Handlder) QInt

func (self *Handlder) QInt(key string) int

Query表单中的

func (*Handlder) QStr

func (self *Handlder) QStr(key string) string

func (*Handlder) Redirect

func (self *Handlder) Redirect(url string)

重定向

type HandleFunc

type HandleFunc func(*Handlder)

回调函数

type MDB

type MDB struct {
	*sql.DB
}

重定向,方便写函数, M考虑使用mongdb?

type PerType

type PerType uint

type QueryResultFunc

type QueryResultFunc func(*sql.Rows)

type Route

type Route struct {
	URL        string     // 请求的url地址
	HTMLFile   string     // 渲染的静态文件
	Permission PerType    // 权限
	HandleFunc HandleFunc // 回调函数
}

路由结构体

type TArticle

type TArticle struct {
	Id             int
	Title          string
	Author         string
	CreateTime     time.Time
	LastEditTime   time.Time
	HTMLString     string
	MarkdownString string
	Summary        string
	CategoryId     int
	CategoryName   string
	IsPublic       bool
}

文章信息结构

type TArticleMsg

type TArticleMsg struct {
	TMessage
	InsertId int64 `json:"id"`
}

type TCategory

type TCategory struct {
	Id   int
	Name string
}

分类

type TMessage

type TMessage struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type TRSSItem

type TRSSItem struct {
	Id     int
	Title  string
	Author string
	// link省略掉
	Description string
	Comments    string
	PubDate     time.Time
}

type TSessions

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

新建一个类型,继承sessions.CookieStore

type TStatistic

type TStatistic struct {
	Id             int
	URL            string
	RefererHost    string
	Time           time.Time
	Platform       string
	OS             string
	BrowserName    string
	BrowserVersion string
	IP             string
	Location       string
}

查询的信息,

type TitlesTop

type TitlesTop struct {
	Id    int
	Title string
}

文章标题信息

type User

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

用户信息

Jump to

Keyboard shortcuts

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