start by showing some of the most popular tags first
Ted Unangst tedu@tedunangst.com
Wed, 28 Feb 2024 01:17:45 -0500
2 files changed,
16 insertions(+),
2 deletions(-)
M
views/onts.html
→
views/onts.html
@@ -3,8 +3,12 @@ <main>
<div class="info"> <p>ontologies of interest {{ $firstrune := .FirstRune }} -{{ $letter := 0 }} <ul> +<li><p> +{{ range .Pops }} +<span class="wsnowrap"><a href="/o/{{ .Name }}">#{{ .Name }}</a> ({{ .Count }})</span> +{{ end }} +{{ $letter := 0 }} {{ range .Onts }} {{ if not (eq $letter (call $firstrune .Name)) }} {{ $letter = (call $firstrune .Name) }}
M
web.go
→
web.go
@@ -938,7 +938,7 @@ elog.Printf("selection error: %s", err)
return } defer rows.Close() - var onts []Ont + var onts, pops []Ont for rows.Next() { var o Ont err := rows.Scan(&o.Name, &o.Count)@@ -951,14 +951,24 @@ continue
} o.Name = o.Name[1:] onts = append(onts, o) + if o.Count > 1 { + pops = append(pops, o) + } } sort.Slice(onts, func(i, j int) bool { return onts[i].Name < onts[j].Name }) + sort.Slice(pops, func(i, j int) bool { + return pops[i].Count > pops[j].Count + }) + if len(pops) > 40 { + pops = pops[:40] + } if u == nil && !develMode { w.Header().Set("Cache-Control", "max-age=300") } templinfo := getInfo(r) + templinfo["Pops"] = pops templinfo["Onts"] = onts templinfo["FirstRune"] = func(s string) rune { r, _ := utf8.DecodeRuneInString(s); return r } err = readviews.Execute(w, "onts.html", templinfo)