Initial commit

This commit is contained in:
Thomas Miceli
2023-03-14 16:22:52 +01:00
commit bee5d045c3
52 changed files with 8560 additions and 0 deletions

43
templates/pages/admin_gists.html vendored Normal file
View File

@ -0,0 +1,43 @@
{{ template "header" .}}
{{ template "admin_header" .}}
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8 bg-gray-800 rounded-md border border-gray-700">
<table class="min-w-full divide-y divide-gray-500">
<thead>
<tr>
<th scope="col" class="whitespace-nowrap py-3.5 pl-4 pr-3 text-left text-sm font-bold text-slate-300 sm:pl-0">ID</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">Title</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">User</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">Private ?</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300"># files</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300"># likes</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">Created at</th>
<th scope="col" class="relative whitespace-nowrap py-3.5 pl-3 pr-4 sm:pr-0">
<span class="sr-only">Delete</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-500">
{{ range $gist := .data }}
<tr>
<td class="whitespace-nowrap py-2 pl-4 pr-3 text-sm text-slate-300 sm:pl-0">{{ $gist.ID }}</td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300"><a href="/{{ $gist.User.Username }}/{{ $gist.Uuid }}">{{ $gist.Title }}</a></td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300"><a href="/{{ $gist.User.Username }}">{{ $gist.User.Username }}</a></td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300">{{ $gist.Private }}</td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300">{{ $gist.NbFiles }}</td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300">{{ $gist.NbLikes }}</td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300"><span class="moment-timestamp-date">{{ $gist.CreatedAt }}</span></td>
<td class="relative whitespace-nowrap py-2 pl-3 pr-4 text-right text-sm font-medium sm:pr-0">
<form action="/admin/gists/{{ $gist.ID }}/delete" method="POST" onsubmit="return confirm('Do you want to delete this user ?')">
{{ $.csrfHtml }}
<button type="submit" class="text-rose-500 hover:text-rose-600">Delete</button>
</form>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ template "admin_footer" .}}
{{ template "footer" .}}

55
templates/pages/admin_index.html vendored Normal file
View File

@ -0,0 +1,55 @@
{{ template "header" .}}
{{ template "admin_header" .}}
<div class="sm:flex sm:space-x-4 space-y-4 sm:space-y-0">
<div class="sm:overflow-hidden ">
<div class="space-y-2 bg-gray-800 py-6 px-6 rounded-md border border-gray-700">
<div>
<span class="text-base font-bold leading-6 text-slate-300">Versions</span>
</div>
<table class="table-fixed">
<tbody>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">Opengist</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .opengistVersion }}</td>
</tr>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">Go</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .goVersion }}</td>
</tr>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">Git</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .gitVersion }} </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sm:overflow-hidden ">
<div class="space-y-2 bg-gray-800 py-6 px-6 rounded-md border border-gray-700">
<div>
<span class="text-base font-bold leading-6 text-slate-300">Stats</span>
</div>
<table class="table-fixed">
<tbody>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">Users</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .countUsers }}</td>
</tr>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">Gists</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .countGists }}</td>
</tr>
<tr>
<td class="whitespace-nowrap py-2 pr-3 text-sm text-slate-300 ">SSH keys</td>
<td class="whitespace-nowrap px-2 py-2 text-sm font-medium text-slate-300">{{ .countKeys }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{{ template "admin_footer" .}}
{{ template "footer" .}}

35
templates/pages/admin_users.html vendored Normal file
View File

@ -0,0 +1,35 @@
{{ template "header" .}}
{{ template "admin_header" .}}
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8 bg-gray-800 rounded-md border border-gray-700">
<table class="min-w-full divide-y divide-gray-500">
<thead>
<tr>
<th scope="col" class="whitespace-nowrap py-3.5 pl-4 pr-3 text-left text-sm font-bold text-slate-300 sm:pl-0">ID</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">Username</th>
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-slate-300">Created</th>
<th scope="col" class="relative whitespace-nowrap py-3.5 pl-3 pr-4 sm:pr-0">
<span class="sr-only">Delete</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-500">
{{ range $user := .data }}
<tr>
<td class="whitespace-nowrap py-2 pl-4 pr-3 text-sm text-slate-300 sm:pl-0">{{ $user.ID }}</td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300"><a href="/{{ $user.Username }}">{{ $user.Username }}</a></td>
<td class="whitespace-nowrap px-2 py-2 text-sm text-slate-300"><span class="moment-timestamp-date">{{ $user.CreatedAt }}</span></td>
<td class="relative whitespace-nowrap py-2 pl-3 pr-4 text-right text-sm font-medium sm:pr-0">
<form action="/admin/users/{{ $user.ID }}/delete" method="POST" onsubmit="return confirm('Do you want to delete this user ?')">
{{ $.csrfHtml }}
<button type="submit" class="text-rose-500 hover:text-rose-600">Delete</button>
</form>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ template "admin_footer" .}}
{{ template "footer" .}}

