teian

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOverQuota = errors.New("quota exceeded")

Functions

func SendMail added in v1.2.0

func SendMail(mail Mail) error

Types

type ByDate

type ByDate []Suggestion

ByDate helps to sort suggestions by creation time.

func (ByDate) Len

func (s ByDate) Len() int

func (ByDate) Less

func (s ByDate) Less(i, j int) bool

func (ByDate) Swap

func (s ByDate) Swap(i, j int)

type ByID

type ByID []Suggestion

ByID helps to sort suggestions by ID.

func (ByID) Len

func (s ByID) Len() int

func (ByID) Less

func (s ByID) Less(i, j int) bool

func (ByID) Swap

func (s ByID) Swap(i, j int)

type ByUser

type ByUser []Suggestion

ByUser helps to sort suggestions by username.

func (ByUser) Len

func (s ByUser) Len() int

func (ByUser) Less

func (s ByUser) Less(i, j int) bool

func (ByUser) Swap

func (s ByUser) Swap(i, j int)

type Conf

type Conf struct {
	Title       string
	AnalyticsID string
	Description string
	Keywords    string
	WriteMsg    string
	Version     string
}

Conf holds configuration values that the program needs.

func (Conf) SiteTitle

func (c Conf) SiteTitle() string

SiteTitle returns the Title capitalized.

type Mail added in v1.2.0

type Mail struct {
	To      string
	From    string
	Subject string
	Content string
}

type Quota added in v1.2.0

type Quota int64

type Suggestion

type Suggestion struct {
	ID       uint64
	Username string
	Text     string
	Created  time.Time
}

Suggestion represents a suggestion that a user can create.

func FilterByText

func FilterByText(suggs []Suggestion, text string) []Suggestion

FilterByText returns suggestions whose Text contains the provided text. It is used to search a slice of suggestions and return only those containing the given text.

func FilterByUser

func FilterByUser(suggs []Suggestion, username string) []Suggestion

FilterByUser returns suggestions whose Username contains the provided username. It is used to filter a slice of suggestions by username.

func FindByID

func FindByID(suggs []Suggestion, id uint64) (int, *Suggestion)

FindByID first sorts the slice of suggestions by ID and then searches for the given id. If the id is found in the slice then it returns the index and the suggestion. If the id is not found then it returns index -1 and nil.

func (*Suggestion) FmtCreated

func (s *Suggestion) FmtCreated() string

FmtCreated returns the creation time of the suggestion formatted as:

Mon 02 Jan 2006 15:04:05 MST

type SuggestionStore

type SuggestionStore interface {
	// Create creates a new suggestion for a user.
	Create(username string, sugg *Suggestion) error
	// OfUser gets all the suggestions created by a user.
	OfUser(username string) ([]Suggestion, error)
	// All returns all the suggestions.
	All() ([]Suggestion, error)
	// Delete deletes a user's suggestion.
	Delete(username string, id uint64) error

	CheckQuota(username string, n Quota) (Quota, error)
}

SuggestionStore describes all the operations that need to access a storage for the suggestions.

type Timer added in v1.2.0

type Timer struct {
	*time.Timer
	// contains filtered or unexported fields
}

func NewTimer added in v1.2.0

func NewTimer(hour, minute, second int) Timer

func (Timer) Reset added in v1.2.0

func (t Timer) Reset()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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