Skip to content

Commit 3ce0c67

Browse files
committed
advertise the feeds via meta tags
1 parent 51b0c34 commit 3ce0c67

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

routers/web/repo/view.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ func Home(ctx *context.Context) {
698698
return
699699
}
700700

701+
ctx.Data["FeedURL"] = ctx.Repo.Repository.HTMLURL()
702+
701703
checkHomeCodeViewable(ctx)
702704
if ctx.Written() {
703705
return

routers/web/user/profile.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func Profile(ctx *context.Context) {
7575
}
7676

7777
uname, showFeedType := feed.GetFeedType(uname, ctx.Req)
78+
isShowFeed := len(showFeedType) != 0
7879

7980
ctxUser := GetUserByName(ctx, uname)
8081
if ctx.Written() {
@@ -83,7 +84,7 @@ func Profile(ctx *context.Context) {
8384

8485
if ctxUser.IsOrganization() {
8586
// Show Org RSS feed
86-
if len(showFeedType) != 0 {
87+
if isShowFeed {
8788
feed.ShowUserFeed(ctx, ctxUser, showFeedType)
8889
return
8990
}
@@ -111,11 +112,14 @@ func Profile(ctx *context.Context) {
111112
}
112113

113114
// Show User RSS feed
114-
if len(showFeedType) != 0 {
115+
if isShowFeed {
115116
feed.ShowUserFeed(ctx, ctxUser, showFeedType)
116117
return
117118
}
118119

120+
// advertise feed via meta tag
121+
ctx.Data["FeedURL"] = ctxUser.HTMLURL()
122+
119123
// Show OpenID URIs
120124
openIDs, err := user_model.GetUserOpenIDs(ctxUser.ID)
121125
if err != nil {

templates/base/head.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
{{if .GoGetImport}}
1515
<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">
1616
<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}">
17+
{{end}}
18+
{{if .FeedURL}}
19+
<link rel="alternate" type="application/atom+xml" title="" href="{{.FeedURL}}.atom">
20+
<link rel="alternate" type="application/rss+xml" title="" href="{{.FeedURL}}.rss">
1721
{{end}}
1822
<script>
1923
<!-- /* eslint-disable */ -->

0 commit comments

Comments
 (0)