herodote

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var 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 := 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 struct {
	// contains filtered or unexported fields
}

func New

func New(config Config, storeApp Store, tracer trace.Tracer) (App, error)

func (App) Handler

func (a App) Handler() http.Handler

func (App) TemplateFunc added in v1.4.0

func (a App) TemplateFunc(w http.ResponseWriter, r *http.Request) (renderer.Page, error)

type Config

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

func Flags

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

type Store added in v1.9.0

type Store interface {
	Enabled() bool
	ListFilters(context.Context) (map[string][]string, error)
	SearchCommit(ctx context.Context, query string, filters map[string][]string, before, after string, pageSize uint, last string) (model.CommitsList, error)
	SaveCommit(context.Context, model.Commit) error
}

Jump to

Keyboard shortcuts

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