mirror of https://github.com/cloudreve/Cloudreve
feat(share): add option to automatically render and show README file (#2382)
parent
aada3aab02
commit
fe2ccb4d4e
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit 27996dc3ea22ab3b7ae525841ad1d45098d375f4
|
Subproject commit 38f5114426a43840e4e86e71f0d6d369e2adb7c7
|
|
@ -177,6 +177,8 @@ type (
|
||||||
ShareProps struct {
|
ShareProps struct {
|
||||||
// Whether to share view setting from owner
|
// Whether to share view setting from owner
|
||||||
ShareView bool `json:"share_view,omitempty"`
|
ShareView bool `json:"share_view,omitempty"`
|
||||||
|
// Whether to automatically show readme file in share view
|
||||||
|
ShowReadMe bool `json:"show_read_me,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
FileTypeIconSetting struct {
|
FileTypeIconSetting struct {
|
||||||
|
|
|
@ -115,6 +115,7 @@ type (
|
||||||
RemainDownloads int
|
RemainDownloads int
|
||||||
Expire *time.Time
|
Expire *time.Time
|
||||||
ShareView bool
|
ShareView bool
|
||||||
|
ShowReadMe bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,8 @@ func (l *manager) CreateOrUpdateShare(ctx context.Context, path *fs.URI, args *C
|
||||||
}
|
}
|
||||||
|
|
||||||
props := &types.ShareProps{
|
props := &types.ShareProps{
|
||||||
ShareView: args.ShareView,
|
ShareView: args.ShareView,
|
||||||
|
ShowReadMe: args.ShowReadMe,
|
||||||
}
|
}
|
||||||
|
|
||||||
share, err := shareClient.Upsert(ctx, &inventory.CreateShareParams{
|
share, err := shareClient.Upsert(ctx, &inventory.CreateShareParams{
|
||||||
|
|
|
@ -280,6 +280,7 @@ type Share struct {
|
||||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
Expired bool `json:"expired"`
|
Expired bool `json:"expired"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
|
ShowReadMe bool `json:"show_readme,omitempty"`
|
||||||
|
|
||||||
// Only viewable by owner
|
// Only viewable by owner
|
||||||
IsPrivate bool `json:"is_private,omitempty"`
|
IsPrivate bool `json:"is_private,omitempty"`
|
||||||
|
@ -313,6 +314,7 @@ func BuildShare(s *ent.Share, base *url.URL, hasher hashid.Encoder, requester *e
|
||||||
res.Downloaded = s.Downloads
|
res.Downloaded = s.Downloads
|
||||||
res.Expires = s.Expires
|
res.Expires = s.Expires
|
||||||
res.Password = s.Password
|
res.Password = s.Password
|
||||||
|
res.ShowReadMe = s.Props != nil && s.Props.ShowReadMe
|
||||||
}
|
}
|
||||||
|
|
||||||
if requester.ID == owner.ID {
|
if requester.ID == owner.ID {
|
||||||
|
|
|
@ -24,6 +24,7 @@ type (
|
||||||
RemainDownloads int `json:"downloads"`
|
RemainDownloads int `json:"downloads"`
|
||||||
Expire int `json:"expire"`
|
Expire int `json:"expire"`
|
||||||
ShareView bool `json:"share_view"`
|
ShareView bool `json:"share_view"`
|
||||||
|
ShowReadMe bool `json:"show_readme"`
|
||||||
}
|
}
|
||||||
ShareCreateParamCtx struct{}
|
ShareCreateParamCtx struct{}
|
||||||
)
|
)
|
||||||
|
@ -58,6 +59,7 @@ func (service *ShareCreateService) Upsert(c *gin.Context, existed int) (string,
|
||||||
Expire: expires,
|
Expire: expires,
|
||||||
ExistedShareID: existed,
|
ExistedShareID: existed,
|
||||||
ShareView: service.ShareView,
|
ShareView: service.ShareView,
|
||||||
|
ShowReadMe: service.ShowReadMe,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue