alphapapa / pocket-reader.el

Emacs client for Pocket reading list (getpocket.com)
GNU General Public License v3.0
223 stars 12 forks source link

Offline support #7

Closed dakra closed 1 year ago

dakra commented 6 years ago

Would be nice if there where an option to download and save all articles so I can browse and view them offline.

alphapapa commented 6 years ago

Hi,

This is an interesting idea, but it raises a lot of questions, and would not be simple to implement. The package does not currently save any data to disk, and implementing a cache with synchronization would be a big undertaking.

However, I do have some very basic code that you might find useful here: https://github.com/alphapapa/org-pocket/blob/master/org-pocket.el

You can customize the org-pocket-capture-file option to an Org file you want to capture to, then customize org-pocket-capture-tag to a tag you apply to items you want to capture (by default, capture), then call org-pocket-capture-items, and it will save up to 10 items to that Org file, and mark each one as archived when it's done.

Perhaps with your help, we can improve this code and make it a worthy addition to this package, or a helpful addon package. Let me know what you think.

dakra commented 6 years ago

I wouldn't overthink the 'sync' part too much.. Just store all articles in it's own file (I personally don't even care about removing items because I want to keep them archived anyway), wouldn't that be good enough and relatively easy to maintain?!

Then some option/command to not download the article but instead jump to the file (or always download and open file if some setting is set).

alphapapa commented 6 years ago

Did you not look at org-pocket?

dakra commented 6 years ago

I had a quick look and looks useful to quickly store some articles.. But it's not really "integrated" in pocket-reader, i.e. it's a separate org file. And I was thinking storing all articles in only 1 org file instead of a directory makes syncing way harder I guess..

Maybe I'll play around with it a bit and will give feedback what works for me.

Thanks for the package!

alphapapa commented 6 years ago

If you prefer separate files, it would be easy to make that change to org-pocket.

Integrating this kind of functionality into pocket-reader is likely not as straightforward as it seems. Some examples:

  1. Idempotency. What if the user runs the command to save articles more than once? Does it store multiple copies, or just one? If one, how does it know which ones have already been downloaded? If we use the item ID as the filename, it won't be very helpful for the user. We could concat the ID onto the page name, but then we have to parse each filename in the directory before we can do anything. We could keep a list of IDs that have been saved, but then we have to delete IDs from the list after the user reads them; how do we do that? Automatically or manually? How would we do that automatically? If manually, do we have to implement another list of "offline/saved items" for the user to browse and delete? That's almost like building a whole new UI and major-mode. If we save multiple copies instead of doing all that, we confuse the user and waste disk space.
  2. Do we mark saved articles as archived or untag them for capture immediately after the article is downloaded? If not, the user will have to do it manually, or else he'll get articles downloaded again after he reads them. Obviously it would be somewhat purpose-defeating for the user to have to do it manually, so how do we do that automatically? What if the user is offline at the time? Do we queue up a list of things to operate on next time the user goes online? Do we then have to implement an entire offline mode of operation?

I hope this illustrates how integrating this kind of functionality is relatively complex for the benefit it would bring. Maybe you can help me think through it and come up with a simple approach, but so far, I think org-pocket is close to the best way to do it. I welcome your feedback.

Thanks.