summaryrefslogtreecommitdiff
blob: 2dbbb7849c18e23b124504f5f06d1ff5f229dce2 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
{{template "head" .}}
<body>
{{template "header" .}}

<div class="container mb-5">
    <div class="row">
        <div class="col-12">

            <h2 class="mt-4"><span style="font-family: monospace;">/</span></h2>

            {{$empty := true}}

            <table class="table">
                <colgroup>
                    <col span="1" style="width: 20%;">
                    <col span="1" style="width: 60%;">
                    <col span="1" style="width: 10%;">
                    <col span="1" style="width: 5%;">
                    <col span="1" style="width: 5%;">
                </colgroup>
                <thead>
                <tr>
                    <th scope="col">Short URL</th>
                    <th scope="col">Target</th>
                    <th scope="col">Creator</th>
                    <th scope="col">Hits</th>
                    <th scope="col">Action</th>
                </tr>
                </thead>
                <tbody>
                {{$empty = true}}
                {{range .UserLinks}}
                    {{if eq .Prefix ""}}
                    {{$empty = false}}
                    <tr>
                        <th scope="row"><a class="text-dark" href="{{.ShortLink}}">go.gentoo.org{{.ShortLink}}</a></th>
                        <td><a class="text-dark" href="{{.TargetLink}}">{{.TargetLink}}</a></td>
                        <td>{{replaceAll .UserEmail "@gentoo.org" ""}}</td>
                        <td>{{.Hits}}</td>
                        <td>
                            <form action="/links/delete" method="post">
                                <input hidden name="prefix" value="{{.Prefix}}">
                                <input hidden name="token" value="{{.URLToken}}">
                                <input hidden name="from" value="/admin/">
                                <button type="submit" class="btn btn-link py-0 text-dark">
                                    <i class="fa fa-trash-o" aria-hidden="true"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    {{end}}
                {{end}}
                {{if $empty}}
                <tr>
                    <td colspan="4" class="text-center"><i>No shortened URLs yet</i></td>
                </tr>
                {{end}}
                </tbody>
            </table>


            {{range $index, $project := getPrefixList .UserLinks}}
                <h2 class="mt-5"><span style="font-family: monospace;">/{{$project}}/</span></h2>

                <table class="table">
                    <colgroup>
                        <col span="1" style="width: 20%;">
                        <col span="1" style="width: 65%;">
                        <col span="1" style="width: 10%;">
                        <col span="1" style="width: 5%;">
                    </colgroup>
                    <thead>
                    <tr>
                        <th scope="col">Short URL</th>
                        <th scope="col">Target</th>
                        <th scope="col">Creator</th>
                        <th scope="col">Action</th>
                    </tr>
                    </thead>
                    <tbody>
                    {{$empty = true}}
                    {{range $.UserLinks}}
                        {{if eq .Prefix $project}}
                            {{$empty = false}}
                            <tr>
                                <th scope="row"><a class="text-dark" href="{{.ShortLink}}">go.gentoo.org{{.ShortLink}}</a></th>
                                <td><a class="text-dark" href="{{.TargetLink}}">{{.TargetLink}}</a></td>
                                <td>{{replaceAll .UserEmail "@gentoo.org" ""}}</td>
                                <td>
                                    <form action="/links/delete" method="post">
                                        <input hidden name="prefix" value="{{.Prefix}}">
                                        <input hidden name="token" value="{{.URLToken}}">
                                        <input hidden name="from" value="/admin/">
                                        <button type="submit" class="btn btn-link py-0 text-dark">
                                            <i class="fa fa-trash-o" aria-hidden="true"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                        {{end}}
                    {{end}}
                    {{if $empty}}
                        <tr>
                            <td colspan="4" class="text-center"><i>No shortened URLs yet</i></td>
                        </tr>
                    {{end}}
                    </tbody>
                </table>
            {{end}}
        </div>
    </div>
</div>


{{template "footer" .}}


</body>
</html>