helpers

package
v0.0.0-...-86b787e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateProduction  = "production"
	StateTest        = "test"
	StateDevelopment = "development"
	ProdDataDir      = "data"
	TestDataDir      = "data_test"
	DevDataDir       = "data_dev"
)
View Source
const HashMin = 16
View Source
const Maxlen = 32

Variables

This section is empty.

Functions

func BleveSafe

func BleveSafe(s string) string

take the bleve html results and make them safe for consumption

func CapFirstLetter

func CapFirstLetter(s string) string

func CheckToBool

func CheckToBool(str string) bool

func CropImageFromCenter

func CropImageFromCenter(img image.Image) (image.Image, error)

func DataDir

func DataDir() string

func FormatAndAssign

func FormatAndAssign(width uint, height uint, im []*image.Paletted, pal color.Palette, img *image.RGBA, index int, crop bool) error

func FormatFrames

func FormatFrames(width uint, height uint, frame *image.Paletted, pal color.Palette, img *image.RGBA, crop bool) (*image.Paletted, error)

func FormatGif

func FormatGif(width uint, height uint, src string, full_path string, crop bool) error

func FormatJpg

func FormatJpg(width uint, height uint, src string, full_path string, crop bool) error

func FormatPng

func FormatPng(width uint, height uint, src string, full_path string, crop bool) error
func GenerateLink(baseurl, namespace string, size int) (string, string)

func GenerateSecureKey

func GenerateSecureKey() string

Copy of auth.GenerateSecureKey to prevent cyclic import with auth library

func GetFileContentType

func GetFileContentType(out *os.File) (string, error)

func HTMLEscapeAll

func HTMLEscapeAll(this interface{})

func HashToId

func HashToId(hash, salt string) (int64, error)

func IdToHash

func IdToHash(id int64, salt string) (string, error)

func ImageContainer

func ImageContainer(rect image.Rectangle) draw.Image

func ImageToPaletted

func ImageToPaletted(img image.Image, pal color.Palette) *image.Paletted

func IsAllowedCommentTag

func IsAllowedCommentTag(t html.Token) (bool, bool)

func IsAllowedTag

func IsAllowedTag(t html.Token) bool

func IsBreakTag

func IsBreakTag(t html.Token) bool

func ParseBreaksHtml

func ParseBreaksHtml(r io.Reader) *bytes.Buffer

func ParseCommentHtml

func ParseCommentHtml(r io.Reader) *bytes.Buffer

Parses the supplied HTML found in the io.reader It iterates over the the tags using the IsAllowedTag() method in order to find tags that are allowed.

func ParseHtml

func ParseHtml(r io.Reader) *bytes.Buffer

Parses the supplied HTML found in the io.reader It iterates over the the tags using the IsAllowedTag() method in order to find tags that are allowed.

func PrettifyString

func PrettifyString(s string) string

func PrettyTime

func PrettyTime(t time.Time) string

func RandomString

func RandomString(n int) string

RandomString isn't crypto secure or anything we just need a psuedo random key to be generated for our canary token

func ResizeImage

func ResizeImage(img image.Image, maxWidth uint, maxHeight uint) image.Image

func Safe

func Safe(s string) string

allow a tiny subset of html elements with only the href attr on <a>

func SafeNoHref

func SafeNoHref(s string) string

func SafeTsAndCs

func SafeTsAndCs(s string) string

allow a tiny subset of html elements with only the href attr on <a>

func SimpleDate

func SimpleDate(st string) string

func Strip

func Strip(s string) string

strip it all, no html

func StripHtmlTags

func StripHtmlTags(r io.Reader) *bytes.Buffer

func ValidateImage

func ValidateImage(b []byte) (string, error)

func ValidateMimeType

func ValidateMimeType(b []byte) string

func ValidateMimeTypeString

func ValidateMimeTypeString(s string) string

func ValidateVideoMimeType

func ValidateVideoMimeType(b []byte) string

this is broken for mp4

func WidthHeight

func WidthHeight(img image.Image, maxWidth uint, maxHeight uint) (uint, uint)

Types

type Email

type Email struct {
	Subject      string
	Body         string
	To           []string
	From         string
	TemplateName string
	Filename     string
	URI          string
}

type Event

type Event struct {
	Mailer *Mailer

	Email *Email
	Link  string
}

func NewEvent

func NewEvent(db *storm.DB, box *packr.Box) *Event

func (*Event) SendEvent

func (te *Event) SendEvent() error

type Mailer

type Mailer struct {
	Smtp     *models.Smtp
	Settings *models.Settings
	DB       *storm.DB
	Box      *packr.Box

	EventID      int64
	EventLink    string
	Subject      string
	Text         string
	TemplateName string
	TemplateFile string
}

func NewMailer

func NewMailer(db *storm.DB, box *packr.Box) *Mailer

type Pagi

type Pagi struct {
	Offset      int
	OffsetSize  int
	Limit       int
	Page        int
	PageTotal   int
	GrandTotal  int
	PrevPage    int
	PrevEnabled bool
	PrevLink    string
	NextPage    int
	NextEnabled bool
	NextLink    string
	BaseURI     string
}

func NewPagi

func NewPagi() *Pagi

func (*Pagi) CalcOffset

func (this *Pagi) CalcOffset()

func (*Pagi) Configure

func (this *Pagi) Configure(grandtotal int, r *http.Request) error

func (*Pagi) ConfigureMan

func (this *Pagi) ConfigureMan(grandtotal, page, limit int, r *http.Request) error

func (*Pagi) LimitIsValid

func (this *Pagi) LimitIsValid() bool

func (*Pagi) PageIsValid

func (this *Pagi) PageIsValid() bool

func (*Pagi) SetupButtons

func (this *Pagi) SetupButtons()

type SensorEvent

type SensorEvent struct {
	ID int64
}

type TokenEvent

type TokenEvent struct {
}

Jump to

Keyboard shortcuts

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