herodote

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthentificationFailed occurs when secret is invalid
	ErrAuthentificationFailed = errors.New("invalid secret provided")
)
View Source
var (

	// FuncMap for template rendering
	FuncMap = template.FuncMap{
		"colors": func(commit model.Commit) string {
			if color, ok := colors.Load(commit.Repository); ok {
				return color.(string)
			}

			colorsCount++
			nextColor := repositoriesColors[colorsCount%len(repositoriesColors)]
			colors.Store(commit.Repository, nextColor)

			return nextColor
		},
		"contains":           contains,
		"dateDistanceInDays": diffInDays,
		"toggleParam": func(path string, params url.Values, name, value string) string {
			safeValues := url.Values{}
			done := false

			for key := range params {
				currentValue := strings.TrimSpace(params.Get(key))

				if len(currentValue) == 0 {
					continue
				}

				if key == name {
					done = true
				} else {
					safeValues.Set(key, currentValue)
				}
			}

			if !done {
				safeValues.Set(name, value)
			}

			if len(safeValues) == 0 {
				return path
			}

			return fmt.Sprintf("%s?%s", path, safeValues.Encode())
		},
	}
)

Functions

This section is empty.

Types

type App

type App interface {
	Handler() http.Handler
	TemplateFunc(*http.Request) (string, int, map[string]interface{}, error)
}

App of package

func New

func New(config Config, storeApp store.App) (App, error)

New creates new App from Config

type Config

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

Config of package

func Flags

func Flags(fs *flag.FlagSet, prefix string) Config

Flags adds flags for configuring package

Jump to

Keyboard shortcuts

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