109
templates/pages/all.html vendored Normal file
View File

@ -0,0 +1,109 @@
{{ template "header" .}}
<div class="py-10">
<header class="pb-4 flex ">
<div class="flex-auto">
<h1 class="text-2xl font-bold leading-tight">All gists {{if .fromUser}} from {{.fromUser}} {{end}}</h1>
</div>
<div class="float-right">
<div class="relative inline-block text-left">
<div>
<button type="button" class="inline-flex text-slate-300 rounded border border-gray-600 bg-gray-800 px-2.5 py-2 text-xs font-medium text-white shadow-sm hover:bg-gray-700 hover:border-gray-500 hover:text-slate-300 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 leading-3" id="sort-gists-button">
<span class="text-gray-300">Sort : <span class="text-slate-300">{{.order}} {{.sort}}</span></span>
<svg class="-mr-1 ml-2 h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
</svg>
</button>
</div>
<div id="sort-gists-dropdown" class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right divide-y divide-gray-700 rounded-md rounded border border-gray-600 bg-gray-800 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1">
<div class="" role="none">
<a href="/{{if .fromUser}}{{.fromUser}}{{else}}all{{end}}?sort=created&order=desc" class="text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-700 hover:text-white hover:bg-primary-500 hover:rounded-t-md" role="menuitem">
Recently created
</a>
</div>
<div class="" role="none">
<a href="/{{if .fromUser}}{{.fromUser}}{{else}}all{{end}}?sort=created&order=asc" class="text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-700 hover:text-white hover:bg-primary-500" role="menuitem">
Least recently created
</a>
</div><div class="" role="none">
<a href="/{{if .fromUser}}{{.fromUser}}{{else}}all{{end}}?sort=updated&order=desc" class="text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-700 hover:text-white hover:bg-primary-500" role="menuitem">
Recently updated
</a>
</div>
<div class="" role="none">
<a href="/{{if .fromUser}}{{.fromUser}}{{else}}all{{end}}?sort=updated&order=asc" class="text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-700 hover:text-white hover:bg-primary-500 hover:rounded-b-md" role="menuitem">
Least recently updated
</a>
</div>
</div>
</div>
</div>
</header>
<main>
<div>
{{ if ne (len .gists) 0 }}
{{ range $gist := .gists }}
<div class="mb-8">
<div class="flex">
<h4 class="text-md leading-tight break-all py-1 flex-auto">
<a href="/{{ $gist.User.Username }}">{{ $gist.User.Username }}</a> <span class="text-slate-300">/</span> <a class="font-bold" href="/{{ $gist.User.Username }}/{{ $gist.Uuid }}">{{ $gist.Title }}</a>
</h4>
<div class="flex space-x-4">
<div class="flex items-center float-right text-sm">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-1 inline-flex">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" />
</svg>
<span>{{ $gist.NbLikes }} likes</span>
</div>
<div class="flex items-center float-right text-sm">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-1 inline-flex">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.25 9.75L16.5 12l-2.25 2.25m-4.5 0L7.5 12l2.25-2.25M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z" />
</svg>
<span>{{ $gist.NbFiles }} files</span>
</div>
</div>
</div>
<h5 class="text-sm text-slate-500 pb-1">Last active <span class="moment-timestamp">{{ $gist.UpdatedAt }}</span>
{{ if $gist.Private }} • <span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-700 text-slate-300"> Unlisted </span>{{ end }}</h5>
<h5 class="text-xs text-slate-300 py-1">{{ $gist.Description }}</h5>
<a href="/{{ $gist.User.Username }}/{{ $gist.Uuid }}" class="hover:text-slate-300">
<div class="rounded-md border border-1 border-gray-700 overflow-auto hover:border-primary-600">
<div class="code overflow-auto">
{{ if isMarkdown $gist.PreviewFilename }}
<div class="markdown markdown-body p-8">{{ $gist.Preview }}</div>
{{ else }}
<table class="table-code w-full whitespace-pre" data-filename="{{ $gist.PreviewFilename }}" style="font-size: 0.8em; border-spacing: 0; border-collapse: collapse;">
<tbody>
{{ $ii := "1" }}
{{ $i := toInt $ii }}
{{ range $line := lines $gist.Preview }}
<tr>
<td class="select-none line-num px-4">{{$i}}</td>
<td class="line-code">{{ $line }}</td>
</tr>
{{ $i = inc $i }}
{{ end }}
</tbody>
</table>
{{ end }}
</div>
</div>
</a>
</div>
{{ end }}
{{ template "pagination" . }}
{{ else }}
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10l-2 1m0 0l-2-1m2 1v2.5M20 7l-2 1m2-1l-2-1m2 1v2.5M14 4l-2-1-2 1M4 7l2-1M4 7l2 1M4 7v2.5M12 21l-2-1m2 1l2-1m-2 1v-2.5M6 18l-2-1v-2.5M18 18l2-1v-2.5" />
</svg>
<h3 class="mt-2 text-sm font-medium text-slate-300">No gists</h3>
</div>
{{ end }}
</div>
</main>
</div>
{{ template "footer" .}}

