forked from kevadesu/forgejo
[GITEA] convert feed items' titles to plain text
Refs: https://codeberg.org/forgejo/forgejo/pulls/1595 (cherry picked from commit35b962e631
) (cherry picked from commit1004e35b84
) (cherry picked from commitaf51dd594d
) (cherry picked from commitef10fae296
) (cherry picked from commitff8027ed1b
) (cherry picked from commit2540ff52ef
) (cherry picked from commit57b4d775e1
) (cherry picked from commitc388aba9b5
) (cherry picked from commit7a3b605c11
)
This commit is contained in:
parent
5d6892ec10
commit
cc02354d0a
2 changed files with 49 additions and 1 deletions
|
@ -21,6 +21,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/gorilla/feeds"
|
||||
"github.com/jaytaylor/html2text"
|
||||
)
|
||||
|
||||
func toBranchLink(ctx *context.Context, act *activities_model.Action) string {
|
||||
|
@ -239,8 +240,15 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio
|
|||
content = desc
|
||||
}
|
||||
|
||||
// It's a common practice for feed generators to use plain text titles.
|
||||
// See https://codeberg.org/forgejo/forgejo/pulls/1595
|
||||
plainTitle, err := html2text.FromString(title, html2text.Options{OmitLinks: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
items = append(items, &feeds.Item{
|
||||
Title: title,
|
||||
Title: plainTitle,
|
||||
Link: link,
|
||||
Description: desc,
|
||||
Author: &feeds.Author{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue