condemil / gist

Sublime Text plugin for creating new Gists from selected text
MIT License
725 stars 136 forks source link

Save a local copy of gist for situation that cannot connect network #79

Open jiminggist opened 11 years ago

jiminggist commented 11 years ago

Is it possible to save a copy of all gist in local? If the network is connected, using the one from gist. Otherwise we still have a copy in local and still can work.

deiga commented 11 years ago

It would be possible to cache gists on to disk, but there would have to be a decision on whether to cache on opening a gist or caching all gists "all the time"

Caching brings with it problems of staleness and of course takes up space

jiminggist commented 11 years ago

The staleness is easy, in case we are connection to the internet, using the online version from gist ALL the time, just ignore and update the local cache. In offline mode, using cache then.

deiga commented 11 years ago

Yes, that would get rid of staleness, but it would also annihilate the actual use of caching, since getting the gists is pretty slow even for a few gists.

I'd be much more inclined to actually cache gists and use local files and check for new version when opening them or something similar.

jiminggist commented 11 years ago

Yes, it's better! Especially you can update all items in gist into local.

oliveagle commented 11 years ago

what about this plan?

  1. create a .gists folder under $HOME, and git clone all gists of a github user using ssh protocol . e.g.: git clone git@gists.github:12345.git .
  2. after Gist plugin create a gist finished normally, just clone the newly create gist into .gists folder.
  3. if user fire an open gist command, use cloned version in .gists folder instead of accessing the api.
  4. add other two commands called update gist and update all gists. let user decide when and which to update.

p.s.:

jiminggist commented 11 years ago

The idea is genius. +1.

deiga commented 11 years ago

Using ssh is a really bad Idea as the whole API is built around HTTPS and github tries to get people to use it. SSH needs credentials just like HTTPS so that is not a valid argument.

Forcing the user to update gist for himself is totally redundant and defeats the purpose of this plugin. It would make more sense to cache only loaded files and then comparing timestamps when opening a cached file

condemil commented 11 years ago

Merged with issue #16

@AeroCross said:

Thank you (and anyone who has contributed to this plugin, too) for such a magnificent plugin. It's saving lives, I tell you.

This isn't an issue — it's more of a feature suggestion.

I was wondering if there's any change to add offline access of some sort. Since gists need internet connection, it could be useful if the snipped is saved elsewhere — if there's access, check and update if necesary, but if there's not, just use the cached version.

sergiitk commented 11 years ago

I use gisty set on cron in order to sync all my gists.

However, it would be really awesome at least to be able to create a mapping between gist repos and Sublime Gist plugin. I mean, it's good to have ~/.gists directory, but sometimes I directly backup local files to gist.github (f.e. ~/.gitconfig). It works well when I create gist from a file; it's possible to update it, but, unfortunately, Gist plugin loses its internal mappings after restart.

So far the best I came for syncing files back up with is zsh oneliner:

cd $GISTY_DIR/91f354bfe4a4c9a82a46; git pull -q origin master; \
cp ~/.gitconfig .; git commit -v -a -e -m "$(date)" && git push origin master

Plus, I have custom script which automatically pushes changes for choosen Sublime user settings files. Anyway, contact me if you would like a hand with gisty setup (I use encapsulated rvm wrapper) or so on.

sunnycmf commented 7 years ago

hello guys, this is a really useful features that can be included in the plugin. seems the repo isn't active development anymore,

guys, how about we pick this up and work it out together?