Przeglądaj źródła

Use singular forms in repo stats if appropriate

Lucas Stadler 8 lat temu
rodzic
commit
cd07c039ef
1 zmienionych plików z 11 dodań i 4 usunięć
  1. 11 4
      quit.go

+ 11 - 4
quit.go

@ -564,6 +564,13 @@ func (fc *FancyFile) Less(file *FancyFile) bool {
564 564
}
565 565
566 566
var repoFuncs = template.FuncMap{
567
	"count": func(count int, singular, plural string) template.HTML {
568
		form := plural
569
		if count == 1 {
570
			form = singular
571
		}
572
		return template.HTML(fmt.Sprintf("<span class=\"count\">%d</span> %s", count, form))
573
	},
567 574
	"languageToColor": func(l string) string {
568 575
		c, ok := languageColors[l]
569 576
		if !ok {
@ -586,10 +593,10 @@ var repoTmpl = template.Must(template.New("").Funcs(repoFuncs).Parse(`<!doctype
586 593
		<div id="container">
587 594
588 595
		<section id="repo" class="repo-info">
589
			<a id="commits" class="repo-stat" href="#"><span class="icon">⏲</span><span class="count">{{ .Repo.CommitCount }}</span> commits</a>
590
			<a id="branches" class="repo-stat" href="#"><span class="icon">⛗</span><span class="count">{{ len .Repo.Branches }}</span> branches</a>
591
			<a id="tags" class="repo-stat" href="#"><span class="icon">🏷&#xFE0E;</span><span class="count">{{ len .Repo.Tags }}</span> tags</a>
592
			<a id="contributors" class="repo-stat" href="#"><span class="icon">👥</span><span class="count">{{ len .Repo.Contributors }}</span> contributors</a>
596
			<a id="commits" class="repo-stat" href="#"><span class="icon">⏲</span>{{ count .Repo.CommitCount "commit" "commits" }}</a>
597
			<a id="branches" class="repo-stat" href="#"><span class="icon">⛗</span>{{ count (len .Repo.Branches) "branch" "branches" }}</a>
598
			<a id="tags" class="repo-stat" href="#"><span class="icon">🏷&#xFE0E;</span>{{ count (len .Repo.Tags) "tag" "tags" }}</a>
599
			<a id="contributors" class="repo-stat" href="#"><span class="icon">👥</span>{{ count (len .Repo.Contributors) "contributor" "contributors" }}</a>
593 600
		</section>
594 601
595 602
		<div id="languages">