common

package
v0.0.0-...-816cd83 Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinDescriptionLength = 3
)

Variables

View Source
var (
	SiteName     = os.Getenv("SITENAME")
	SiteLongName = os.Getenv("SITELONGNAME")
)
View Source
var (
	EmailFailed               = errors.New("Sending email failed.")
	EmailInUse                = errors.New("You have already registered with this email address.")
	UsernameInUse             = errors.New("This username is in use. Please select a different one.")
	InvalidUsernameOrPassword = errors.New("Invalid username or password.")
	DatabaseError             = errors.New("Unknown database error.")
	InvalidSessionID          = errors.New("Invalid sessionid.")
	InvalidEmail              = errors.New("The provided email address is not valid.")
	InvalidIpAddress          = errors.New("There is something wrong with your IP address.")
	InvalidTitle              = errors.New("Invalid page title.")
	PageAlreadyExists         = errors.New("A page with this category and title already exists.")
	PageNotFound              = errors.New("Page not found.")
	InvalidLink               = errors.New("Invalid link. It may have expired or possibly you already used it.")
)

Errors

Functions

func CheckParam

func CheckParam(values url.Values, key string) bool

func CheckSecret

func CheckSecret(hash, email, date string) bool

func ExecTemplate

func ExecTemplate(tmpl *template.Template, w http.ResponseWriter, pc map[string]interface{})

func GenPassword

func GenPassword() string

func GenSlug

func GenSlug(title string) string

func GenerateSecret

func GenerateSecret(email string) (hash string, date string, err error)

func GetBaseURL

func GetBaseURL(req *http.Request) string

func GetIpAddress

func GetIpAddress(req *http.Request) string

func GetSessionId

func GetSessionId(res http.ResponseWriter, req *http.Request) (sessionid string, err error)

func LogError

func LogError(err error)

func LogErrorSkipLevels

func LogErrorSkipLevels(err error, levels int)

func Logout

func Logout(res http.ResponseWriter, req *http.Request)

func NewSessionID

func NewSessionID() string

func RandSeq

func RandSeq(n int) string

func SendRegEmail

func SendRegEmail(email, baseURL string) error

func SendResetEmail

func SendResetEmail(email, date, hash, baseURL string) error

func SetSessionCookie

func SetSessionCookie(res http.ResponseWriter, sessionid string)

func ValidEmail

func ValidEmail(email string) bool

Types

type Community

type Community struct {
	Id       int
	Name     string
	IsMember bool
}

type Page

type Page struct {
	Id           int
	Title        string
	PageSlug     string
	Category     string
	CategorySlug string
	Description  string
	Address      string
	Website      string
	DateCreated  time.Time
}

type PagePostCount

type PagePostCount struct {
	Title        string
	PageSlug     string
	Category     string
	CategorySlug string
	PostCount    int
}

Database row types

type Post

type Post struct {
	Author           string
	Body             string
	CommonCategories int
	Date             string
}

type UserInfo

type UserInfo struct {
	SessionID string
	Email     string
	Username  string
	UserID    int
}

Jump to

Keyboard shortcuts

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