nut

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NOTICE notice
	NOTICE = "notice"
	// WARNING warning
	WARNING = "warning"
	// ERROR error
	ERROR = "error"

	// TITLE title
	TITLE = "title"
	// CurrentUser current user
	CurrentUser = "currentUser"
	// IsAdmin is admin?
	IsAdmin = "isAdmin"
)
View Source
const (
	// RoleAdmin admin role
	RoleAdmin = "admin"
	// RoleRoot root role
	RoleRoot = "root"
	// UserTypeEmail email user
	UserTypeEmail = "email"

	// DefaultResourceType default resource type
	DefaultResourceType = ""
	// DefaultResourceID default resourc id
	DefaultResourceID = 0
)
View Source
const (

	// SendEmailJob send email
	SendEmailJob = "send.email"
)

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(ca bool, subject pkix.Name, years int) ([]byte, []byte, error)

CreateCertificate create certs

func Languages

func Languages() []string

Languages languages

func WritePemFile

func WritePemFile(file, _type string, buf []byte, mode os.FileMode) error

WritePemFile wirte to a pem format file

Types

type AdminPlugin

type AdminPlugin struct {
	I18n     *web.I18n     `inject:""`
	Cache    *web.Cache    `inject:""`
	Jobber   *web.Jobber   `inject:""`
	Router   *gin.Engine   `inject:""`
	Settings *web.Settings `inject:""`
	DB       *pg.DB        `inject:""`
	Redis    *redis.Pool   `inject:""`
	Dao      *Dao          `inject:""`
	Layout   *Layout       `inject:""`
}

AdminPlugin admin plugin

func (*AdminPlugin) Init

func (p *AdminPlugin) Init(*inject.Graph) error

Init init beans

func (*AdminPlugin) Mount

func (p *AdminPlugin) Mount() error

Mount register

func (*AdminPlugin) Shell

func (p *AdminPlugin) Shell() []cli.Command

Shell console commands

type Attachment

type Attachment struct {
	ID           uint      `json:"id"`
	Title        string    `json:"title"`
	URL          string    `json:"url"`
	Length       int64     `json:"length"`
	MediaType    string    `json:"mediaType"`
	ResourceID   uint      `json:"resourceId" sql:",notnull"`
	ResourceType string    `json:"resourceType" sql:",notnull"`
	User         User      `json:"user"`
	UserID       uint      `json:"userId"`
	UpdatedAt    time.Time `json:"updatedAt"`
	CreatedAt    time.Time `json:"crateAt"`
	// contains filtered or unexported fields
}

Attachment attachment

func (*Attachment) IsPicture

func (p *Attachment) IsPicture() bool

IsPicture is picture?

type AttachmentsPlugin

type AttachmentsPlugin struct {
	UEditor *web.UEditor `inject:""`
	I18n    *web.I18n    `inject:""`
	Cache   *web.Cache   `inject:""`
	Router  *gin.Engine  `inject:""`
	DB      *pg.DB       `inject:""`
	Layout  *Layout      `inject:""`
	S3      *web.S3      `inject:""`
	Jwt     *web.Jwt     `inject:""`
}

AttachmentsPlugin attachments plugin

func (*AttachmentsPlugin) Init

func (p *AttachmentsPlugin) Init(*inject.Graph) error

Init init beans

func (*AttachmentsPlugin) Mount

func (p *AttachmentsPlugin) Mount() error

Mount register

func (*AttachmentsPlugin) Shell

func (p *AttachmentsPlugin) Shell() []cli.Command

Shell console commands

type Card

