summaryrefslogtreecommitdiffstats
path: root/modules/setting/badges.go
blob: e0c1cb55ec94aa3d5ac76368c18a2512827350a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package setting

import (
	"text/template"
)

// Badges settings
var Badges = struct {
	Enabled                      bool               `ini:"ENABLED"`
	GeneratorURLTemplate         string             `ini:"GENERATOR_URL_TEMPLATE"`
	GeneratorURLTemplateTemplate *template.Template `ini:"-"`
}{
	Enabled:              true,
	GeneratorURLTemplate: "https://img.shields.io/badge/{{.label}}-{{.text}}-{{.color}}",
}

func loadBadgesFrom(rootCfg ConfigProvider) {
	mustMapSetting(rootCfg, "badges", &Badges)

	Badges.GeneratorURLTemplateTemplate = template.Must(template.New("").Parse(Badges.GeneratorURLTemplate))
}