@@ -48,32 +48,36 @@ func host(raw string) string {
4848 return strings .TrimPrefix (u .Host , "www." )
4949}
5050
51- // renderIndex injects the member cards into the embedded page once, at startup,
52- // so each request just writes static bytes (no per-request templating).
53- func renderIndex ( webring []WebringEntry ) [] byte {
54- var cards strings.Builder
55- for _ , e := range webring {
51+ var founderNames = map [ string ] bool { "datavorous" : true , "nisarga" : true }
52+
53+ func buildCards ( entries []WebringEntry ) string {
54+ var b strings.Builder
55+ for _ , e := range entries {
5656 name := html .EscapeString (e .Name )
57- cards .WriteString (`<a class="card" href="` )
58- cards .WriteString (html .EscapeString (e .Url ))
59- cards .WriteString (`" rel="noopener" data-name="` )
60- cards .WriteString (name )
61- cards .WriteString (`"><span class="avatar">` )
62- cards .WriteString (html .EscapeString (initial (e .Name )))
57+ b .WriteString (`<a class="card" href="` )
58+ b .WriteString (html .EscapeString (e .Url ))
59+ b .WriteString (`" rel="noopener" data-name="` )
60+ b .WriteString (name )
61+ b .WriteString (`"><span class="avatar">` )
62+ b .WriteString (html .EscapeString (initial (e .Name )))
6363 if e .Gh != "" {
64- cards .WriteString (`<img src="https://avatars.githubusercontent.com/` )
65- cards .WriteString (html .EscapeString (e .Gh ))
66- cards .WriteString (`?size=96" alt="" loading="lazy" onerror="this.setAttribute('data-failed','')" />` )
64+ b .WriteString (`<img src="https://avatars.githubusercontent.com/` )
65+ b .WriteString (html .EscapeString (e .Gh ))
66+ b .WriteString (`?size=96" alt="" loading="lazy" onerror="this.setAttribute('data-failed','')" />` )
6767 }
68- cards .WriteString (`</span><span class="meta"><span class="name">` )
69- cards .WriteString (name )
70- cards .WriteString (`</span><span class="host">` )
71- cards .WriteString (html .EscapeString (host (e .Url )))
72- cards .WriteString (`</span></span><span class="arrow">→</span></a>` )
68+ b .WriteString (`</span><span class="meta"><span class="name">` )
69+ b .WriteString (name )
70+ b .WriteString (`</span><span class="host">` )
71+ b .WriteString (html .EscapeString (host (e .Url )))
72+ b .WriteString (`</span></span><span class="arrow">→</span></a>` )
7373 }
74+ return b .String ()
75+ }
7476
75- out := strings .Replace (string (indexHTML ), "<!--MEMBERS-->" , cards .String (), 1 )
76- out = strings .Replace (out , "<!--COUNT-->" , fmt .Sprintf ("%d members" , len (webring )), 1 )
77+ func renderIndex (founders , members []WebringEntry ) []byte {
78+ out := strings .Replace (string (indexHTML ), "<!--FOUNDERS-->" , buildCards (founders ), 1 )
79+ out = strings .Replace (out , "<!--MEMBERS-->" , buildCards (members ), 1 )
80+ out = strings .Replace (out , "<!--COUNT-->" , fmt .Sprintf ("%d members" , len (founders )+ len (members )), 1 )
7781 return []byte (out )
7882}
7983
@@ -84,7 +88,16 @@ func main() {
8488 os .Exit (1 )
8589 }
8690
87- page := renderIndex (webring )
91+ var founders , members []WebringEntry
92+ for _ , e := range webring {
93+ if founderNames [e .Name ] {
94+ founders = append (founders , e )
95+ } else {
96+ members = append (members , e )
97+ }
98+ }
99+
100+ page := renderIndex (founders , members )
88101
89102 http .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
90103 reqHost := r .Host
0 commit comments