web

package
v0.0.0-...-7aa88fd Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const UserCookieNamePrefix = "user."

Variables

This section is empty.

Functions

func MarkdownToHTML

func MarkdownToHTML(d string) template.HTML

func StringListJoin

func StringListJoin(strList model.StringList) string

func TimeDay

func TimeDay(t time.Time) int

func TimeMonth

func TimeMonth(t time.Time) string

func TimeYear

func TimeYear(t time.Time) int

Types

type Controller

type Controller struct {
}

func (*Controller) Error

func (ctr *Controller) Error(c *gin.Context, msg string)

func (*Controller) GetParamInt

func (*Controller) GetParamInt(c *gin.Context, key string, defVal ...int) (int, bool)

GetParamInt 从路由参数中返回 key 对应的值 规则与 GetQueryInt() 函数相同

func (*Controller) GetQueryInt

func (*Controller) GetQueryInt(c *gin.Context, key string, defVal ...int) (int, bool)

GetQueryInt 返回查询参数中 key 对应的值 如果找不到 key 或者 key 的值不是有效数值,则返回的第2个参数返回 false 可以指定 defVal 参数作为默认值返回

func (*Controller) JsonFail

func (*Controller) JsonFail(c *gin.Context, errMsg string, errCode int)

func (*Controller) JsonSuccess

func (*Controller) JsonSuccess(c *gin.Context, data interface{})

func (Controller) NewTemplate

func (ctr Controller) NewTemplate(path string) *Template

NewTemplate 返回一个 Template `path` 不需要包含 模板主题名

func (Controller) Response

func (ctr Controller) Response(c *gin.Context, tpl *Template)

func (*Controller) Success

func (ctr *Controller) Success(c *gin.Context, msg string)

type Pagination

type Pagination struct {
	Request *http.Request
	Total   int
	Pernum  int
}

Pagination 分页器

func NewPagination

func NewPagination(req *http.Request, total int, pernum int) *Pagination

NewPagination 新建分页器

func (*Pagination) Pages

func (p *Pagination) Pages() string

Pages 渲染生成html分页标签

type Post

type Post struct {
	Controller
}

func (Post) Detail

func (ctr Post) Detail(c *gin.Context)

func (Post) DetailForPage

func (ctr Post) DetailForPage(c *gin.Context)

func (Post) Form

func (ctr Post) Form(c *gin.Context)

func (Post) Index

func (ctr Post) Index(c *gin.Context)

func (Post) Remove

func (ctr Post) Remove(c *gin.Context)

func (Post) Save

func (ctr Post) Save(c *gin.Context)

func (Post) TagPosts

func (ctr Post) TagPosts(c *gin.Context)

type SiteParameter

type SiteParameter struct {
	Controller
}

func (SiteParameter) Form

func (ctr SiteParameter) Form(c *gin.Context)

func (SiteParameter) Save

func (ctr SiteParameter) Save(c *gin.Context)

type Template

type Template struct {
	Site        *model.SiteParameter
	Path        string // 要使用的模板路径
	Title       string // 页面 title 标签
	Keywords    string // 页面 meta 标签: Keywords
	Description string // 页面 meta 标签: Description
	Author      string // 页面 meta 标签: Author
	IsLoggedIn  bool   // 当前用户是否已登录
	Data        gin.H
}

type User

type User struct {
	Controller
}

func (User) Login

func (ctr User) Login(c *gin.Context)

func (User) LoginForm

func (ctr User) LoginForm(c *gin.Context)

func (User) Logout

func (ctr User) Logout(c *gin.Context)

func (User) ResetPassword

func (ctr User) ResetPassword(c *gin.Context)

func (User) ResetPasswordForm

func (ctr User) ResetPasswordForm(c *gin.Context)

Jump to

Keyboard shortcuts

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