Add UI to export the list of bookmarks

This commit is contained in:
2022-05-25 17:18:32 +09:30
parent 78488d2f41
commit be10f5238e
4 changed files with 26 additions and 1 deletions

View File

@@ -189,6 +189,16 @@ func Create(bmm *db.BookmarkManager) *Server {
c.String(http.StatusOK, "queued")
})
r.GET("/export", func(c *gin.Context) {
c.Writer.Header().Set("Content-Type", "text/plain")
c.Writer.Header().Set("Content-Disposition", "attachment; filename=\"bookmarks.txt\"")
err := bmm.ExportBookmarks(c.Writer)
// this is a bit late, but we already added headers, so at least log it.
if err != nil {
log.Printf("got error when exporting: %s", err)
}
})
return server
}