type Card struct {
	ID        uint      `json:"id"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	Title     string    `json:"title"`
	Summary   string    `json:"summary"`
	Type      string    `json:"type"`
	Href      string    `json:"href"`
	SortOrder int       `json:"sortOrder" sql:",notnull"`
	Action    string    `json:"action"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Card card

type Dao

type Dao struct {
	DB       *pg.DB        `inject:""`
	I18n     *web.I18n     `inject:""`
	Security *web.Security `inject:""`
}

Dao dao

func (*Dao) AddEmailUser

func (p *Dao) AddEmailUser(tx *pg.Tx, name, email, password string) (*User, error)

AddEmailUser add email user

func (*Dao) AddLog

func (p *Dao) AddLog(tx *pg.Tx, user uint, ip, lang, format string, args ...interface{}) error

AddLog add log

func (*Dao) Allow

func (p *Dao) Allow(tx *pg.Tx, user uint, name, rty string, rid uint, years, months, days int) error

Allow allow

func (*Dao) Can

func (p *Dao) Can(user uint, name, rty string, rid uint) bool

Can can?

func (*Dao) Deny

func (p *Dao) Deny(tx *pg.Tx, user uint, name, rty string, rid uint) error

Deny deny

func (*Dao) Is

func (p *Dao) Is(user uint, role string) bool

Is is role?

func (*Dao) SignIn

func (p *Dao) SignIn(lang, ip, email, password string) (*User, error)

SignIn sign in

type FriendLink struct {
	ID        uint      `json:"id"`
	Title     string    `json:"title"`
	Home      string    `json:"home"`
	SortOrder int       `json:"sortOrder"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

FriendLink friend_links

type HomePlugin

type HomePlugin struct {
	I18n     *web.I18n     `inject:""`
	Cache    *web.Cache    `inject:""`
	Jwt      *web.Jwt      `inject:""`
	Router   *gin.Engine   `inject:""`
	Jobber   *web.Jobber   `inject:""`
	Settings *web.Settings `inject:""`
	DB       *pg.DB        `inject:""`
	Dao      *Dao          `inject:""`
	Layout   *Layout       `inject:""`
}

HomePlugin admin plugin

func (*HomePlugin) Init

func (p *HomePlugin) Init(g *inject.Graph) error

Init init beans

func (*HomePlugin) Mount

func (p *HomePlugin) Mount() error

Mount register

func (*HomePlugin) Shell

func (p *HomePlugin) Shell() []cli.Command

Shell console commands

type Layout

type Layout struct {
	Settings *web.Settings `inject:""`
	I18n     *web.I18n     `inject:""`
	Jwt      *web.Jwt      `inject:""`
	DB       *pg.DB        `inject:""`
	Dao      *Dao          `inject:""`
	Router   *gin.Engine   `inject:""`
}

Layout layout

func (*Layout) Abort

func (p *Layout) Abort(c *gin.Context, s int, e error)

Abort abort error

func (*Layout) Application

func (p *Layout) Application(tpl string, fn func(string, gin.H, *gin.Context) error) gin.HandlerFunc

Application application layout

func (*Layout) CurrentUserMiddleware

func (p *Layout) CurrentUserMiddleware(c *gin.Context)

CurrentUserMiddleware currend user middleware

func (*Layout) Home

func (p *Layout) Home(req *http.Request) string

Home home url

func (*Layout) JSON

func (p *Layout) JSON(fn func(string, *gin.Context) (interface{}, error)) gin.HandlerFunc

JSON render json

func (*Layout) MustAdminMiddleware

func (p *Layout) MustAdminMiddleware(c *gin.Context)

MustAdminMiddleware currend user middleware

func (*Layout) MustSignInMiddleware

func (p *Layout) MustSignInMiddleware(c *gin.Context)

MustSignInMiddleware currend user middleware

func (*Layout) Redirect

func (p *Layout) Redirect(to string, fn func(string, *gin.Context) error) gin.HandlerFunc

Redirect redirect

func (*Layout) UEditor

func (p *Layout) UEditor(act string, check func(*User, uint) bool, edit func(uint, string) (string, string, error), update func(uint, string) error)

UEditor ueditor edit

func (*Layout) XML

func (p *Layout) XML(fn func(string, *gin.Context) (interface{}, error)) gin.HandlerFunc

XML render xml

type LeaveWord

type LeaveWord struct {
	ID        uint      `json:"id"`
	Body      string    `json:"body"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

LeaveWord leave-word

type Link struct {
	ID        uint      `json:"id"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	Href      string    `json:"href"`
	Label     string    `json:"label"`
	SortOrder int       `json:"sortOrder"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Link link

type Log

type Log struct {
	ID        uint      `json:"id"`
	Message   string    `json:"message"`
	IP        string    `json:"ip"`
	User      *User     `json:"user"`
	UserID    uint      `json:"userId"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Log log

func (Log) String

func (p Log) String() string

type Policy

type Policy struct {
	ID        uint
	Begin     time.Time `sql:"_begin"`
	End       time.Time `sql:"_end"`
	User      *User
	UserID    uint
	Role      *Role
	RoleID    uint
	UpdatedAt time.Time
	CreatedAt time.Time
	// contains filtered or unexported fields
}

Policy policy

func (*Policy) Enable

func (p *Policy) Enable() bool

Enable is enable?

type Role

type Role struct {
	ID           uint
	Name         string
	ResourceID   uint   `sql:",notnull"`
	ResourceType string `sql:",notnull"`
	UpdatedAt    time.Time
	CreatedAt    time.Time
	// contains filtered or unexported fields
}

Role role

func (Role) String

func (p Role) String() string

type User

type User struct {
	ID              uint       `json:"id"`
	Name            string     `json:"name"`
	Email           string     `json:"email"`
	UID             string     `json:"uid"`
	Password        []byte     `json:"-"`
	ProviderID      string     `json:"providerId"`
	ProviderType    string     `json:"providerType"`
	SignInCount     uint       `json:"signInCount"`
	LastSignInAt    *time.Time `json:"lastSignInAt"`
	LastSignInIP    string     `json:"lastSignInIp"`
	CurrentSignInAt *time.Time `json:"currentSignInAt"`
	CurrentSignInIP string     `json:"currentSignInIp"`
	ConfirmedAt     *time.Time `json:"confirmedAt"`
	LockedAt        *time.Time `json:"lockAt"`
	Logs            []Log      `json:"logs"`
	UpdatedAt       time.Time  `json:"updatedAt"`
	CreatedAt       time.Time  `json:"createdAt"`
	// contains filtered or unexported fields
}

User user

func (*User) IsConfirm

func (p *User) IsConfirm() bool

IsConfirm is confirm?

func (*User) IsLock

func (p *User) IsLock() bool

IsLock is lock?

func (p *User) SetGravatarLogo()

SetGravatarLogo set logo by gravatar

func (*User) SetUID

func (p *User) SetUID()

SetUID generate uid

func (User) String

func (p User) String() string

type UsersPlugin

type UsersPlugin struct {
	I18n     *web.I18n     `inject:""`
	Cache    *web.Cache    `inject:""`
	Router   *gin.Engine   `inject:""`
	Jobber   *web.Jobber   `inject:""`
	Settings *web.Settings `inject:""`
	Security *web.Security `inject:""`
	Jwt      *web.Jwt      `inject:""`
	DB       *pg.DB        `inject:""`
	Dao      *Dao          `inject:""`
	Layout   *Layout       `inject:""`
}

UsersPlugin admin plugin

func (*UsersPlugin) Init

func (p *UsersPlugin) Init(*inject.Graph) error

Init init beans

func (*UsersPlugin) Mount

func (p *UsersPlugin) Mount() error

Mount register

func (*UsersPlugin) Shell

func (p *UsersPlugin) Shell() []cli.Command

Shell console commands

type Vote

type Vote struct {
	ID           uint
	Point        int
	ResourceID   uint
	ResourceType string
	UpdatedAt    time.Time
	CreatedAt    time.Time
	// contains filtered or unexported fields
}

Vote vote

Jump to

Keyboard shortcuts

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