Show a Hugging Face repository's model card on the mirror page

Opening a repository shows its model card, rendered from markdown, with
its base model, license and languages above it; the listing names each
repository's base model and license under its name. The card is a
stranger's text: raw HTML and dangerous links are dropped, images are
shown as links rather than loaded, and relative links point into the
repository.

Adds github.com/yuin/goldmark for the markdown.

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 22:03:19 +02:00
1 parent 02fa639657
commit 3fea39feb9
10 files changed
+375 -27

No files matched your search

+14 -1
View File
@@ -122,7 +122,11 @@ type adminMirrorData struct {
Query string
Explore *explorer
// Back is the listing an open repository was reached from.
Back template.URL
Back template.URL
// Card is the open repository's model card, rendered.
Card template.HTML
// RepoURL is the open repository on the registry's own site.
RepoURL string
Repo *hf.Repo
RepoSets []repoSet
RegistryErr string
@@ -466,6 +470,8 @@ func (p *AccountPages) explore(r *http.Request, d *adminMirrorData) {
return
}
d.Repo = &got
d.RepoURL = strings.TrimSuffix(got.DownloadURL("", ""), "/resolve/"+revOrMain(got.Revision)+"/")
d.Card = renderCard(got.Card, d.RepoURL+"/blob/"+revOrMain(got.Revision)+"/")
var weights []hf.File
for _, f := range got.Files {
if !f.IsWeights() {
@@ -532,3 +538,10 @@ func (p *AccountPages) checkSource(ctx context.Context, source string) gguf.Verd
}
return gguf.Check(ctx, url, p.llamaVersion)
}
func revOrMain(rev string) string {
if rev == "" {
return "main"
}
return rev
}