Files
golink/home.html
T
Will Norris 811dd5ae87 cmd/golink: persist click stats for links
store click stats in db.  Hold stats in memory and flush to db every
minute, as well as whenever the /_/export endpoint is called.

Change DB.List() to DB.LoadAll(), since it practice we actually want
the data, not just the names.

Change-Id: I21a3aa19bfc065d595822f004a14b96bbb347de8
2022-06-10 13:21:39 -07:00

62 lines
2.9 KiB
HTML

<html>
<head>
<title>go/</title>
<link rel="stylesheet" href="/_/static/base.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body class="flex flex-col min-h-screen">
<div class="bg-gray-100 border-b border-gray-200 pt-4 pb-2 mb-6">
<header class="container mx-auto px-4">
<h1 class="text-2xl font-bold pb-1">go/</h1>
A private shortlink service for your tailnet
</header>
</div>
<main class="container mx-auto px-4 flex-1">
<h2 class="text-xl font-bold pb-2">Create a new link</h2>
<form method="POST" action="/">
<label class="whitespace-nowrap">http://go/
<input name=short required type=text size=15 placeholder="shortname" value="{{.Short}}" class="p-2 my-2 rounded-md border-gray-300 placeholder:text-gray-400">
&rarr;
</label>
<input name=long required type=text size=40 placeholder="https://destination-url" class="p-2 my-2 max-w-full rounded-md border-gray-300 placeholder:text-gray-400">
<button type=submit class="py-2 px-4 my-2 rounded-md bg-blue-500 border-blue-500 text-white hover:bg-blue-600 hover:border-blue-600">Create</button>
</form>
<h2 class="text-xl font-bold pt-6 pb-2">Popular Links</h2>
<table class="table-auto ">
<thead class="border-b border-gray-200 uppercase text-xs text-gray-500 text-left">
<tr>
<th class="p-2">Link</th>
<th class="p-2">Clicks</th>
</tr>
</thead>
<tbody>
{{range .Clicks}}
<tr class="hover:bg-gray-100 border-b border-gray-200"><td><a class="block p-2 pr-8 hover:text-blue-500 hover:underline" href="http://go/{{.Short}}">go/{{.Short}}</a></td><td class="p-2">{{.NumClicks}}</td></tr>
{{end}}
</tbody>
</table>
</main>
<footer class="bg-gray-100 border-t border-gray-200 pt-2 pb-2 mt-6">
<div class="container mx-auto px-4 leading-6 text-right">
From the nerds at
<a href="https://tailscale.com/" class="inline-block align-text-top">
<svg width="18" height="18" viewBox="0 0 22 22" fill="none" role="img" aria-labelledby="tsTitle" xmlns="http://www.w3.org/2000/svg">
<title id="tsTitle">Tailscale</title>
<circle opacity="0.2" cx="3.4" cy="3.25" r="2.7" fill="currentColor" />
<circle cx="3.4" cy="11.3" r="2.7" fill="currentColor" />
<circle opacity="0.2" cx="3.4" cy="19.5" r="2.7" fill="currentColor" />
<circle cx="11.5" cy="11.3" r="2.7" fill="currentColor" />
<circle cx="11.5" cy="19.5" r="2.7" fill="currentColor" />
<circle opacity="0.2" cx="11.5" cy="3.25" r="2.7" fill="currentColor" />
<circle opacity="0.2" cx="19.5" cy="3.25" r="2.7" fill="currentColor" />
<circle cx="19.5" cy="11.3" r="2.7" fill="currentColor" />
<circle opacity="0.2" cx="19.5" cy="19.5" r="2.7" fill="currentColor" />
</svg>
</a>
</div>
</footer>
</html>