gistpad icon indicating copy to clipboard operation
gistpad copied to clipboard

Download all gists locally

Open majkinetor opened this issue 4 years ago • 8 comments

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:

  • File name template
  • How to handle file overwrites

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.

majkinetor avatar Dec 09 '21 23:12 majkinetor

@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

  • skip: do not overwrite, skip the folder/file
  • ask: this could be the default, ask the user what to do (overwrite, skip or select a differnt folder)
  • overwrite: always overwrite

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

carlocardella avatar Jun 19 '22 22:06 carlocardella

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).

majkinetor avatar Jun 20 '22 08:06 majkinetor

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

image

carlocardella avatar Jun 20 '22 17:06 carlocardella

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

majkinetor avatar Jun 20 '22 18:06 majkinetor

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

carlocardella avatar Jun 22 '22 03:06 carlocardella

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).

majkinetor avatar Jun 22 '22 08:06 majkinetor

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

carlocardella avatar Jun 22 '22 14:06 carlocardella

OK, I will do it. Thanks :)

majkinetor avatar Jun 22 '22 14:06 majkinetor

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

lostintangent avatar Dec 10 '23 01:12 lostintangent