mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-25 00:14:10 +08:00
Fix custom title and excerpt doesn't saved
This commit is contained in:
parent
1d83468455
commit
fbd4e37643
4 changed files with 30 additions and 21 deletions
|
@ -37,11 +37,15 @@ func addHandler(cmd *cobra.Command, args []string) {
|
|||
noArchival, _ := cmd.Flags().GetBool("no-archival")
|
||||
logArchival, _ := cmd.Flags().GetBool("log-archival")
|
||||
|
||||
// Normalize input
|
||||
title = validateTitle(title, url)
|
||||
excerpt = normalizeSpace(excerpt)
|
||||
|
||||
// Create bookmark item
|
||||
book := model.Bookmark{
|
||||
URL: url,
|
||||
Title: validateTitle(title, url),
|
||||
Excerpt: normalizeSpace(excerpt),
|
||||
Title: title,
|
||||
Excerpt: excerpt,
|
||||
CreateArchive: !noArchival,
|
||||
}
|
||||
|
||||
|
@ -83,6 +87,8 @@ func addHandler(cmd *cobra.Command, args []string) {
|
|||
Content: content,
|
||||
ContentType: contentType,
|
||||
LogArchival: logArchival,
|
||||
KeepTitle: title != "",
|
||||
KeepExcerpt: excerpt != "",
|
||||
}
|
||||
|
||||
book, isFatalErr, err = core.ProcessBookmark(request)
|
||||
|
|
|
@ -163,12 +163,13 @@ func updateHandler(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
request := core.ProcessRequest{
|
||||
DataDir: dataDir,
|
||||
Bookmark: book,
|
||||
Content: content,
|
||||
ContentType: contentType,
|
||||
KeepMetadata: keepMetadata,
|
||||
LogArchival: logArchival,
|
||||
DataDir: dataDir,
|
||||
Bookmark: book,
|
||||
Content: content,
|
||||
ContentType: contentType,
|
||||
KeepTitle: keepMetadata,
|
||||
KeepExcerpt: keepMetadata,
|
||||
LogArchival: logArchival,
|
||||
}
|
||||
|
||||
book, _, err = core.ProcessBookmark(request)
|
||||
|
|
|
@ -26,12 +26,13 @@ import (
|
|||
|
||||
// ProcessRequest is the request for processing bookmark.
|
||||
type ProcessRequest struct {
|
||||
DataDir string
|
||||
Bookmark model.Bookmark
|
||||
Content io.Reader
|
||||
ContentType string
|
||||
KeepMetadata bool
|
||||
LogArchival bool
|
||||
DataDir string
|
||||
Bookmark model.Bookmark
|
||||
Content io.Reader
|
||||
ContentType string
|
||||
KeepTitle bool
|
||||
KeepExcerpt bool
|
||||
LogArchival bool
|
||||
}
|
||||
|
||||
// ProcessBookmark process the bookmark and archive it if needed.
|
||||
|
@ -77,11 +78,11 @@ func ProcessBookmark(req ProcessRequest) (model.Bookmark, bool, error) {
|
|||
book.HTML = article.Content
|
||||
|
||||
// If title and excerpt doesnt have submitted value, use from article
|
||||
if !req.KeepMetadata || book.Title == "" {
|
||||
if !req.KeepTitle || book.Title == "" {
|
||||
book.Title = article.Title
|
||||
}
|
||||
|
||||
if !req.KeepMetadata || book.Excerpt == "" {
|
||||
if !req.KeepExcerpt || book.Excerpt == "" {
|
||||
book.Excerpt = article.Excerpt
|
||||
}
|
||||
|
||||
|
|
|
@ -460,11 +460,12 @@ func (h *handler) apiUpdateCache(w http.ResponseWriter, r *http.Request, ps http
|
|||
}
|
||||
|
||||
request := core.ProcessRequest{
|
||||
DataDir: h.DataDir,
|
||||
Bookmark: book,
|
||||
Content: content,
|
||||
ContentType: contentType,
|
||||
KeepMetadata: keepMetadata,
|
||||
DataDir: h.DataDir,
|
||||
Bookmark: book,
|
||||
Content: content,
|
||||
ContentType: contentType,
|
||||
KeepTitle: keepMetadata,
|
||||
KeepExcerpt: keepMetadata,
|
||||
}
|
||||
|
||||
book, _, err = core.ProcessBookmark(request)
|
||||
|
|
Loading…
Reference in a new issue