Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

RSS/Atom support for Repos #19055

Merged
merged 14 commits into from
Mar 13, 2022
Merged

RSS/Atom support for Repos #19055

merged 14 commits into from
Mar 13, 2022

Conversation

6543
Copy link
Member

@6543 6543 commented Mar 10, 2022

close #569

@6543 6543 added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Mar 10, 2022
@6543 6543 added this to the 1.17.0 milestone Mar 10, 2022
@6543 6543 mentioned this pull request Mar 10, 2022
4 tasks
@6543 6543 mentioned this pull request Mar 10, 2022
3 tasks
Copy link
Member

@noerw noerw left a comment

Choose a reason for hiding this comment

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

nice!

I wonder where a button in the UI linking to the feed URL could be nicely placed..?

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Mar 11, 2022
@noerw
Copy link
Member

noerw commented Mar 11, 2022

Here's a diff to advertise the feeds via meta tags:
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index f4d2fccef..4896f16e0 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -698,6 +698,8 @@ func Home(ctx *context.Context) {
 		return
 	}
 
+	ctx.Data["FeedURL"] = ctx.Repo.Repository.HTMLURL()
+
 	checkHomeCodeViewable(ctx)
 	if ctx.Written() {
 		return
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 718ad6dc7..29687a23c 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -75,6 +75,7 @@ func Profile(ctx *context.Context) {
 	}
 
 	uname, showFeedType := feed.GetFeedType(uname, ctx.Req)
+	isShowFeed := len(showFeedType) != 0
 
 	ctxUser := GetUserByName(ctx, uname)
 	if ctx.Written() {
@@ -83,7 +84,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
 		}
@@ -111,11 +112,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 {
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index 32e206a95..666246a18 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -14,6 +14,10 @@
 {{if .GoGetImport}}
 	<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">
 	<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}">
+{{end}}
+{{if .FeedURL}}
+	<link rel="alternate" type="application/atom+xml" title="" href="{{.FeedURL}}.atom">
+	<link rel="alternate" type="application/rss+xml" title="" href="{{.FeedURL}}.rss">
 {{end}}
 	<script>
 		<!-- /* eslint-disable */ -->

@6543
Copy link
Member Author

6543 commented Mar 12, 2022

@noerw applyed

@6543 6543 requested a review from delvh March 12, 2022 16:49
@6543 6543 requested a review from delvh March 12, 2022 23:47
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 13, 2022
@6543 6543 merged commit bc0d2c8 into go-gitea:main Mar 13, 2022
@6543 6543 deleted the rss-repo branch March 13, 2022 16:40
@6543 6543 mentioned this pull request Mar 13, 2022
11 tasks
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 14, 2022
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Fix documentation and go-gitea#19065 (go-gitea#19067)
  RSS/Atom support for Repos (go-gitea#19055)
  [skip ci] Updated licenses and gitignores
  Feeds: render markdown to html (go-gitea#19058)
  [skip ci] Updated translations via Crowdin
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
* support for repos
* refactor
* advertise the feeds via meta tags
* allow feed suffix and feed header
* optimize performance
@6543 6543 mentioned this pull request Apr 28, 2022
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic RSS support
4 participants