58
templates/pages/auth_form.html vendored Normal file
View File

@ -0,0 +1,58 @@
{{ template "header" .}}
<div class="py-10">
<header>
<h1 class="text-2xl font-bold leading-tight text-slate-300">
{{ .title }}
</h1>
</header>
<main class="mt-4">
{{ if and .signupDisabled (ne .title "Login") }}
<p class="italic">Administrator has disabled signing up</p>
{{ else }}
<div class="sm:col-span-6">
<div class="mt-8 sm:w-full sm:max-w-md">
<div class="bg-gray-900 rounded-md border border-1 border-gray-700 py-8 px-4 shadow sm:rounded-lg sm:px-10">
<form class="space-y-6" action="#" method="post">
<div>
<label for="username" class="block text-sm font-medium text-slate-300"> Username </label>
<div class="mt-1">
<input id="username" name="username" type="text" required class="bg-gray-800 appearance-none block w-full px-3 py-2 border border-gray-700 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
</div>
</div>
<div class="mt-8">
<label for="password" class="block text-sm font-medium text-slate-300"> Password </label>
<div class="mt-1">
<input id="password" name="password" type="password" autocomplete="current-password" required class="bg-gray-800 appearance-none block w-full px-3 py-2 border border-gray-700 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
</div>
</div>
{{ if eq .title "Login" }}
<div class="flex">
<div class="flex-auto">
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">Login</button>
</div>
{{ if not .signupDisabled }}
<span class="float-right text-sm py-2 underline"><a href="/register">Register instead →</a></span>
{{ end }}
</div>
{{ else }}
<div class="flex">
<div class="flex-auto">
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">Register</button>
</div>
<span class="float-right text-sm py-2 underline"><a href="/login">Login instead →</a></span>
</div>
{{ end }}
{{ .csrfHtml }}
</form>
</div>
</div>
</div>
{{ end }}
</main>
</div>
{{ template "footer" .}}

49
templates/pages/create.html vendored Normal file
View File

