Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
f4ac7ff5
Commit
f4ac7ff5
authored
Jan 28, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update memo resource url
parent
55ecdae5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
14 deletions
+9
-14
memo.go
api/v1/memo.go
+3
-1
rss.go
api/v1/rss.go
+1
-3
frontend.go
server/frontend/frontend.go
+5
-10
No files found.
api/v1/memo.go
View file @
f4ac7ff5
...
@@ -46,7 +46,8 @@ func (v Visibility) String() string {
...
@@ -46,7 +46,8 @@ func (v Visibility) String() string {
}
}
type
Memo
struct
{
type
Memo
struct
{
ID
int32
`json:"id"`
ID
int32
`json:"id"`
Name
string
`json:"name"`
// Standard fields
// Standard fields
RowStatus
RowStatus
`json:"rowStatus"`
RowStatus
RowStatus
`json:"rowStatus"`
...
@@ -832,6 +833,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
...
@@ -832,6 +833,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
func
(
s
*
APIV1Service
)
convertMemoFromStore
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
(
*
Memo
,
error
)
{
func
(
s
*
APIV1Service
)
convertMemoFromStore
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
(
*
Memo
,
error
)
{
memoMessage
:=
&
Memo
{
memoMessage
:=
&
Memo
{
ID
:
memo
.
ID
,
ID
:
memo
.
ID
,
Name
:
memo
.
ResourceName
,
RowStatus
:
RowStatus
(
memo
.
RowStatus
.
String
()),
RowStatus
:
RowStatus
(
memo
.
RowStatus
.
String
()),
CreatorID
:
memo
.
CreatorID
,
CreatorID
:
memo
.
CreatorID
,
CreatedTs
:
memo
.
CreatedTs
,
CreatedTs
:
memo
.
CreatedTs
,
...
...
api/v1/rss.go
View file @
f4ac7ff5
...
@@ -3,7 +3,6 @@ package v1
...
@@ -3,7 +3,6 @@ package v1
import
(
import
(
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
"net/http"
"net/http"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -127,10 +126,9 @@ func (s *APIV1Service) generateRSSFromMemoList(ctx context.Context, memoList []*
...
@@ -127,10 +126,9 @@ func (s *APIV1Service) generateRSSFromMemoList(ctx context.Context, memoList []*
}
}
feed
.
Items
[
i
]
=
&
feeds
.
Item
{
feed
.
Items
[
i
]
=
&
feeds
.
Item
{
Title
:
getRSSItemTitle
(
memoMessage
.
Content
),
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
,
Description
:
description
,
Created
:
time
.
Unix
(
memoMessage
.
CreatedTs
,
0
),
Created
:
time
.
Unix
(
memoMessage
.
CreatedTs
,
0
),
Enclosure
:
&
feeds
.
Enclosure
{
Url
:
baseURL
+
"/m/"
+
fmt
.
Sprintf
(
"%d"
,
memoMessage
.
ID
)
+
"/image"
},
}
}
if
len
(
memoMessage
.
ResourceList
)
>
0
{
if
len
(
memoMessage
.
ResourceList
)
>
0
{
resource
:=
memoMessage
.
ResourceList
[
0
]
resource
:=
memoMessage
.
ResourceList
[
0
]
...
...
server/frontend/frontend.go
View file @
f4ac7ff5
...
@@ -43,7 +43,7 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {
...
@@ -43,7 +43,7 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {
Root
:
"dist"
,
Root
:
"dist"
,
HTML5
:
true
,
HTML5
:
true
,
Skipper
:
func
(
c
echo
.
Context
)
bool
{
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) {
...
@@ -54,16 +54,11 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {
func
(
s
*
FrontendService
)
registerRoutes
(
e
*
echo
.
Echo
)
{
func
(
s
*
FrontendService
)
registerRoutes
(
e
*
echo
.
Echo
)
{
rawIndexHTML
:=
getRawIndexHTML
()
rawIndexHTML
:=
getRawIndexHTML
()
e
.
GET
(
"/m/:
memoID
"
,
func
(
c
echo
.
Context
)
error
{
e
.
GET
(
"/m/:
name
"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
memoID
,
err
:=
util
.
ConvertStringToInt32
(
c
.
Param
(
"memoID"
))
resourceName
:=
c
.
Param
(
"name"
)
if
err
!=
nil
{
// Redirect to `index.html` if any error occurs.
return
c
.
HTML
(
http
.
StatusOK
,
rawIndexHTML
)
}
memo
,
err
:=
s
.
Store
.
GetMemo
(
ctx
,
&
store
.
FindMemo
{
memo
,
err
:=
s
.
Store
.
GetMemo
(
ctx
,
&
store
.
FindMemo
{
ID
:
&
memoID
,
ResourceName
:
&
resourceName
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
c
.
HTML
(
http
.
StatusOK
,
rawIndexHTML
)
return
c
.
HTML
(
http
.
StatusOK
,
rawIndexHTML
)
...
@@ -116,7 +111,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL)
...
@@ -116,7 +111,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL)
return
err
return
err
}
}
for
_
,
memo
:=
range
memoList
{
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
"
))
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
))
return
c
.
XMLBlob
(
http
.
StatusOK
,
[]
byte
(
sitemap
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment