mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat(rss): use server title and description for RSS feed, if configured (#4717)
This commit is contained in:
@@ -26,6 +26,11 @@ type RSSService struct {
|
|||||||
Store *store.Store
|
Store *store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RSSHeading struct {
|
||||||
|
Title string
|
||||||
|
Description string
|
||||||
|
}
|
||||||
|
|
||||||
func NewRSSService(profile *profile.Profile, store *store.Store) *RSSService {
|
func NewRSSService(profile *profile.Profile, store *store.Store) *RSSService {
|
||||||
return &RSSService{
|
return &RSSService{
|
||||||
Profile: profile,
|
Profile: profile,
|
||||||
@@ -93,10 +98,14 @@ func (s *RSSService) GetUserRSS(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*store.Memo, baseURL string) (string, error) {
|
func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*store.Memo, baseURL string) (string, error) {
|
||||||
|
rssHeading, err := getRSSHeading(s.Store, ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
feed := &feeds.Feed{
|
feed := &feeds.Feed{
|
||||||
Title: "Memos",
|
Title: rssHeading.Title,
|
||||||
Link: &feeds.Link{Href: baseURL},
|
Link: &feeds.Link{Href: baseURL},
|
||||||
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
|
Description: rssHeading.Description,
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,3 +159,21 @@ func getRSSItemDescription(content string) (string, error) {
|
|||||||
result := renderer.NewHTMLRenderer().Render(nodes)
|
result := renderer.NewHTMLRenderer().Render(nodes)
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRSSHeading(store *store.Store, ctx context.Context) (RSSHeading, error) {
|
||||||
|
settings, err := store.GetWorkspaceGeneralSetting(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return RSSHeading{}, err
|
||||||
|
}
|
||||||
|
if settings == nil || settings.CustomProfile == nil {
|
||||||
|
return RSSHeading{
|
||||||
|
Title: "Memos",
|
||||||
|
Description: "An open source, lightweight note-taking service. Easily capture and share your great thoughts.",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
customProfile := settings.CustomProfile
|
||||||
|
return RSSHeading{
|
||||||
|
Title: customProfile.Title,
|
||||||
|
Description: customProfile.Description,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user