@ -0,0 +1,49 @@
{{ template "header" .}}
<div class="py-10">
<header>
<h1 class="text-2xl font-bold leading-tight text-slate-300">
New Gist
</h1>
</header>
<main class="mt-4">
<form id="create" class="space-y-4" method="post" action="/">
<div class="grid grid-cols-12 gap-x-4">
<div class="col-span-4">
<div class="mt-1">
<input type="text" placeholder="Title" name="title" id="title" class="bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-md">
</div>
</div>
<div class="col-span-8">
<div class="mt-1">
<input type="text" placeholder="Description" name="description" id="description" class="bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-md">
</div>
</div>
</div>
<div id="editors" class="space-y-4">
<div class="rounded-md border border-1 border-gray-700 editor">
<div class="border-b-1 border-gray-700 bg-gray-800 my-auto">
<p class="mx-2 my-2 inline-flex">
<input type="text" name="name" placeholder="Filename with extension" style="line-height: 0.05em" class="form-filename bg-gray-900 shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-md">
</p>
</div>
<input type="hidden" value="" name="content" class="form-filecontent">
</div>
</div>
<div class="flex">
<button type="button" id="add-file" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">Add file</button>
<button type="submit" name="private" value="1" class="ml-auto inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">Create unlisted gist</button>
<button type="submit" name="private" value="0" class="ml-2 inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">Create public gist</button>
</div>
{{ .csrfHtml }}
</form>
</main>
</div>
<script type="module" src="http://localhost:3000/editor.js"></script>
{{ template "footer" .}}

57
templates/pages/edit.html vendored Normal file
View File

@ -0,0 +1,57 @@
{{ template "header" .}}
<div class="py-10">
<header>
<h1 class="text-2xl font-bold leading-tight text-slate-300">
Editing {{ .gist.Title }}
</h1>
</header>
<main class="mt-4">
<form id="create" class="space-y-4" method="post" action="/{{ .gist.User.Username }}/{{ .gist.Uuid }}/edit">
<div class="grid grid-cols-12 gap-x-4">
<div class="sm:col-span-4">
<div class="mt-1">
<input type="text" value="{{ .gist.Title }}" placeholder="Title" name="title" id="title" class="bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-md">
</div>
</div>
<div class="sm:col-span-8">
<div class="mt-1">
<input type="text" value="{{ .gist.Description }}" placeholder="Description" name="description" id="description" class="bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-md">
</div>
</div>
</div>
<div id="editors" class="space-y-4">
{{ range $filename, $content := .files }}
<div class="rounded-md border border-1 border-gray-700 editor">
<div class="border-b-1 border-gray-700 bg-gray-800 my-auto">
<p class="mx-2 my-2 inline-flex">
<input type="text" value="{{ $filename }}" name="name" placeholder="Filename with extension" style="line-height: 0.05em; z-index: 99999" class="form-filename bg-gray-900 shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-700 rounded-l-md">
<button style="line-height: 0.05em" class="delete-file -ml-px relative inline-flex items-center space-x-2 px-4 py-2 border border-gray-700 text-sm font-medium rounded-r-md text-slate-300 bg-gray-800 hover:bg-gray-900 focus:outline-none" type="button">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</button>
</p>
</div>
<input type="hidden" value="{{ $content }}" name="content" class="form-filecontent">
</div>
{{ end }}
</div>
<div class="flex">
<button type="button" id="add-file" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">Add file</button>
<a href="/{{ .gist.User.Username }}/{{ .gist.Uuid }}" type="submit" name="private" value="1" class="ml-auto inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 text-rose-400 hover:text-rose-400">Cancel</a>
<button type="submit" name="private" value="0" class="ml-2 inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">Save</button>
</div>
{{ .csrfHtml }}
</form>
</main>
</div>
<script type="module" src="http://localhost:3000/editor.js"></script>
{{ template "footer" .}}

14
templates/pages/error.html vendored Normal file
View File

@ -0,0 +1,14 @@
{{ template "header" .}}
<div class="mt-4">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="h-12 w-12 text-slate-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
</svg>
<h1 class="mt-2 text-3xl font-medium text-slate-300">Error {{ .error.Code }}</h1>
<h3 class="mt-2 text-md font-medium text-slate-300">{{ httpStatusText .error.Code }}</h3>
{{ if lt .error.Code 500 }}
<p class="mt-2 text-sm font-medium text-slate-300">{{ .error.Message }}</p>
{{ end }}
</div>
{{ template "footer" .}}

