Add topics for Gists (#413)

This commit is contained in:
Thomas Miceli
2025-01-24 14:39:42 +01:00
committed by GitHub
parent 8369cbf2f0
commit f5b8881d35
25 changed files with 278 additions and 59 deletions

View File

@ -114,6 +114,7 @@
<p class="text-gray-400"><code class="text-slate-800 dark:text-slate-300 pr-1">filename:myfile.txt</code> {{ .locale.Tr "gist.search.help.filename" }}</p>
<p class="text-gray-400"><code class="text-slate-800 dark:text-slate-300 pr-1">extension:yml</code> {{ .locale.Tr "gist.search.help.extension" }}</p>
<p class="text-gray-400"><code class="text-slate-800 dark:text-slate-300 pr-1">language:go</code> {{ .locale.Tr "gist.search.help.language" }}</p>
<p class="text-gray-400"><code class="text-slate-800 dark:text-slate-300 pr-1">topic:homelab</code> {{ .locale.Tr "gist.search.help.topic" }}</p>
</div>
</div>
</div>

View File

@ -95,6 +95,13 @@
{{ 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"> {{ visibilityStr .gist.Private false }} </span>{{ end }}
</p>
<p class="mt-1 text-sm max-w-2xl text-slate-600 dark:text-slate-400">{{ .gist.Description }}</p>
{{ if .gist.Topics }}
<div class="mt-2">
{{ range .gist.Topics }}
<a href="{{ $.c.ExternalUrl }}/topics/{{ .Topic }}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-primary-200 text-primary-900 hover:bg-primary-300 dark:bg-primary-950 dark:text-primary-200 dark:hover:bg-primary-900">{{ .Topic }}</a>
{{ end }}
</div>
{{ end }}
</header>
<main class="mt-4">

View File

@ -18,6 +18,8 @@
<h1 class="text-2xl font-bold leading-tight">{{ .locale.Tr "gist.list.all" }}</h1>
{{ else if eq .mode "search" }}
<h1 class="text-2xl font-bold leading-tight">{{ .locale.Tr "gist.list.search-results" }}</h1>
{{ else if eq .mode "topics" }}
<h1 class="text-2xl font-bold leading-tight">{{ .locale.Tr "gist.list.topic-results" }} <span class="items-center px-2 py-0.5 rounded bg-primary-200 text-primary-900 hover:bg-primary-300 dark:bg-primary-950 dark:text-primary-200 dark:hover:bg-primary-900">{{ .topic }}</span></h1>
{{ end }}
{{ end }}
</div>
@ -58,7 +60,7 @@
</div>
</div>
{{ if and (ne .mode "all") (ne .mode "search") }}
{{ if and (ne .mode "all") (ne .mode "search") (ne .mode "topics") }}
<div class="mt-4">
<div class="sm:hidden">
<label for="tabs" class="sr-only">{{ .locale.Tr "gist.list.select-tab" }}</label>

View File

@ -25,6 +25,10 @@
<div class="col-span-6 sm:col-span-3 mt-2">
<input type="text" placeholder="{{ .locale.Tr "gist.new.url" }}" name="url" id="url" class="bg-white dark:bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-200 dark:border-gray-700 rounded-md" maxlength="32">
</div>
<div class="col-span-12 sm:col-span-9 mt-2">
<input type="text" placeholder="{{ .locale.Tr "gist.new.topics" }}" name="topics" id="topics" class="bg-white dark:bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-200 dark:border-gray-700 rounded-md">
</div>
</div>
</div>
<div id="editors" class="space-y-4">

View File

@ -58,6 +58,9 @@
<div class="col-span-6 sm:col-span-3 mt-2">
<input type="text" value="{{ .gist.URL }}" placeholder="{{ .locale.Tr "gist.new.url" }}" name="url" id="url" class="bg-white dark:bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-200 dark:border-gray-700 rounded-md" maxlength="32">
</div>
<div class="col-span-12 sm:col-span-9 mt-2">
<input type="text" value="{{ topicsToStr .gist.Topics }}" placeholder="{{ .locale.Tr "gist.new.topics" }}" name="topics" id="topics" class="bg-white dark:bg-black shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-200 dark:border-gray-700 rounded-md">
</div>
</div>
</div>
<div id="editors" class="space-y-4">

View File

@ -38,7 +38,18 @@
<h5 class="text-sm text-slate-500 pb-1">{{ .locale.Tr "gist.list.last-active" }} <span class="moment-timestamp">{{ .gist.UpdatedAt }}</span>
{{ if .gist.Forked }} • {{ .locale.Tr "gist.list.forked-from" }} <a href="{{ .c.ExternalUrl }}/{{ .gist.Forked.User.Username }}/{{ .gist.Forked.Identifier }}">{{ .gist.Forked.User.Username }}/{{ .gist.Forked.Title }}</a> {{ end }}
{{ 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"> {{ visibilityStr .gist.Private false }} </span>{{ end }}</h5>
<h6 class="text-xs text-slate-700 dark:text-slate-300 py-1">{{ .gist.Description }}</h6>
<div class="flex items-center gap-2 mb-2">
{{ if len .gist.Description }}
<h6 class="text-xs text-slate-700 dark:text-slate-300">{{ .gist.Description }}</h6>
{{ end }}
{{ if len .gist.TopicsSlice }}
<div class="flex flex-wrap items-center gap-1">
{{ range .gist.TopicsSlice }}
<a href="{{ $.c.ExternalUrl }}/topics/{{ . }}" class="inline-flex items-center px-2 py-0.5 rounded text-xs bg-primary-200 text-primary-900 hover:bg-primary-300 dark:bg-primary-950 dark:text-primary-200 dark:hover:bg-primary-900">{{ . }}</a>
{{ end }}
</div>
{{ end }}
</div>
</div>
</div>
<a href="{{ .c.ExternalUrl }}/{{ .gist.User.Username }}/{{ .gist.Identifier }}" class="text-slate-700 dark:text-slate-300">