fix: pass empty condition in rss (#1058)

fix: handle empty condition in rss
pull/1060/head
boojack 2 years ago committed by GitHub
parent 5df59a48b7
commit a004dcf320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,10 +14,6 @@ import (
)
func generateRSSFromMemoList(memoList []*api.Memo, baseURL string, profile *api.CustomizedProfile) (string, error) {
if len(memoList) == 0 {
return "", nil
}
feed := &feeds.Feed{
Title: profile.Name,
Link: &feeds.Link{Href: baseURL},
@ -56,10 +52,7 @@ func generateRSSFromMemoList(memoList []*api.Memo, baseURL string, profile *api.
if err != nil {
return "", err
}
rssPrefix := `<?xml version="1.0" encoding="UTF-8"?>`
return rss[len(rssPrefix):], nil
return rss, nil
}
func (s *Server) registerRSSRoutes(g *echo.Group) {
@ -84,13 +77,13 @@ func (s *Server) registerRSSRoutes(g *echo.Group) {
}
baseURL := c.Scheme() + "://" + c.Request().Host
rss, err := generateRSSFromMemoList(memoList, baseURL, &systemCustomizedProfile)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate rss").SetInternal(err)
}
return c.XMLBlob(http.StatusOK, []byte(rss))
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationXMLCharsetUTF8)
return c.String(http.StatusOK, rss)
})
g.GET("/u/:id/rss.xml", func(c echo.Context) error {
@ -125,8 +118,8 @@ func (s *Server) registerRSSRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate rss").SetInternal(err)
}
return c.XMLBlob(http.StatusOK, []byte(rss))
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationXMLCharsetUTF8)
return c.String(http.StatusOK, rss)
})
}

@ -13,7 +13,7 @@
}
> .title-text {
@apply font-bold text-lg leading-10 mr-2 text-ellipsis shrink-0 cursor-pointer overflow-hidden text-gray-700 dark:text-gray-200;
@apply font-bold text-lg leading-10 mr-1 text-ellipsis shrink-0 cursor-pointer overflow-hidden text-gray-700 dark:text-gray-200;
}
}

Loading…
Cancel
Save