Open the mirror's registry on what is current, not an empty search box

The mirror page lists Hugging Face's trending models without anything
typed, with views for what is new this month and what is most
downloaded, filters for task and size, and each repository's parameter
count, architecture, context length and age from one registry call.
"Only what these nodes can run" is on by default and leaves out
architectures the nodes' llama.cpp cannot load, and adapters, saying how
many it hid. Listings are remembered for ten minutes.

The stylesheet is now linked by a hash of its content. It is cached for
a day, so under a fixed name a deploy's new styles reached people a day
after its markup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-09-28 21:56:58 +02:00
1 parent 5aa5675a9c
commit 02fa639657
20 files changed
+632 -52

No files matched your search

+8 -11
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"gitea.mynodes.xyz/ilker/llmgw/internal/control/catalog"
"gitea.mynodes.xyz/ilker/llmgw/internal/gguf"
"html/template"
"net/http"
"sort"
"strconv"
@@ -36,7 +37,7 @@ type MirrorAdmin interface {
// off, which is right for a deployment with no way out to the internet: a
// search box that can only time out is worse than no search box.
type Registry interface {
Search(ctx context.Context, query string, limit int) ([]hf.Model, error)
Explore(ctx context.Context, q hf.Query) ([]hf.Model, error)
Repo(ctx context.Context, id string) (hf.Repo, error)
}
@@ -119,7 +120,9 @@ type adminMirrorData struct {
// The explorer.
HasRegistry bool
Query string
Results []hf.Model
Explore *explorer
// Back is the listing an open repository was reached from.
Back template.URL
Repo *hf.Repo
RepoSets []repoSet
RegistryErr string
@@ -442,7 +445,7 @@ func plural(n int, one, many string) string {
return strconv.Itoa(n) + " " + many
}
// explore fills in the registry half of the page: a search, or one repository.
// explore fills in the registry half of the page: a listing, or one repository.
//
// A failure here is reported in its own line rather than as the page's error.
// The registry is somebody else's server on the other side of the internet, and
@@ -456,6 +459,7 @@ func (p *AccountPages) explore(r *http.Request, d *adminMirrorData) {
d.Query = strings.TrimSpace(r.URL.Query().Get("q"))
if repo := strings.TrimSpace(r.URL.Query().Get("repo")); repo != "" {
d.Back = exploreState(r.URL.Query()).href(d.Query, "", "")
got, err := p.registry.Repo(r.Context(), repo)
if err != nil {
d.RegistryErr = err.Error()
@@ -491,14 +495,7 @@ func (p *AccountPages) explore(r *http.Request, d *adminMirrorData) {
return
}
if d.Query != "" {
got, err := p.registry.Search(r.Context(), d.Query, 20)
if err != nil {
d.RegistryErr = err.Error()
return
}
d.Results = got
}
p.exploreList(r, d)
}
// defaultModelName is the catalog name a repository suggests.