-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add RSS Feeds for branches and files #22719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
a43e056
implementing the rss feed for branches not connected to router yet
jladbrook bd6f6e5
adding feed generation for a file
jladbrook 6279b02
refactored feed rendering and updated home implementation
jladbrook b95ff66
Merge branch 'main' into rss-22228
jladbrook 41db639
Merge branch 'main' into rss-22228
jladbrook d277548
responding to feedback removing .rss suffix from branches
jladbrook 955bc04
Merge branch 'main' into rss-22228
jladbrook a9095e1
Merge branch 'main' into rss-22228
6543 ca1d6b7
Merge branch 'main' into rss-22228
jladbrook 32579ed
addressing comments from feedback
jladbrook b29d1ef
updating view templates adding feed buttons
jladbrook f796c36
don't inline svg use the svg helper instead
jladbrook 20cb77f
Merge branch 'main' into rss-22228
6543 6590760
Merge branch 'main' into rss-22228
silverwind f573e75
Merge branch 'main' into rss-22228
6543 54d2304
Merge branch 'main' into rss-22228
6543 b195361
Merge branch 'main' into rss-22228
6543 e2bf743
Merge branch 'main' into rss-22228
jladbrook e9126e7
updating ui as per feedback
jladbrook abdf073
relocate buttons on home and view_file
jladbrook 9d763f2
adding feed buttons on the branches page
jladbrook e461fbc
add rss feed links to the drop-down menu and remove from the main page
jladbrook a674624
Merge branch 'main' into rss-22228
jladbrook 8ab322d
Merge branch 'main' into rss-22228
jladbrook 081b40d
revert changes in response to #24904 and fix rss path from dropdown box
jladbrook 3d63b4c
fix: lint-frontend failure
jladbrook b32be23
Merge branch 'main' into rss-22228
jladbrook 4a30a23
Merge branch 'main' into rss-22228
jladbrook 30e6d1d
mute link in branch dropdown
silverwind d5a6055
Merge branch 'main' into rss-22228
silverwind 9591255
Merge branch 'main' into rss-22228
jladbrook 8b225c5
remove reference to setting.EnableFeed
jladbrook b9669b2
remove custom rule and use ui.right
jladbrook dcd6f9d
remove unecessary jump from button
jladbrook 172280d
addressing reviewers feedback
jladbrook f1b03c5
Merge branch 'main' into rss-22228
GiteaBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package feed | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/context" | ||
|
||
"github.com/gorilla/feeds" | ||
) | ||
|
||
// ShowBranchFeed shows tags and/or releases on the repo as RSS / Atom feed | ||
func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType string) { | ||
commits, err := ctx.Repo.Commit.CommitsByRange(0, 10) | ||
if err != nil { | ||
ctx.ServerError("ShowBranchFeed %s", err) | ||
return | ||
} | ||
|
||
title := fmt.Sprintf("Latest commits for branch %s", ctx.Repo.BranchName) | ||
link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.BranchNameSubURL()} | ||
|
||
feed := &feeds.Feed{ | ||
Title: title, | ||
Link: link, | ||
Description: repo.Description, | ||
Created: time.Now(), | ||
} | ||
|
||
for _, commit := range commits { | ||
feed.Items = append(feed.Items, &feeds.Item{ | ||
Id: commit.ID.String(), | ||
Title: strings.TrimSpace(strings.Split(commit.Message(), "\n")[0]), | ||
Link: &feeds.Link{Href: repo.HTMLURL() + "/commit/" + commit.ID.String()}, | ||
Author: &feeds.Author{ | ||
Name: commit.Author.Name, | ||
Email: commit.Author.Email, | ||
}, | ||
Description: commit.Message(), | ||
Content: commit.Message(), | ||
}) | ||
} | ||
|
||
writeFeed(ctx, feed, formatType) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package feed | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/context" | ||
|
||
"github.com/gorilla/feeds" | ||
) | ||
|
||
// ShowFileFeed shows tags and/or releases on the repo as RSS / Atom feed | ||
func ShowFileFeed(ctx *context.Context, repo *repo.Repository, formatType string) { | ||
fileName := ctx.Repo.TreePath | ||
if len(fileName) == 0 { | ||
return | ||
} | ||
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(ctx.Repo.RefName, fileName, 1) | ||
if err != nil { | ||
ctx.ServerError("ShowBranchFeed %s", err) | ||
return | ||
} | ||
|
||
title := fmt.Sprintf("Latest commits for file %s", ctx.Repo.TreePath) | ||
link := &feeds.Link{Href: repo.HTMLURL() + "/" + ctx.Repo.BranchNameSubURL() + "/" + ctx.Repo.TreePath} | ||
|
||
feed := &feeds.Feed{ | ||
Title: title, | ||
Link: link, | ||
Description: repo.Description, | ||
Created: time.Now(), | ||
} | ||
|
||
for _, commit := range commits { | ||
feed.Items = append(feed.Items, &feeds.Item{ | ||
Id: commit.ID.String(), | ||
Title: strings.TrimSpace(strings.Split(commit.Message(), "\n")[0]), | ||
Link: &feeds.Link{Href: repo.HTMLURL() + "/commit/" + commit.ID.String()}, | ||
Author: &feeds.Author{ | ||
Name: commit.Author.Name, | ||
Email: commit.Author.Email, | ||
}, | ||
Description: commit.Message(), | ||
Content: commit.Message(), | ||
}) | ||
} | ||
|
||
writeFeed(ctx, feed, formatType) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package feed | ||
|
||
import ( | ||
model "code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/context" | ||
) | ||
|
||
// RenderBranchFeed render format for branch or file | ||
func RenderBranchFeed(ctx *context.Context) { | ||
_, _, showFeedType := GetFeedType(ctx.Params(":reponame"), ctx.Req) | ||
var renderer func(ctx *context.Context, repo *model.Repository, formatType string) | ||
switch { | ||
case ctx.Repo.TreePath == "": | ||
renderer = ShowBranchFeed | ||
case ctx.Repo.TreePath != "": | ||
renderer = ShowFileFeed | ||
} | ||
renderer(ctx, ctx.Repo.Repository, showFeedType) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.