45
templates/pages/gist.html vendored Normal file
View File

@ -0,0 +1,45 @@
{{ template "header" .}}
{{ template "gist_header" .}}
{{ if .files }}
<div class="grid gap-y-4">
{{ range $filename, $content := .files }}
<div class="rounded-md border border-1 border-gray-700 overflow-auto">
<div class="border-b-1 border-gray-700 bg-gray-800 my-auto block">
<div class="ml-4 py-1.5 flex">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 flex text-slate-300" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
</svg>
<span class="flex-auto ml-2 text-sm text-slate-300 filename" id="file-{{ slug $filename }}"><a href="#file-{{ slug $filename }}">{{ $filename }}</a></span>
<button class="float-right mx-2 px-2.5 py-0.5 leading-4 rounded-full text-xs font-medium bg-gray-600 border border-gray-500 hover:bg-gray-700 hover:text-slate-300 select-none copy-gist-btn"> Copy </button>
<a href="/{{ $.gist.User.Username }}/{{ $.gist.Uuid }}/raw/{{ $.commit }}/{{$filename}}" class="float-right mr-2 px-2.5 py-0.5 leading-4 rounded-full text-xs font-medium bg-gray-600 border border-gray-500 hover:bg-gray-700 hover:text-slate-300 select-none"> Raw </a>
<div class="hidden gist-content">{{ $content }}</div>
</div>
</div>
<div class="code overflow-auto">
{{ if isMarkdown $filename }}
<div class="markdown markdown-body p-8">{{ $content }}</div>
{{ else }}
{{ $fileslug := slug $filename }}
<table class="table-code w-full whitespace-pre" data-filename-slug="{{ $fileslug }}" data-filename="{{ $filename }}" style="font-size: 0.8em; border-spacing: 0; border-collapse: collapse;">
<tbody>
{{ $ii := "1" }}
{{ $i := toInt $ii }}
{{ range $line := lines $content }}<tr><td id="file-{{ $fileslug }}-{{$i}}" class="select-none line-num px-4">{{$i}}</td><td class="line-code">{{ $line }}</td></tr>{{ $i = inc $i }}{{ end }}
</tbody>
</table>
{{ end }}
</div>
</div>
{{ end }}
</div>
{{ else }}
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10l-2 1m0 0l-2-1m2 1v2.5M20 7l-2 1m2-1l-2-1m2 1v2.5M14 4l-2-1-2 1M4 7l2-1M4 7l2 1M4 7v2.5M12 21l-2-1m2 1l2-1m-2 1v-2.5M6 18l-2-1v-2.5M18 18l2-1v-2.5" />
</svg>
<h3 class="mt-2 text-sm font-medium text-slate-300">No content</h3>
</div>
{{ end }}
{{ template "gist_footer" .}}
{{ template "footer" .}}

27
templates/pages/likes.html vendored Normal file
View File

@ -0,0 +1,27 @@
{{ template "header" .}}
{{ template "gist_header" .}}
{{ if ne (len .likers) 0 }}
<h3 class="text-xl font-bold leading-tight break-all py-2">Likes</h3>
<div class="grid grid-cols-1 gap-4 sm:grid-cols-5">
{{ range $user := .likers }}
<div class="relative flex items-center space-x-3 rounded-lg border border-gray-600 bg-gray-800 px-6 py-5 shadow-sm focus-within:ring-1 focus-within:border-primary-500 focus-within:ring-primary-500 hover:border-gray-400">
<div class="min-w-0 flex-1">
<a href="/{{ $user.Username }}" class="focus:outline-none">
<span class="absolute inset-0" aria-hidden="true"></span>
<p class="text-sm font-medium text-slate-300">{{ $user.Username }}</p>
</a>
</div>
</div>
{{ end }}
</div>
{{ else }}
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mx-auto h-12 w-12 text-slate-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" />
</svg>
<h3 class="mt-2 text-sm font-medium text-slate-300">No likes yet</h3>
</div>
{{ end }}
{{ template "gist_footer" .}}
{{ template "footer" .}}

110
templates/pages/revisions.html vendored Normal file
View File

