Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT


//go:build vendor

package main
Expand Down
16 changes: 15 additions & 1 deletion routers/web/feed/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"

"github.com/gorilla/feeds"
)
Expand Down Expand Up @@ -39,10 +41,22 @@ func showUserFeed(ctx *context.Context, formatType string) {
return
}

ctxUserDescription, err := markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
URLPrefix: ctx.ContextUser.HTMLURL(),
Metas: map[string]string{
"user": ctx.ContextUser.GetDisplayName(),
},
}, ctx.ContextUser.Description)
if err != nil {
ctx.ServerError("RenderString", err)
return
}

feed := &feeds.Feed{
Title: ctx.Tr("home.feed_of", ctx.ContextUser.DisplayName()),
Link: &feeds.Link{Href: ctx.ContextUser.HTMLURL()},
Description: ctx.ContextUser.Description,
Description: ctxUserDescription,
Created: time.Now(),
}

Expand Down
48 changes: 38 additions & 10 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"os"
"path"
"strings"

"code.gitea.io/gitea/models/perm"
"code.gitea.io/gitea/models/unit"
Expand Down Expand Up @@ -672,16 +673,43 @@ func RegisterRoutes(m *web.Route) {
})
http.ServeFile(ctx.Resp, ctx.Req, path.Join(setting.StaticRootPath, "public/img/favicon.png"))
})
m.Group("/{username}", func() {
m.Get(".png", user.AvatarByUserName)
m.Get(".keys", user.ShowSSHKeys)
m.Get(".gpg", user.ShowGPGKeys)
m.Get(".rss", feedEnabled, feed.ShowUserFeedRSS)
m.Get(".atom", feedEnabled, feed.ShowUserFeedAtom)
m.Get("", user.Profile)
}, func(ctx *context.Context) {
ctx.Data["EnableFeed"] = setting.EnableFeed
}, context_service.UserAssignmentWeb())
m.Get("/{username}", func(ctx *context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think this function should get moved out of web.go and into a named function within routers/web/user - and we should probably also update the routing.UpdateFuncInfo(req.Context(), ...) (Although we should do that without causing the funcInfo to be generated at run time.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the best case the upstream issue get solved ...

the question is if we wana have that workaround now in or engineer around it properly ... or wait for upstream

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have personally given up on waiting for chi to fix any issues 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that would mean we must fix and submit a patch upstream 😆

// WORKAROUND to support usernames with "." in it
// https://github.com/go-chi/chi/issues/781
username := ctx.Params("username")
switch {
case strings.HasSuffix(username, ".png"):
ctx.SetParams("username", strings.TrimSuffix(username, ".png"))
context_service.UserAssignmentWeb()(ctx)
user.AvatarByUserName(ctx)
case strings.HasSuffix(username, ".keys"):
ctx.SetParams("username", strings.TrimSuffix(username, ".keys"))
context_service.UserAssignmentWeb()(ctx)
user.ShowSSHKeys(ctx)
case strings.HasSuffix(username, ".gpg"):
ctx.SetParams("username", strings.TrimSuffix(username, ".gpg"))
context_service.UserAssignmentWeb()(ctx)
user.ShowGPGKeys(ctx)
case strings.HasSuffix(username, ".rss"):
feedEnabled(ctx)
if !ctx.Written() {
ctx.SetParams("username", strings.TrimSuffix(username, ".rss"))
context_service.UserAssignmentWeb()(ctx)
feed.ShowUserFeedRSS(ctx)
}
case strings.HasSuffix(username, ".atom"):
feedEnabled(ctx)
if !ctx.Written() {
ctx.SetParams("username", strings.TrimSuffix(username, ".atom"))
context_service.UserAssignmentWeb()(ctx)
feed.ShowUserFeedAtom(ctx)
}
default:
context_service.UserAssignmentWeb()(ctx)
ctx.Data["EnableFeed"] = setting.EnableFeed
user.Profile(ctx)
}
})
m.Get("/attachments/{uuid}", repo.GetAttachment)
}, ignSignIn)

Expand Down