1{% import "context" %}
2
3{% code
4type Selection int
5const (
6 Git Selection = iota
7 List
8 About
9 Config
10 Login
11)
12%}
13
14{% code
15type GitSelection int
16const (
17 Readme GitSelection = iota
18 Log
19 Summary
20 Refs
21 Tree
22)
23%}
24
25{% func insertIfEqual(s, d any) %}{% if s == d %} selected{% endif %}{% endfunc %}
26
27{% func Navbar (ctx context.Context, s Selection) %}
28 <nav class="container navbar navbar-expand">
29 <div class="navbar-nav">
30 <a class="nav-link{%= insertIfEqual(s, Git) %}" href="/">git</a>
31 </div>
32 <div class="navbar-nav ms-auto">
33 {% if !IsAuthenticationDisabled(ctx) %}
34 {% if IsLoggedIn(ctx) %}
35 <a class="nav-link{%= insertIfEqual(s, Login) %}" href="/logout/">logout</a>
36 {% else %}
37 <a class="nav-link{%= insertIfEqual(s, Login) %}" href="/login/">login</a>
38 {% endif %}
39 {% endif %}
40{% comment %}
41Add this back once needed
42 <a class="nav-link{%= insertIfEqual(s, List) %}" href="/list/">list</a>
43{% endcomment %}
44{% comment %}
45Add this back if needed
46 <a class="nav-link{%= insertIfEqual(s, About) %}" href="/about/">about</a>
47{% endcomment %}
48 </div>
49 </nav>
50{% endfunc %}
51
52{% func GitItemNav (name, ref string, s GitSelection) %}
53<div class="row">
54 <h3 id="name">{%s name %} {% if ref != "" && (s == Log || s == Tree) %}@ {%s ref %}{% endif %}</h3>
55</div>
56<div class="row">
57 <ul class="nav">
58 <li class="nav-item">
59 <a class="nav-link{%= insertIfEqual(s, Readme) %}" aria-current="page" href="/{%s name %}/about/">about</a>
60 </li>
61 <li class="nav-item">
62 <a class="nav-link{%= insertIfEqual(s, Summary) %}" aria-current="page" href="/{%s name %}/">summary</a>
63 </li>
64 <li class="nav-item">
65 <a class="nav-link{%= insertIfEqual(s, Refs) %}" aria-current="page" href="/{%s name %}/refs/">refs</a>
66 </li>
67 <li class="nav-item">
68 <a class="nav-link{%= insertIfEqual(s, Log) %}" aria-current="page" href="/{%s name %}/log/{%s ref %}/">log</a>
69 </li>
70 <li class="nav-item">
71 <a class="nav-link{%= insertIfEqual(s, Tree) %}" aria-current="page" href="/{%s name %}/tree/{%s ref %}/">tree</a>
72 </li>
73 </ul>
74</div>
75{% endfunc %}