summer

package module
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2017 License: MIT Imports: 23 Imported by: 0

README

Summer panel

Simple control panel for Golang based on Gin framework and MongoDB

How To Install

go get -u gopkg.in/night-codes/summer.v1/...

Getting Started

  1. Create new project with demo-modules:
summerGen project --name myProject --title="My project" --db "project" --port=8080 --views="templates/main" --views-dot="templates/dot" --demo
  1. Create new module:
cd myProject/
summerGen module --name tasks --title="My tasks" --menu=MainMenu --add-sort --add-search --add-pages --add-tabs
  1. Start project
go build
./myProject
Result:

summer

or with another design theme: summer2

Examples

Coming soon...

People

Author and developer is Oleksiy Chechel

License

MIT License

Copyright (C) 2016-2017 Oleksiy Chechel (alex.mirrr@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(envName string, defaultValue string) (value string)

Env returns environment variable value (or default value if env.variable absent)

func H3hash

func H3hash(s string) string

H3hash create sha512 hash of string

func PackagePath

func PackagePath() string

PackagePath returns file path of Summer package location

func PostBind

func PostBind(c *gin.Context, ret interface{}) bool

PostBind binds data from post request and validates them

func Wait

func Wait()

Types

type Func added in v1.2.6

type Func map[string]func(c *gin.Context)

Func is alias for map[string]func(c *gin.Context)

type GroupsList

type GroupsList struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*GroupsList) Add

func (g *GroupsList) Add(name string, actions ...string)

Add new group

func (*GroupsList) Get

func (g *GroupsList) Get(names ...string) (actions []string)
type Menu struct {
	Title  string
	Order  int
	Parent *Menu
	Link   string
	// contains filtered or unexported fields
}

Menu struct

func (m *Menu) Add(title string, order ...int) *Menu

Add submenu to current menu

type Module

type Module struct {
	*Panel
	Collection *mgo.Collection
	Settings   *ModuleSettings
}

Module struct

func (*Module) Ajax

func (m *Module) Ajax(c *gin.Context)

Ajax is default module's ajax method

func (*Module) GetSettings

func (m *Module) GetSettings() *ModuleSettings

GetSettings needs for correct settings getting from module struct

func (*Module) Page

func (m *Module) Page(c *gin.Context)

Page is default module's page rendering method

func (*Module) Websockets

func (m *Module) Websockets(c *gin.Context)

Websockets is default module's websockets method

type ModuleList

type ModuleList struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ModuleList struct

func (*ModuleList) Get

func (m *ModuleList) Get(name string) (module Simple, exists bool)

Get one module by name

func (*ModuleList) GetList

func (m *ModuleList) GetList() map[string]Simple

GetList returns modules list

type ModuleSettings

type ModuleSettings struct {
	Name             string
	Menu             *Menu
	MenuTitle        string
	MenuOrder        int
	PageRouteName    string
	AjaxRouteName    string
	SocketsRouteName string
	Title            string
	CollectionName   string
	TemplateName     string
	Ajax             Func
	Websockets       WebFunc
	Icon             string
	GroupTo          Simple
	GroupTitle       string
	Rights           Rights
}

ModuleSettings struct

type NotifyStruct

type NotifyStruct struct {
	ID      uint64 `json:"id"  bson:"_id"`
	UserID  uint64 `json:"userId"  bson:"userId"`
	Title   string `json:"title" bson:"title" binding:"required,min=3"`
	Text    string `json:"text" bson:"text"`
	Created uint   `json:"-" bson:"created"`
	Updated uint   `json:"-" bson:"updated"`
	Deleted bool   `json:"-" bson:"deleted"`
	Demo    bool
}

type Panel

type Panel struct {
	Settings
	// RootMenu is zerro-level menu
	RootMenu *Menu
	// MainMenu is main admin-panel menu
	MainMenu *Menu
	// DropMenu is top user dropdown menu
	DropMenu *Menu
	// Groups
	Groups *GroupsList
	// Modules
	Modules *ModuleList
	// Users
	Users *Users
	// contains filtered or unexported fields
}

Panel struct

func Create

func Create(s Settings) *Panel

Create new panel

func (*Panel) AddModule

func (panel *Panel) AddModule(settings *ModuleSettings, s Simple) Simple

AddModule provide adding new module to Panel

type Rights

type Rights struct {
	Groups  []string
	Actions []string
}

type Settings

type Settings struct {
	Port              uint
	Title             string
	AuthSalt          string
	AuthPrefix        string
	Path              string // URL path of panel - "/" by default
	Views             string // file path of ./templates directory
	ViewsDoT          string // file path of doT.js templates directory
	Files             string // file path of ./files directory
	TMPs              string // file path of /tmp directory
	DBName            string // MongoDB database name
	DefaultPage       string
	Language          string
	UsersCollection   string // collection for panel's users
	NotifyCollection  string // collection for panel's notifications
	AICollection      string // collection for AUTO_INCREMENT
	Debug             bool
	Vars              map[string]interface{}
	TFuncMap          template.FuncMap
	FirstStart        func()
	RouterGroup       *gin.RouterGroup
	Engine            *gin.Engine
	DisableAuth       bool     // if TRUE - without summer auth
	DisableFirstStart bool     // if TRUE - without first user creating
	JS                []string // external JS resources
	CSS               []string // external CSS resources
}

Settings intended for data transmission into the Create method of package

type Simple

type Simple interface {
	Page(c *gin.Context)
	Ajax(c *gin.Context)
	Websockets(c *gin.Context)
	GetSettings() *ModuleSettings
	// contains filtered or unexported methods
}

Simple module interface

type Users

type Users struct {
	sync.Mutex
	*Panel
	// contains filtered or unexported fields
}

func (*Users) Add

func (u *Users) Add(user UsersStruct) error

Add new user from struct

func (*Users) GetByLogin

func (u *Users) GetByLogin(login string) (user *UsersStruct, exists bool)

GetArr exports array of users

func (*Users) Length

func (u *Users) Length() int

Length of array of users

type UsersStruct

type UsersStruct struct {
	ID       uint64                 `form:"id"  json:"id"  bson:"_id"`
	Root     bool                   `form:"-"  json:"root"  bson:"root"`
	Name     string                 `form:"name" json:"name" bson:"name" binding:"required,min=3"`
	Notice   string                 `form:"notice" json:"notice" bson:"notice"`
	Login    string                 `form:"login" json:"login" bson:"login" binding:"required`
	Password string                 `form:"password" json:"-" bson:"password"`
	Created  uint                   `form:"-" json:"-" bson:"created"`
	Updated  uint                   `form:"-" json:"-" bson:"updated"`
	Deleted  bool                   `form:"-" json:"-" bson:"deleted"`
	Rights   Rights                 `form:"-" json:"rights" bson:"rights"`
	Settings map[string]interface{} `form:"-" json:"settings" bson:"settings"`
	Demo     bool
}

type WebFunc added in v1.2.6

type WebFunc map[string]func(c *gin.Context, ws *websocket.Conn)

WebFunc is alias for map[string]func(c *websocket.Conn)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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