Add UI to export the list of bookmarks
This commit is contained in:
@@ -2,6 +2,7 @@ package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -48,6 +49,19 @@ func (m *BookmarkManager) ListBookmarks() ([]entity.Bookmark, error) {
|
||||
return bookmarks, nil
|
||||
}
|
||||
|
||||
// ExportBookmarks exports all bookmarks to an io.Writer
|
||||
func (m *BookmarkManager) ExportBookmarks(w io.Writer) error {
|
||||
bms := []entity.Bookmark{}
|
||||
err := m.db.store.Find(&bms, &badgerhold.Query{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not export bookmarks: %w", err)
|
||||
}
|
||||
for _, bm := range bms {
|
||||
w.Write([]byte(bm.URL + "\n"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BookmarkManager) SaveBookmark(bm *entity.Bookmark) error {
|
||||
err := m.db.store.Update(bm.ID, &bm)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user