@ -0,0 +1,110 @@
{{ template "header" .}}
{{ template "gist_header" .}}
{{ if ne (len .commits) 0 }}
<div>
{{ range $commit := .commits }}
<div class="pb-8">
<div class="flex">
<h3 class="text-sm py-2 flex-auto"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1 inline" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M13 5l7 7-7 7M5 5l7 7-7 7" />
</svg><span class="font-bold">{{ $commit.Author }}</span> revised this gist <span class="moment-timestamp font-bold">{{ $commit.Timestamp }}</span>. <a class="underline" href="/{{ $.gist.User.Username }}/{{ $.gist.Uuid }}/rev/{{ $commit.Hash }}">Go to revision</a></h3>
{{ if ne $commit.Changed "" }}
<p class="text-sm float-right py-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 inline-flex">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" />
</svg>
{{ $commit.Changed }}
{{ end }}
</p>
</div>
<div class="grid gap-y-4">
{{ if ne (len $commit.Files) 0 }}
{{ range $file := $commit.Files }}
<div class="rounded-md border border-1 border-gray-700 overflow-auto">
<div class="border-b-1 border-gray-700 bg-gray-800 my-auto">
<p class="ml-4 mt-2 inline-flex">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 flex text-slate-300" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
</svg>
{{ if eq $file.Filename $file.OldFilename }}
<span class="flex text-sm ml-2 text-slate-300">{{ $file.Filename }}</span>
{{ else }}
{{ if eq $file.OldFilename "/dev/null" }}
<span class="flex text-sm ml-2 text-slate-300">{{ $file.Filename }}<span class="italic text-gray-400 ml-1">(file created)</span></span>
{{ else if eq $file.Filename "/dev/null" }}
<span class="flex text-sm ml-2 text-slate-300">{{ $file.OldFilename }} <span class="italic text-gray-400 ml-1">(file deleted)</span></span>
{{ else }}
<span class="flex text-sm ml-2 text-slate-300">{{ $file.OldFilename }} <span class="italic text-gray-400 mx-1">renamed to</span> {{ $file.Filename }}</span>
{{ end }}
{{ end }}
</p>
</div>
<div class="code overflow-auto">
{{ if eq $file.Content "" }}
<p class="m-2 ml-4 text-sm">
File renamed without changes.
</p>
{{ else }}
<table class="table-code w-full whitespace-pre" data-filename="{{ $file.Filename }}" style="font-size: 0.8em; border-spacing: 0">
<tbody>
{{ $left := 0 }}
{{ $right := 0 }}
{{ range $line := split $file.Content "\n" }}
{{ if ne $line "" }}{{ if ne (index $line 0) 92 }}
{{ if eq (index $line 0) 64 }}
{{ $left = toInt (index (splitGit (index (split $line "-") 1)) 0) }}
{{ $right = toInt (index (splitGit (index (split $line "+") 1)) 0) }}
{{ end }}
<tr class="{{ if eq (index $line 0) 64 }}gray-diff{{ end }}{{ if eq (index $line 0) 43 }}green-diff{{ end }}{{ if eq (index $line 0) 45 }}red-diff{{ end }}" >
{{ if eq (index $line 0) 64 }}
<td colspan="2" class="select-none py-3"></td>
{{ else }}
{{ if eq (index $line 0) 43 }}
<td class="select-none line-num px-2"></td>
<td class="select-none line-num px-2">{{ $right }}</td>
{{ $right = inc $right }}
{{ else if eq (index $line 0) 45 }}
<td class="select-none line-num px-2">{{ $left }}</td>
<td class="select-none line-num px-2"></td>
{{ $left = inc $left }}
{{ else if eq (index $line 0) 32 }}
<td class="select-none line-num px-2">{{ $left }}</td>
<td class="select-none line-num px-2">{{ $right }}</td>
{{ $left = inc $left }}
{{ $right = inc $right }}
{{ end }}
{{ end }}
<td class="select-none" style="width: 2%;">{{ if ne (index $line 0) 64 }}{{ slice $line 0 1 }}{{ end }}</td>
<td>{{ if ne (index $line 0) 64 }}{{ slice $line 1 }}{{ else }}{{ $line }}{{ end }}</td>
</tr>
{{end}}
{{end}}{{end}}
</tbody>
</table>
{{ end }}
</div>
</div>
{{end}}
{{else}}
<p class="text-left text-sm text-slate-300 italic">No changes</p>
{{end}}
</div>
</div>
{{end}}
</div>
<div class="flex justify-center space-x-2">
{{ template "pagination" . }}
</div>
{{ else }}
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10l-2 1m0 0l-2-1m2 1v2.5M20 7l-2 1m2-1l-2-1m2 1v2.5M14 4l-2-1-2 1M4 7l2-1M4 7l2 1M4 7v2.5M12 21l-2-1m2 1l2-1m-2 1v-2.5M6 18l-2-1v-2.5M18 18l2-1v-2.5" />
</svg>
<h3 class="mt-2 text-sm font-medium text-slate-300">No revisions to show</h3>
</div>
{{ end }}
{{ template "gist_footer" .}}
{{ template "footer" .}}

