ckolderup / postmarks

a single-user bookmarking website designed to live on the Fediverse
https://postmarks.glitch.me
MIT License
456 stars 38 forks source link

Add csv export for bookmarks #118

Closed PatOConnor43 closed 9 months ago

PatOConnor43 commented 9 months ago

This PR may close #86 unless there are additional desired formats.

Description

86 describes a need to export the bookmarks into a friendlier format. This PR attempts to do that by creating a specific bookmarksDB function for that query and then using the csv-stringify package to send it to the client. This PR makes an additional small change to the admin/data template to export the formats as a list.

Testing

Alternatives Considered

I started out trying to just rely on sqlite to do the export. If you get in the console you can run:

.headers on
.mode csv

and selects will come out as csv.

I was having an issue toggling those options on as part of the db.all/exec/run. I think we could probably remove the csv-stringify dependency altogether if we could rely on this instead.

FYI @ckolderup @andypiper

andypiper commented 9 months ago

I guess a follow-on step from this would be to enable the reverse via the bulk import function, ie accept a file in CSV format that has been exported, for import.

ckolderup commented 9 months ago

@andypiper good point, I just updated #23 to make it specifically targeting import from this export format. (We can open separate tickets over time for import from browser bookmark HTML files as well as export formats from Pinboard, Shaarli, etc)

PatOConnor43 commented 9 months ago

Thanks for the review @andypiper @ckolderup. I think this should be ready for review again when you have a chance.

I did start looking into a csv import as well. The csv-parser package seemed like a good way to do that since it'd give us a parsed object that we could use to support other sources that output csv.