Skip to content

Commit

Permalink
Update Gist Package to 2012.05.16.03.05.18
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesroper committed May 16, 2012
1 parent 08bf9e0 commit 2c79949
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 49 deletions.
78 changes: 33 additions & 45 deletions Gist/README.md
@@ -1,26 +1,22 @@
Gist
====
# Gist

[Sublime Text 2](http://www.sublimetext.com/) plugin for creating new Gists from selected text and get the gist list
A [Sublime Text 2](http://www.sublimetext.com/) plugin for creating and editing Gists.

Installation
-----------
# Installation

Go to your Packages subdirectory under Sublime Text 2 data directory:
## Package Control

* Windows: %APPDATA%\Sublime Text 2
* OS X: ~/Library/Application Support/Sublime Text 2
* Linux: ~/.config/sublime-text-2
* Portable Installation: Sublime Text 2/Data
Install [Package Control](http://wbond.net/sublime_packages/package_control). Gist will show up in the package list. This is the recommended installation method.

Then clone this repository:
## Manual installation

Go to the "Packages" directory (`Preferences` / `Browse Packages…`). Then clone this repository:

git clone git://github.com/condemil/Gist

Options
-------
# Options

If you're using OS X and have a keychain entry for github.com, no configuration is needed. Otherwise, copy the `Gist.sublime-settings` file from Packages/Gist to Packages/User sub-directory and edit:
If you're using OS X and have a keychain entry for github.com, no configuration is needed. Otherwise, edit the settings file (it should open automatically the first time you use a Gist command):

* `"username": ""`

Expand All @@ -35,54 +31,46 @@ If you're using OS X and have a keychain entry for github.com, no configuration
You can enter https proxy here
Format: "http://user:pass@proxy:port"

Usage
-----
**Create a public gist:**

From menu items:

* Main menu: Tools -> Gist -> "Create Public Gist"
* Context menu: "Create Public Gist"
# Usage

By command called "Gist (public): Create from Selected Text"
All functionality of the plugin is available in the `Tools` / `Gist` menu and in the command pallette.

There is a key bindings:
## Creating Gists

* Windows and Linux: "ctrl+k", "ctrl+i"
* OS X: "super+k", "super+i"
Use the `Gist` / `Create Public Gist` or `Gist` / `Create Private Gist` commands. If you don't have anything selected, a Gist will be created with contents of current file, URL of that Gist will be copied to the clipboard and then the file will switch to Gist editing mode. If you have selected some text, a Gist will be created using only that text and then immediately opened for editing. In case of multiple selections, you'll get one Gist with multiple files.

**Create a private gist:**
## Editing existing Gists

From menu items:
Use the `Gist` / `Open Gist` command to see a list of your Gists. Selecting one will open the files from that Gist in new tabs. You can then edit the files normally and use `Gist` / `Update File` to update the Gist, or use other commands to change Gist description, remove or rename files, or delete the Gist.

* Main menu: Tools -> Gist -> "Create Private Gist"
* Context menu: "Create Private Gist"
## Adding new files to existing Gists

By command called "Gist (private): Create from Selected Text".
Use the `Gist` / `Add File To Gist` command to see a list of your Gists. Selecting one will add contents of current file as a new file to that Gist and switch the file to Gist editing mode.

There is a key bindings:
# Default key bindings:

* Windows and Linux: "ctrl+k", "ctrl+l"
* OS X: "super+k", "super+l"
## Create Public Gist

**Get gist list:**
* Windows and Linux: `Ctrl+K` `Ctrl+I`
* OS X: `Cmd+K` `Cmd+I`

From menu items:
## Create Private Gist

* Main menu: Tools -> Gist -> "Get Gist List"
* Windows and Linux: `Ctrl+K` `Ctrl+L`
* OS X: `Cmd+K` `Cmd+L`

By command called "Gist: Get Gist List".
## Update File

There is a key bindings:
* Windows and Linux: `Ctrl+K` `Ctrl+S`
* OS X: `Cmd+K` `Cmd+S`

* Windows and Linux: "ctrl+shift+g"
* OS X: "super+shift+g"
## Open Gist

**The content of the selected gist will be copied into the clipboard**
* Windows and Linux: `Ctrl+Shift+G`
* OS X: `Ctrl+Cmd+G`

Information
-----------
# Information

Source: https://github.com/condemil/Gist

Author: https://github.com/condemil/
Authors: [Dmitry Budaev](https://github.com/condemil/), [Alexey Ermakov](https://github.com/technocoreai)
12 changes: 10 additions & 2 deletions Gist/gist.py
Expand Up @@ -11,6 +11,7 @@
import tempfile
import traceback
import contextlib
import shutil

DEFAULT_CREATE_PUBLIC_VALUE = 'false'
DEFAULT_USE_PROXY_VALUE = 'false'
Expand Down Expand Up @@ -53,6 +54,8 @@ class SecKeychainAttribute(Structure):
class SecKeychainAttributeList(Structure):
_fields_ = [("count", c_uint32), ("attr", POINTER(SecKeychainAttribute))]

PtrSecKeychainAttributeList = POINTER(SecKeychainAttributeList)

def keychain_get_credentials():
username = settings.get('username')
password = settings.get('password')
Expand Down Expand Up @@ -85,7 +88,7 @@ def keychain_get_credentials():
pointer(c_uint32(1633903476)), # kSecAccountItemAttr
pointer(c_uint32(6))) # CSSM_DB_ATTRIBUTE_FORMAT_BLOB

attrlist_ptr = pointer(SecKeychainAttributeList())
attrlist_ptr = PtrSecKeychainAttributeList()
error = lib_security.SecKeychainItemCopyAttributesAndData(
item, # keychain item reference
byref(info), # list of attributes to retrieve
Expand All @@ -101,7 +104,7 @@ def keychain_get_credentials():
username = string_at(attr.data, attr.length)
password = string_at(password_buf.value, password_buflen.value)
finally:
lib_security.SecKeychainItemFreeContent(attrlist_ptr, password_buf)
lib_security.SecKeychainItemFreeAttributesAndData(attrlist_ptr, password_buf)

if not username or not password:
raise MissingCredentialsException()
Expand All @@ -118,6 +121,11 @@ def _fn(*args, **kwargs):
return fn(*args, **kwargs)
except MissingCredentialsException:
sublime.error_message("Gist: GitHub username or password isn't provided in Gist.sublime-settings file")
user_settings_path = os.path.join(sublime.packages_path(), 'User', 'Gist.sublime-settings')
if not os.path.exists(user_settings_path):
default_settings_path = os.path.join(sublime.packages_path(), 'Gist', 'Gist.sublime-settings')
shutil.copy(default_settings_path, user_settings_path)
sublime.active_window().run_command("open_file", {"file": user_settings_path})
except subprocess.CalledProcessError as err:
sublime.error_message("Gist: Error while contacting GitHub: cURL returned %d" % err.returncode)
except EnvironmentError as err:
Expand Down
2 changes: 1 addition & 1 deletion Gist/package-metadata.json
@@ -1 +1 @@
{"url": "https://github.com/condemil/Gist", "version": "2012.01.15.15.40.12", "description": "Sublime Text 2 plugin for creating new Gists from selected text"}
{"url": "https://github.com/condemil/Gist", "version": "2012.05.16.03.05.18", "description": "Sublime Text 2 plugin for creating new Gists from selected text"}
2 changes: 1 addition & 1 deletion User/Package Control.sublime-settings
@@ -1,5 +1,5 @@
{
"auto_upgrade_last_run": 1337091110,
"auto_upgrade_last_run": 1337183346,
"installed_packages":
[
"Bullet",
Expand Down

0 comments on commit 2c79949

Please sign in to comment.