diff --git a/db/bookmarks.go b/db/bookmarks.go index 005c8da..ff16374 100644 --- a/db/bookmarks.go +++ b/db/bookmarks.go @@ -21,6 +21,7 @@ type BookmarkManager struct { type SearchOptions struct { Query string Tags []string + Sort string } func NewBookmarkManager(db *DB) *BookmarkManager { @@ -138,10 +139,22 @@ func (m *BookmarkManager) Search(opts SearchOptions) ([]entity.Bookmark, error) bhQuery = bolthold.Query(*bhQuery.And("Tags").ContainsAll(bolthold.Slice(opts.Tags)...)) } + if opts.Sort == "title" { + bhQuery.SortBy("Info.Title") + } else if opts.Sort == "created" { + bhQuery.SortBy("TimestampCreated") + } else if opts.Sort == "scraped" { + bhQuery.SortBy("TimestampLastScraped") + + } else { + bhQuery.SortBy("ID") + } + out := []entity.Bookmark{} err := m.db.store.ForEach(&bhQuery, func(bm *entity.Bookmark) error { out = append(out, *bm) + return nil }) if err != nil { diff --git a/web/templates/manage.html b/web/templates/manage.html index 40fa456..b756762 100644 --- a/web/templates/manage.html +++ b/web/templates/manage.html @@ -13,8 +13,9 @@ {{ template "tags_widget.html" . }} + {{ template "manage_results.html" . }} + - {{ template "manage_results.html" . }} \ No newline at end of file diff --git a/web/templates/manage_results.html b/web/templates/manage_results.html index 20e2b27..da33b96 100644 --- a/web/templates/manage_results.html +++ b/web/templates/manage_results.html @@ -2,10 +2,10 @@
- | title/url | +title/url | tags | -created | -scraped | +created | +scraped |
---|---|---|---|---|---|---|---|