summaryrefslogtreecommitdiffstats
path: root/routers/web/user
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-03-13 17:40:47 +0100
committerGitHub <noreply@github.com>2022-03-13 17:40:47 +0100
commitbc0d2c8ada14eae81542f30a81552ed5cef8bd5d (patch)
tree5242a9e288f53cfc04e56df495a048d02a902d91 /routers/web/user
parent780cf76f6e930b5e92fd12ae1e729c5702e70afa (diff)
downloadgitea-bc0d2c8ada14eae81542f30a81552ed5cef8bd5d.tar.gz
gitea-bc0d2c8ada14eae81542f30a81552ed5cef8bd5d.zip
RSS/Atom support for Repos (#19055)
* support for repos * refactor * advertise the feeds via meta tags * allow feed suffix and feed header * optimize performance
Diffstat (limited to 'routers/web/user')
-rw-r--r--routers/web/user/home.go7
-rw-r--r--routers/web/user/profile.go26
2 files changed, 12 insertions, 21 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 379e1f8e20..877aa45280 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -29,7 +29,6 @@ import (
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
- "code.gitea.io/gitea/routers/web/feed"
issue_service "code.gitea.io/gitea/services/issue"
pull_service "code.gitea.io/gitea/services/pull"
@@ -131,7 +130,7 @@ func Dashboard(ctx *context.Context) {
ctx.Data["MirrorCount"] = len(mirrors)
ctx.Data["Mirrors"] = mirrors
- ctx.Data["Feeds"] = feed.RetrieveFeeds(ctx, models.GetFeedsOptions{
+ ctx.Data["Feeds"], err = models.GetFeeds(ctx, models.GetFeedsOptions{
RequestedUser: ctxUser,
RequestedTeam: ctx.Org.Team,
Actor: ctx.User,
@@ -140,8 +139,8 @@ func Dashboard(ctx *context.Context) {
IncludeDeleted: false,
Date: ctx.FormString("date"),
})
-
- if ctx.Written() {
+ if err != nil {
+ ctx.ServerError("GetFeeds", err)
return
}
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index b4198ef8fd..b84cee2b3a 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -74,19 +74,7 @@ func Profile(ctx *context.Context) {
uname = strings.TrimSuffix(uname, ".gpg")
}
- showFeedType := ""
- if strings.HasSuffix(uname, ".rss") {
- showFeedType = "rss"
- uname = strings.TrimSuffix(uname, ".rss")
- } else if strings.Contains(ctx.Req.Header.Get("Accept"), "application/rss+xml") {
- showFeedType = "rss"
- }
- if strings.HasSuffix(uname, ".atom") {
- showFeedType = "atom"
- uname = strings.TrimSuffix(uname, ".atom")
- } else if strings.Contains(ctx.Req.Header.Get("Accept"), "application/atom+xml") {
- showFeedType = "atom"
- }
+ isShowFeed, uname, showFeedType := feed.GetFeedType(uname, ctx.Req)
ctxUser := GetUserByName(ctx, uname)
if ctx.Written() {
@@ -95,7 +83,7 @@ func Profile(ctx *context.Context) {
if ctxUser.IsOrganization() {
// Show Org RSS feed
- if len(showFeedType) != 0 {
+ if isShowFeed {
feed.ShowUserFeed(ctx, ctxUser, showFeedType)
return
}
@@ -123,11 +111,14 @@ func Profile(ctx *context.Context) {
}
// Show User RSS feed
- if len(showFeedType) != 0 {
+ if isShowFeed {
feed.ShowUserFeed(ctx, ctxUser, showFeedType)
return
}
+ // advertise feed via meta tag
+ ctx.Data["FeedURL"] = ctxUser.HTMLURL()
+
// Show OpenID URIs
openIDs, err := user_model.GetUserOpenIDs(ctxUser.ID)
if err != nil {
@@ -259,7 +250,7 @@ func Profile(ctx *context.Context) {
total = ctxUser.NumFollowing
case "activity":
- ctx.Data["Feeds"] = feed.RetrieveFeeds(ctx, models.GetFeedsOptions{
+ ctx.Data["Feeds"], err = models.GetFeeds(ctx, models.GetFeedsOptions{
RequestedUser: ctxUser,
Actor: ctx.User,
IncludePrivate: showPrivate,
@@ -267,7 +258,8 @@ func Profile(ctx *context.Context) {
IncludeDeleted: false,
Date: ctx.FormString("date"),
})
- if ctx.Written() {
+ if err != nil {
+ ctx.ServerError("GetFeeds", err)
return
}
case "stars":