cthiel / cardboard

A simple web-based card grouping application with a bit of collaboration
https://github.com/cthiel/cardboard
Other
4 stars 0 forks source link

import/export #27

Open garrett opened 13 years ago

garrett commented 13 years ago

We should support an import & export feature.

I imagine it would be a snapshot of what's currently represented by the board, in JSON.

bear454 commented 13 years ago

And CSV.

garrett commented 13 years ago

We can use a data URI to export the data from the client-side of things, which would be a good idea anyway, as we want to eventually have offline support. (I imagine the offline support would simply store & retrieve this same data structure.)

The data structure could be something like:

{
  "board": boardTitle,
  "decks": allTheDeckData,
  "cards": allTheCardData,
  "version": 0.5
}

Essentially, the same format that we're using, but combine the two JSON requests into one object.

I also added a version, in case we want to make a stable release and support importing old data formats. When importing, do you think it's possible to import the data to an older schema and migrate it to the latest? With multiple tables too?

I think import would need to be handled on the server side, unless we did a copy/paste based hack. As of yet, I don't think it's possible to upload files to the client side only.

garrett commented 13 years ago

Also: What would the CSV look like? I guess it would be something like:

"Header", "Card", "Tags"
DeckHeader1, Card1, Card1Tags
DeckHeader1, Card2
DeckHeader2, Card3, Card3Tags

Basically, the header would be included in every row, and tags would be included if they exist.

Should we prefix each line with the board title too? It would be for multi-board support. Otherwise, we could just make it overwrite the current board, or generate a new board name that they could change. (I think the generate name option is best for CSV.)

garrett commented 13 years ago

I have downloading JSON working locally.

However, it doesn't set the filename. There's unfortunately no way to do this with pure JS in the browser. There's a JS lib + Flash object that makes it possible @ https://github.com/dcneiner/Downloadify ... or we could rely on the server (which means the feature wouldn't be available for offline use, unless we have an offline mode that falls back to either Downloadify or no-specified-filename if Flash and the server aren't available).

I can, however, open a new window/tab and inject the data into it w/o any problem. It can be copy/pasted from there. That's another approach. (Or it could be a textarea that appears in the page.)

Thoughts?

This would apply to both JSON and CSV.

cthiel commented 13 years ago

Let's just move the exporting to the backend.

I was also thinking about this feature a bit more: maybe we should introduce UUIDs for Cards? That would enable use to move them back and forth between boards and make merging changes easier. What do you think?

garrett commented 13 years ago

Yeah, that's probably a good idea.

I think we should still have a fallback JSON export w/ copy/paste for offline mode, as that's when you need export the most! Of course, we'd need offline support and an offline mode too. (;

But the primary import/export should be handled by the server, evidently.