Search page more explicit

This commit is contained in:
Thomas Miceli 2023-06-23 13:59:07 +02:00
parent 7b5d035a32
commit 9470622125
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F
3 changed files with 14 additions and 9 deletions

View file

@ -121,7 +121,8 @@ func allGists(ctx echo.Context) error {
if strings.HasSuffix(urlctx, "search") { if strings.HasSuffix(urlctx, "search") {
setData(ctx, "htmlTitle", "Search results") setData(ctx, "htmlTitle", "Search results")
setData(ctx, "mode", "search") setData(ctx, "mode", "search")
setData(ctx, "searchQuery", template.URL("&q="+ctx.QueryParam("q"))) setData(ctx, "searchQuery", ctx.QueryParam("q"))
setData(ctx, "searchQueryUrl", template.URL("&q="+ctx.QueryParam("q")))
urlPage = "search" urlPage = "search"
gists, err = models.GetAllGistsFromSearch(currentUserId, ctx.QueryParam("q"), pageInt-1, sort, order) gists, err = models.GetAllGistsFromSearch(currentUserId, ctx.QueryParam("q"), pageInt-1, sort, order)
} else if strings.HasSuffix(urlctx, "all") { } else if strings.HasSuffix(urlctx, "all") {

View file

@ -73,7 +73,7 @@
</svg> </svg>
</div> </div>
<form action="/search" method="GET"> <form action="/search" method="GET">
<input id="search" name="q" class="bg-white dark:bg-gray-900 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 pl-10" placeholder="Search" type="search"> <input id="search" name="q" class="bg-white dark:bg-gray-900 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 pl-10" placeholder="Search" type="search" value="{{ .searchQuery }}">
<input type="submit" hidden="hidden"> <input type="submit" hidden="hidden">
</form> </form>
</div> </div>
@ -191,7 +191,7 @@
<!-- Mobile menu --> <!-- Mobile menu -->
<div class="sm:hidden hidden" id="mobile-menu"> <div class="sm:hidden hidden" id="mobile-menu">
<div class="mx-2"> <div class="mx-2">
<label for="search" class="sr-only">Search</label> <label for="searchmobile" class="sr-only">Search</label>
<div class="relative"> <div class="relative">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"> <div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> <svg class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@ -199,7 +199,7 @@
</svg> </svg>
</div> </div>
<form action="/search" method="GET"> <form action="/search" method="GET">
<input id="search" name="q" class="bg-white dark:bg-gray-900 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 pl-10" placeholder="Search" type="search"> <input id="searchmobile" name="q" class="bg-white dark:bg-gray-900 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 pl-10" placeholder="Search" type="search" value="{{.searchQuery}}">
<input type="submit" hidden="hidden"> <input type="submit" hidden="hidden">
</form> </form>
</div> </div>

View file

@ -14,7 +14,11 @@
</div> </div>
</div> </div>
{{ else }} {{ else }}
<h1 class="text-2xl font-bold leading-tight">All gists</h1> {{ if eq .mode "all" }}
<h1 class="text-2xl font-bold leading-tight">All gists</h1>
{{ else if eq .mode "search" }}
<h1 class="text-2xl font-bold leading-tight">Search results</h1>
{{ end }}
{{ end }} {{ end }}
</div> </div>
<div class="align-middle inline-flex items-center"> <div class="align-middle inline-flex items-center">
@ -29,22 +33,22 @@
</div> </div>
<div id="sort-gists-dropdown" class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right divide-y divide-gray-200 dark:divide-gray-700 rounded-md rounded border border-gray-200 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"> <div id="sort-gists-dropdown" class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right divide-y divide-gray-200 dark:divide-gray-700 rounded-md rounded border border-gray-200 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">
<div class="" role="none"> <div class="" role="none">
<a href="/{{ .urlPage }}?sort=created&order=desc{{.searchQuery}}" 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"> <a href="/{{ .urlPage }}?sort=created&order=desc{{.searchQueryUrl}}" 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">
Recently created Recently created
</a> </a>
</div> </div>
<div class="" role="none"> <div class="" role="none">
<a href="/{{ .urlPage }}?sort=created&order=asc{{.searchQuery}}" 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"> <a href="/{{ .urlPage }}?sort=created&order=asc{{.searchQueryUrl}}" 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">
Least recently created Least recently created
</a> </a>
</div> </div>
<div class="" role="none"> <div class="" role="none">
<a href="/{{ .urlPage }}?sort=updated&order=desc{{.searchQuery}}" 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"> <a href="/{{ .urlPage }}?sort=updated&order=desc{{.searchQueryUrl}}" 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">
Recently updated Recently updated
</a> </a>
</div> </div>
<div class="" role="none"> <div class="" role="none">
<a href="/{{ .urlPage }}?sort=updated&order=asc{{.searchQuery}}" 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"> <a href="/{{ .urlPage }}?sort=updated&order=asc{{.searchQueryUrl}}" 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">
Least recently updated Least recently updated
</a> </a>
</div> </div>