mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-23 07:26:01 +08:00
Save HTML content to database
This commit is contained in:
parent
a454641d81
commit
cd5a74a123
3 changed files with 7 additions and 5 deletions
|
@ -62,6 +62,7 @@ func addBookmark(url, title, excerpt string, tags []string, offline bool) (err e
|
||||||
MinReadTime: article.Meta.MinReadTime,
|
MinReadTime: article.Meta.MinReadTime,
|
||||||
MaxReadTime: article.Meta.MaxReadTime,
|
MaxReadTime: article.Meta.MaxReadTime,
|
||||||
Content: article.Content,
|
Content: article.Content,
|
||||||
|
HTML: article.RawContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
bookTags := make([]model.Tag, len(tags))
|
bookTags := make([]model.Tag, len(tags))
|
||||||
|
|
|
@ -66,7 +66,7 @@ func OpenSQLiteDatabase() (*SQLiteDatabase, error) {
|
||||||
CONSTRAINT bookmark_id_FK FOREIGN KEY(bookmark_id) REFERENCES bookmark(id),
|
CONSTRAINT bookmark_id_FK FOREIGN KEY(bookmark_id) REFERENCES bookmark(id),
|
||||||
CONSTRAINT tag_id_FK FOREIGN KEY(tag_id) REFERENCES tag(id))`)
|
CONSTRAINT tag_id_FK FOREIGN KEY(tag_id) REFERENCES tag(id))`)
|
||||||
|
|
||||||
tx.MustExec(`CREATE VIRTUAL TABLE IF NOT EXISTS bookmark_content USING fts4(title, content)`)
|
tx.MustExec(`CREATE VIRTUAL TABLE IF NOT EXISTS bookmark_content USING fts4(title, content, html)`)
|
||||||
|
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
||||||
checkError(err)
|
checkError(err)
|
||||||
|
@ -121,8 +121,8 @@ func (db *SQLiteDatabase) SaveBookmark(bookmark model.Bookmark) (bookmarkID int6
|
||||||
|
|
||||||
// Save bookmark content
|
// Save bookmark content
|
||||||
tx.MustExec(`INSERT INTO bookmark_content
|
tx.MustExec(`INSERT INTO bookmark_content
|
||||||
(docid, title, content) VALUES (?, ?, ?)`,
|
(docid, title, content, html) VALUES (?, ?, ?, ?)`,
|
||||||
bookmarkID, bookmark.Title, bookmark.Content)
|
bookmarkID, bookmark.Title, bookmark.Content, bookmark.HTML)
|
||||||
|
|
||||||
// Save tags
|
// Save tags
|
||||||
stmtGetTag, err := tx.Preparex(`SELECT id FROM tag WHERE name = ?`)
|
stmtGetTag, err := tx.Preparex(`SELECT id FROM tag WHERE name = ?`)
|
||||||
|
@ -375,8 +375,8 @@ func (db *SQLiteDatabase) SearchBookmarks(keyword string, tags ...string) ([]mod
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
whereClause += ` AND id IN (
|
whereClause += ` AND id IN (
|
||||||
SELECT docid id FROM bookmark_content
|
SELECT docid id FROM bookmark_content
|
||||||
WHERE bookmark_content MATCH ?)`
|
WHERE title MATCH ? OR content MATCH ?)`
|
||||||
args = append(args, keyword)
|
args = append(args, keyword, keyword)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create where clause for tags
|
// Create where clause for tags
|
||||||
|
|
|
@ -17,5 +17,6 @@ type Bookmark struct {
|
||||||
MaxReadTime int `db:"max_read_time" json:"maxReadTime"`
|
MaxReadTime int `db:"max_read_time" json:"maxReadTime"`
|
||||||
Modified string `db:"modified" json:"modified"`
|
Modified string `db:"modified" json:"modified"`
|
||||||
Content string `db:"content" json:"-"`
|
Content string `db:"content" json:"-"`
|
||||||
|
HTML string `db:"html" json:"-"`
|
||||||
Tags []Tag `json:"tags"`
|
Tags []Tag `json:"tags"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue