Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update memo resource url
Stevenf4ac7ff52945
diff --git a/api/v1/memo.go b/api/v1/memo.goindex 919745215..f1a962cd6 100644--- a/api/v1/memo.go+++ b/api/v1/memo.go@@ -46,7 +46,8 @@ func (v Visibility) String() string {}type Memo struct {- ID int32 `json:"id"`+ ID int32 `json:"id"`+ Name string `json:"name"`// Standard fieldsRowStatus RowStatus `json:"rowStatus"`@@ -832,6 +833,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Memo) (*Memo, error) {memoMessage := &Memo{ID: memo.ID,+ Name: memo.ResourceName,RowStatus: RowStatus(memo.RowStatus.String()),CreatorID: memo.CreatorID,CreatedTs: memo.CreatedTs,diff --git a/api/v1/rss.go b/api/v1/rss.goindex 3732b6827..31a5245e5 100644--- a/api/v1/rss.go+++ b/api/v1/rss.go@@ -3,7 +3,6 @@ package v1import ("context""encoding/json"- "fmt""net/http""strconv""strings"@@ -127,10 +126,9 @@ func (s *APIV1Service) generateRSSFromMemoList(ctx context.Context, memoList []*}feed.Items[i] = &feeds.Item{Title: getRSSItemTitle(memoMessage.Content),- Link: &feeds.Link{Href: baseURL + "/m/" + fmt.Sprintf("%d", memoMessage.ID)},+ Link: &feeds.Link{Href: baseURL + "/m/" + memoMessage.Name},Description: description,Created: time.Unix(memoMessage.CreatedTs, 0),- Enclosure: &feeds.Enclosure{Url: baseURL + "/m/" + fmt.Sprintf("%d", memoMessage.ID) + "/image"},}if len(memoMessage.ResourceList) > 0 {resource := memoMessage.ResourceList[0]diff --git a/server/frontend/frontend.go b/server/frontend/frontend.goindex d1b01a04d..24d5f2491 100644--- a/server/frontend/frontend.go+++ b/server/frontend/frontend.go@@ -43,7 +43,7 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {Root: "dist",HTML5: true,Skipper: func(c echo.Context) bool {- return util.HasPrefixes(c.Path(), "/api", "/memos.api.v2", "/robots.txt", "/sitemap.xml", "/m/:memoID")+ return util.HasPrefixes(c.Path(), "/api", "/memos.api.v2", "/robots.txt", "/sitemap.xml", "/m/:name")},}))@@ -54,16 +54,11 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {func (s *FrontendService) registerRoutes(e *echo.Echo) {rawIndexHTML := getRawIndexHTML()- e.GET("/m/:memoID", func(c echo.Context) error {+ e.GET("/m/:name", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := util.ConvertStringToInt32(c.Param("memoID"))- if err != nil {- // Redirect to `index.html` if any error occurs.- return c.HTML(http.StatusOK, rawIndexHTML)- }-+ resourceName := c.Param("name")memo, err := s.Store.GetMemo(ctx, &store.FindMemo{- ID: &memoID,+ ResourceName: &resourceName,})if err != nil {return c.HTML(http.StatusOK, rawIndexHTML)@@ -116,7 +111,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL)return err}for _, memo := range memoList {- urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%d", instanceURL, memo.ID)))+ urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%s", instanceURL, memo.ResourceName)))}sitemap := fmt.Sprintf(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">%s</urlset>`, strings.Join(urlsets, "\n"))return c.XMLBlob(http.StatusOK, []byte(sitemap))