73
templates/pages/ssh_keys.html vendored Normal file
View File

@ -0,0 +1,73 @@
{{ template "header" .}}
<div class="py-10">
<header class="pb-4">
<div>
<h1 class="text-2xl font-bold leading-tight">SSH Keys</h1>
<p class="text-sm text-gray-400 italic">Used only to pull/push gists using Git via SSH</p>
</div>
</header>
<main>
<div >
<div class="sm:grid grid-cols-2 gap-x-4 md:gap-x-16">
<div class="w-full">
<div class="bg-gray-900 rounded-md border border-1 border-gray-700 py-8 px-4 shadow sm:rounded-lg sm:px-10">
<h2 class="text-md font-bold text-slate-300 mb-4">
Add SSH Key
</h2>
<form class="space-y-6" action="#" method="post">
<div>
<label for="title" class="block text-sm font-medium text-slate-300"> Title </label>
<div class="mt-1">
<input id="title" name="title" type="text" required autocomplete="off" class="bg-gray-800 appearance-none block w-full px-3 py-2 border border-gray-700 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
</div>
</div>
<div class="mt-8">
<label for="sshkey" class="block text-sm font-medium text-slate-300"> Key </label>
<div class="mt-1">
<textarea id="sshkey" required autocomplete="off" name="content" class="bg-gray-800 appearance-none block w-full px-3 py-2 border border-gray-700 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"></textarea>
</div>
</div>
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent border-gray-700 text-sm font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">Add key</button>
{{ .csrfHtml }}
</form>
</div>
</div>
<div>
<div class="mt-6 flow-root">
<ul role="list" class="-my-5 divide-y divide-gray-700 list-none">
{{ if .sshKeys }}
{{ range $key := .sshKeys }}
<li class="py-5">
<div class="inline-flex">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mr-4">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z" />
</svg>
<div>
<h3 class="text-sm font-semibold text-slate-300">{{ .Title }}</h3>
<p class="mt-1 text-xs text-slate-400 line-clamp-2 code" style="overflow-wrap: anywhere">SHA256:{{.SHA}}</p>
<p class="text-xs text-gray-500 line-clamp-2">Added <span class="moment-timestamp-date">{{ .CreatedAt }}</span></p>
{{ if eq .LastUsedAt 0 }}
<p class="text-xs text-gray-500 line-clamp-2">Never used</p>
{{ else }}
<p class="text-xs text-gray-500 line-clamp-2">Last used <span class="moment-timestamp">{{ .LastUsedAt }}</span></p>
{{ end }}
</div>
<form action="/ssh-keys/{{.ID}}" method="post" class="inline-block" onsubmit="return confirm('Confirm deletion of SSH key')">
<input type="hidden" name="_method" value="DELETE">
{{ $.csrfHtml }}
<button type="submit" class="align-middle items-center leading-2 ml-2 px-3 py-1 border border-transparent border-gray-700 text-xs font-medium rounded-md shadow-sm text-white bg-rose-600 hover:bg-rose-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-rose-500">Delete</button>
</form>
</div>
</li>
{{ end }}
{{ end }}
</ul>
</div>
</div>
</div>
</div>
</main>
</div>
{{ template "footer" .}}