opengist/templates/pages/all.html

130 lines
10 KiB
HTML
Raw Normal View History

2023-03-14 15:22:52 +00:00
{{ template "header" .}}
<div class="py-10">
<header class="pb-4 flex ">
<div class="flex-auto">
2023-03-20 12:30:25 +00:00
{{if .fromUser}}
<div class="flex items-center">
<div class="flex-shrink-0">
2023-05-27 11:58:08 +00:00
<img class="h-12 w-12 rounded-md mr-2 border border-gray-200 dark:border-gray-700" src="{{ avatarUrl .fromUser .DisableGravatar }}" alt="">
2023-03-20 12:30:25 +00:00
</div>
<div>
<h1 class="text-2xl font-bold leading-tight">{{.fromUser.Username}}</h1>
<p class="text-sm text-slate-500">Joined <span class="moment-timestamp">{{.fromUser.CreatedAt}}</span></p>
</div>
</div>
{{ else }}
<h1 class="text-2xl font-bold leading-tight">All gists</h1>
{{ end }}
2023-03-14 15:22:52 +00:00
</div>
<div class="float-right">
<div class="relative inline-block text-left">
<div>
2023-05-27 11:58:08 +00:00
<button type="button" class="whitespace-nowrap inline-flex text-slate-700 dark:text-slate-300 rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 px-2.5 py-2 text-xs font-medium text-gray-700 dark:text-white shadow-sm hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-500 hover:text-slate-700 dark: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-700 dark:text-gray-300">Sort : <span class="text-slate-700 dark:text-slate-300">{{.order}} {{.sort}}</span></span>
2023-03-14 15:22:52 +00:00
<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>
2023-05-27 11:58:08 +00:00
<div id="sort-gists-dropdown" class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right divide-y divide-gray-300 dark:divide-gray-700 rounded-md rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 shadow-lg ring-1 ring-white dark:ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1">
2023-03-14 15:22:52 +00:00
<div class="" role="none">
2023-05-27 11:58:08 +00:00
<a href="/{{if .fromUser}}{{.fromUser.Username}}{{else}}all{{end}}?sort=created&order=desc" class="text-slate-700 dark:text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white hover:text-white hover:bg-primary-500 hover:rounded-t-md" role="menuitem">
2023-03-14 15:22:52 +00:00
Recently created
</a>
</div>
<div class="" role="none">
2023-05-27 11:58:08 +00:00
<a href="/{{if .fromUser}}{{.fromUser.Username}}{{else}}all{{end}}?sort=created&order=asc" class="text-slate-700 dark:text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white hover:text-white hover:bg-primary-500" role="menuitem">
2023-03-14 15:22:52 +00:00
Least recently created
</a>
2023-05-27 11:58:08 +00:00
</div>
<div class="" role="none">
<a href="/{{if .fromUser}}{{.fromUser.Username}}{{else}}all{{end}}?sort=updated&order=desc" class="text-slate-700 dark:text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white hover:text-white hover:bg-primary-500" role="menuitem">
2023-03-14 15:22:52 +00:00
Recently updated
</a>
</div>
<div class="" role="none">
2023-05-27 11:58:08 +00:00
<a href="/{{if .fromUser}}{{.fromUser.Username}}{{else}}all{{end}}?sort=updated&order=asc" class="text-slate-700 dark:text-slate-300 group flex items-center px-3 py-2 text-xs hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white hover:text-white hover:bg-primary-500 hover:rounded-b-md" role="menuitem">
2023-03-14 15:22:52 +00:00
Least recently updated
</a>
</div>
</div>
</div>
</div>
</header>
<main>
<div>
{{ if ne (len .gists) 0 }}
{{ range $gist := .gists }}
<div class="mb-8">
2023-03-15 11:59:18 +00:00
<div class="flex flex-col lg:flex-row">
2023-03-14 15:22:52 +00:00
<h4 class="text-md leading-tight break-all py-1 flex-auto">
2023-05-27 11:58:08 +00:00
<a href="/{{ $gist.User.Username }}">{{ $gist.User.Username }}</a> <span class="text-slate-700 dark:text-slate-300">/</span> <a class="font-bold" href="/{{ $gist.User.Username }}/{{ $gist.Uuid }}">{{ $gist.Title }}</a>
2023-03-14 15:22:52 +00:00
</h4>
2023-03-15 11:59:18 +00:00
<div class="flex space-x-4 lg:flex-row flex py-1 lg:py-0 lg:ml-auto text-slate-500">
<div class="flex items-center float-right text-xs">
<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 mr-1 inline-flex">
2023-03-14 15:22:52 +00:00
<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>
2023-03-15 11:59:18 +00:00
<span class="whitespace-nowrap">{{ $gist.NbLikes }} likes</span>
2023-03-14 15:22:52 +00:00
</div>
2023-03-15 11:59:18 +00:00
<div class="flex items-center float-right text-xs">
<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 mr-1 inline-flex">
2023-03-14 22:26:39 +00:00
<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>
2023-03-15 11:59:18 +00:00
<span class="whitespace-nowrap">{{ $gist.NbForks }} forks</span>
2023-03-14 22:26:39 +00:00
</div>
2023-03-15 11:59:18 +00:00
<div class="flex items-center float-right text-xs">
<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 mr-1 inline-flex">
2023-03-14 15:22:52 +00:00
<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>
2023-03-15 11:59:18 +00:00
<span class="whitespace-nowrap">{{ $gist.NbFiles }} files</span>
2023-03-14 15:22:52 +00:00
</div>
</div>
</div>
<h5 class="text-sm text-slate-500 pb-1">Last active <span class="moment-timestamp">{{ $gist.UpdatedAt }}</span>
2023-03-14 22:26:39 +00:00
{{ if $gist.Forked }} • Forked from <a href="/{{ $gist.Forked.User.Username }}/{{ $gist.Forked.Uuid }}">{{ $gist.Forked.User.Username }}/{{ $gist.Forked.Title }}</a> {{ end }}
2023-05-27 11:58:08 +00:00
{{ if $gist.Private }} • <span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 dark:bg-gray-700 text-slate-700 dark:text-slate-300"> Unlisted </span>{{ end }}</h5>
<h5 class="text-xs text-slate-700 dark:text-slate-300 py-1">{{ $gist.Description }}</h5>
<a href="/{{ $gist.User.Username }}/{{ $gist.Uuid }}" class="text-slate-700 dark:text-slate-300">
<div class="rounded-md border border-1 border-gray-200 dark:border-gray-700 overflow-auto hover:border-primary-600">
2023-03-14 15:22:52 +00:00
<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">
2023-05-27 11:58:08 +00:00
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-slate-600 dark:text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
2023-03-14 15:22:52 +00:00
<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>
2023-05-27 11:58:08 +00:00
<h3 class="mt-2 text-sm font-medium text-slate-700 dark:text-slate-300">No gists</h3>
2023-03-14 15:22:52 +00:00
</div>
{{ end }}
</div>
</main>
</div>
{{ template "footer" .}}