0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-17 19:42:55 +02:00
This commit is contained in:
Philip Peterson 2025-05-27 20:55:30 -07:00
parent 845a290fcd
commit e984f30bc1
6 changed files with 15 additions and 11 deletions

View File

@ -17,7 +17,7 @@ func SVG(icon string, others ...any) g.Node {
}
// Utility to add "active" class if condition is true
func classIf(condition bool, class string) string {
func classIf(condition bool, class string) string { //nolint:unparam
if condition {
return class
}

View File

@ -10,7 +10,7 @@ import (
type ExploreNavbarProps struct {
PageIsExploreRepositories bool
UsersPageIsDisabled bool
AppSubUrl string
AppSubURL string
PageIsExploreUsers bool
PageIsExploreCode bool
IsRepoIndexerEnabled bool
@ -33,14 +33,14 @@ func ExploreNavbar(data ExploreNavbarProps) g.Node {
gh.Class("overflow-menu-items tw-justify-center"),
gh.A(
gh.Class(classIf(data.PageIsExploreRepositories, "active ")+"item"),
gh.Href(data.AppSubUrl+"/explore/repos"),
gh.Href(data.AppSubURL+"/explore/repos"),
SVG("octicon-repo"),
g.Text(" "+tr("explore.repos")),
),
If(!data.UsersPageIsDisabled,
gh.A(
gh.Class(classIf(data.PageIsExploreUsers, "active ")+"item"),
gh.Href(data.AppSubUrl+"/explore/users"),
gh.Href(data.AppSubURL+"/explore/users"),
SVG("octicon-person"),
g.Text(" "+tr("explore.users")),
),
@ -48,7 +48,7 @@ func ExploreNavbar(data ExploreNavbarProps) g.Node {
If(!data.OrganizationsPageIsDisabled,
gh.A(
gh.Class(classIf(data.PageIsExploreOrganizations, "active ")+"item"),
gh.Href(data.AppSubUrl+"/explore/organizations"),
gh.Href(data.AppSubURL+"/explore/organizations"),
SVG("octicon-organization"),
g.Text(" "+tr("explore.organizations")),
),
@ -56,7 +56,7 @@ func ExploreNavbar(data ExploreNavbarProps) g.Node {
If(!isCodeGlobalDisabled && data.IsRepoIndexerEnabled && !data.CodePageIsDisabled,
gh.A(
gh.Class(classIf(data.PageIsExploreCode, "active ")+"item"),
gh.Href(data.AppSubUrl+"/explore/code"),
gh.Href(data.AppSubURL+"/explore/code"),
SVG("octicon-code"),
g.Text(" "+tr("explore.code")),
),

View File

@ -35,7 +35,7 @@ func UserList(data UserListProps) g.Node {
return gh.Div(
gh.Class("flex-list"),
g.Group(g.Map(data.Users, func(u *user.User) g.Node {
g.Map(data.Users, func(u *user.User) g.Node {
utils := templates.NewAvatarUtils(data.Context)
return gh.Div(
@ -86,6 +86,6 @@ func UserList(data UserListProps) g.Node {
),
),
)
})),
}),
)
}

View File

@ -57,7 +57,7 @@ func (h *HTMLRender) HTML(w io.Writer, status int, tplName TplName, data any, ct
return t.Execute(w, data)
}
func (h *HTMLRender) Gomponents(w io.Writer, status int, data []byte) error { //nolint:revive
func (h *HTMLRender) Gomponents(w io.Writer, status int, data []byte) error {
if respWriter, ok := w.(http.ResponseWriter); ok {
if respWriter.Header().Get("Content-Type") == "" {
respWriter.Header().Set("Content-Type", "text/html; charset=utf-8")

View File

@ -232,7 +232,11 @@ func RenderUserSearch2(ctx *context.Context, opts user_model.SearchUserOptions,
})
var bodyBuffer bytes.Buffer
data.Render(&bodyBuffer)
err = data.Render(&bodyBuffer)
if err != nil {
ctx.ServerError("RenderUserSearch().data.Render", err)
return
}
ctx.Gomponents(http.StatusOK, bodyBuffer.String(), "ExploreUsersPage")
}

View File

@ -199,7 +199,7 @@ func (tr *MockRender) HTML(w io.Writer, status int, _ templates.TplName, _ any,
return nil
}
func (tr *MockRender) Gomponents(w io.Writer, status int, _ string) error {
func (tr *MockRender) Gomponents(w io.Writer, status int, _ []byte) error {
if resp, ok := w.(http.ResponseWriter); ok {
resp.WriteHeader(status)
}