sprucelib

package
v0.0.0-...-de10f32 Latest Latest
Warning

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

Go to latest
Published: May 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectPassword = errors.New("Incorrect password")
View Source
var ErrInvalidToken = errors.New("Invalid token")
View Source
var ErrUnknownUser = errors.New("Unknown user")

Functions

This section is empty.

Types

type AssetStore

type AssetStore interface {
}

type BoltDataStore

type BoltDataStore struct {
	DB *bolt.DB
}

func NewBoltDataStore

func NewBoltDataStore() (db BoltDataStore, err error)

NewBoltDataStore opens a new connection to a BoltDB database.

func (BoltDataStore) Close

func (ds BoltDataStore) Close()

Closes the underlying BoltDB database. Ensure this is called before the application exits.

func (BoltDataStore) CreateBuckets

func (ds BoltDataStore) CreateBuckets()

CreateBuckets ensures all the BoltDB buckets used by the application are created. This function is called automatically by NewBoltDataStore(). If some other means is used to get a BoltDataStore, this function may need to be called manually to ensure the buckets exist.

func (BoltDataStore) GetUserByToken

func (db BoltDataStore) GetUserByToken(token string) (user User, err error)

func (BoltDataStore) GetUserByUsernameAndPassword

func (ds BoltDataStore) GetUserByUsernameAndPassword(username string, password string) (user User, err error)

func (BoltDataStore) NewTokenForUser

func (db BoltDataStore) NewTokenForUser(user User) (token string, err error)

type ContentTemplate

type ContentTemplate struct {
	Name      string
	Content   []byte
	MediaType string // Default text/html, could also be application/xml or application/json
	IsRoot    bool   // For HTML templates, a "root" template is one that starts with <html>
}

type ContentType

type ContentType struct {
	Id              int
	Name            string
	DataFields      []Field
	TitleAllowed    bool
	TitleRequired   bool
	ContentAllowed  bool
	ContentRequired bool
}

type DataStore

type DataStore interface {
	Close()
	// GetUserById(int) (User, error)
	// GetAllUsers() ([]User, error)
	GetUserByUsernameAndPassword(string, string) (User, error)
	GetUserByToken(string) (User, error)
	NewTokenForUser(User) (string, error)
}

type Field

type Field struct {
	ID        string // TODO Should this be a GUID?
	Name      string
	TypeID    string
	Type      FieldType
	Position  int // Used to sort fields in the UI
	MinValues int // The minimum number of FieldValues required to be assigned in the UI
	MaxValues int // The maximum number of FieldValues allowed to be assigned in the UI
}

A Field is a concrete instance of a FieldType attached to a ContentType in a particular position.

For example, the "Department" Field on a "Staff" ContentType which should be the 3rd field in the UI.

NOTE: This type does not store data values. In the example above, the value "Marketing" is attached to a Resource as a FieldValue

type FieldType

type FieldType struct {
	ID   string
	Name string
}

type FieldValue

type FieldValue struct {
	Field Field
	Value interface{}
}

func (*FieldValue) IsValid

func (fv *FieldValue) IsValid() bool

type Resource

type Resource struct {
	Id          uint
	Alias       string
	URI         string
	TreePath    string
	Title       string
	ShortTitle  string
	IsPublished bool
	PublishAt   time.Time
	UnpublishAt time.Time
	PublishedBy *User
}

type Scanner

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

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, lit string)

type SpruceApp

type SpruceApp struct {
	Logger     *logrus.Logger
	DataStore  DataStore
	AssetStore AssetStore
	// contains filtered or unexported fields
}

func NewSpruceApp

func NewSpruceApp() *SpruceApp

func (*SpruceApp) AdminDir

func (app *SpruceApp) AdminDir() string

type SqlDataStore

type SqlDataStore struct {
	DB *gorm.DB
}

func (SqlDataStore) GetUserByToken

func (db SqlDataStore) GetUserByToken(token string) (user User, err error)

func (SqlDataStore) GetUserByUsernameAndPassword

func (ds SqlDataStore) GetUserByUsernameAndPassword(username string, password string) (user User, err error)

func (SqlDataStore) NewTokenForUser

func (db SqlDataStore) NewTokenForUser(user User) (token string, err error)

type Token

type Token int
const (

	// Special tokens
	ILLEGAL Token = iota
	EOF
	WHITESPACE

	// Literals
	IDENT

	// Character triggers
	EXCLAMATION
)

type User

type User struct {
	ID                    uint `gorm:"primary_key"`
	Username              string
	Email                 string
	PasswordHash          string
	PasswordResetToken    string
	FirstName             string
	LastName              string
	IsBlocked             bool
	Tokens                []UserToken
	CreatedAt             time.Time
	UpdatedAt             time.Time
	PasswordLastChangedAt time.Time
	LastLoginAt           time.Time
	FailedLoginAttempts   int
	DeletedAt             *time.Time
}

type UserToken

type UserToken struct {
	UserID    uint   `gorm:"primary_key"`
	Token     string `gorm:"primary_key"`
	User      User
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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