lostintangent / gistpad

VS Code extension for managing and sharing code snippets, notes and interactive samples using GitHub Gists
https://aka.ms/gistpad
MIT License
938 stars 58 forks source link

Download all gists locally #266

Closed majkinetor closed 9 months ago

majkinetor commented 2 years ago

Is your feature request related to a problem? Please describe.

I would like to have all gists locally for various purposes - advanced search, processing, backup...

Describe the solution you'd like

At least command that would allow one to download all gists (both private and public) into local folder. One time event, you explicitly call it, and specify folder where gists will be downloaded to.

Much better option would be to add GistPad options to specify local cache folder that should always contain latest downloaded versions and we should be able to periodically sync it completely either manually or automatically in case there are some edits outside of GistPad (e.g. using the Github UI or some other tool).

We probably need few options for this such as:

but even the first simplest solution with sane defaults would suffice.

Describe alternatives you've considered

There are no alternatives right now apart from using various CLI tools to achieve that.

I would prefer GistPad be my only gist interface and its most important to have your stuff offline.

Also, I believe that this is easy to implement feature.

carlocardella commented 2 years ago

@majkinetor, @lostintangent, this is what I have so far:

  1. Download one file from a gist
  2. Download multiple files from a gist (use CTRL or SHIFT to select the files to download)
  3. Download a single gist (with all its files)
  4. Download multiple gists (use CTRL or SHIFT to select the gists to download)

In every case the user needs to select the destination folder where to save the files. When downloading a gist, the gist name is used as the name of a folder to contain the gist's files. Since gist names can contain special characters (e.g. slash, pund sign, greater or smaller than etc.), I am currently replacing those characters with an underscore (you can see the result in the second video below): is this ok or do you have other suggestions?

Also, I am thinking to add a setting to control folder/file overwrites, e.g. gistpad.downloadOverwrite

Comments? @lostintangent I can submit a draft PR with what I have so far if you want to take a look at the code.

Download gist

download gist2

Convert name with special characters

encode file name

Menu command

I have named the command Download... to download both one (or more) gist and file(s), we can be more specific (e.g. Download gist..., Download file...) if you think that can be confusing. sshot-1493

majkinetor commented 2 years ago

Awesome work. I don't think anything is confusing or requires more work.

It would be nice to have Download all tho, that would work on the current filter (you select a tag, or nothing at all, and issue download all).

carlocardella commented 2 years ago

Do you mean something like this, when I click on a user?

image

majkinetor commented 2 years ago

If that includes my own gists and not just people I follow, then yes.

carlocardella commented 2 years ago

I need to handle a few edge cases I found in my testing, but this is how Download all... looks like:

Download all gists from a followed user

save all 1

Download all starred gists

save all starred

Download all my gists

save all my gists

At this point, even if we don't group followed users in a "folder" (like Your Gists or Starred Users), is a command to download all gists from all followed users and from Scratch Nodes

majkinetor commented 2 years ago

Great work.

This solves backup and read, but batch write is still a problem - lets say I do search and replace downloaded gists using vscode, operation that touches 20 gists, how would I save that upstream? It is briefly mentioned in original description of this issue (called local cache and sync), but it probably deserves its own ticket if you would like to tackle that (I do have few ideas in mind).

carlocardella commented 2 years ago

Agreed, that would be better tracked in its own issue, do you mind opening one with the description and ideas you mentioned? We can continue the discussion there

majkinetor commented 2 years ago

OK, I will do it. Thanks :)

lostintangent commented 9 months ago

I haven't had a use for this feature, and I've not heard any other requests for it. So due to the low priority, and the fact that I couldn't naturally test/maintain in as part of my personal usage, I'm going to close this as "not planned".

If folks would like this feature, they can check out this alternative extension: https://marketplace.visualstudio.com/items?itemName=CarloCardella.vscode-virtualgists