-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
240 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Build 0.0.6 | ||
----------- | ||
Release Date: 15 Mar 2015 | ||
|
||
* Add thread progress for CRUD on gist | ||
* Refactoring this plugin, add callback support to thread | ||
* If CRUD succeed, just hide the panel after lots of seconds | ||
* Add a ``delay_seconds_for_hiding_panel`` setting to control the panel hiding delay seconds | ||
|
||
Notes: | ||
|
||
* You should restart your sublime after ``HaoGist`` is upgraded | ||
----------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"name": "HaoGist", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "HaoGist is sublime plugin for CRUD on Github gist", | ||
"author": "Hao Liu", | ||
"email": "mouse.mliu@gmail.com", | ||
"homepage": "https://github.com/xjsender/HaoGist", | ||
"last_modified_date": "2015-03-14" | ||
"last_modified_date": "2015-03-15" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import os | ||
import sublime | ||
|
||
from . import util | ||
from .panel import Printer | ||
|
||
def refresh_gist(res, options): | ||
# Get file_full_name | ||
file_full_name = options["file_full_name"] | ||
base, filename = os.path.split(file_full_name) | ||
|
||
settings = util.get_settings() | ||
with open(file_full_name, "wb") as fp: | ||
fp.write(res.content) | ||
|
||
Printer.get("log").write("%s update succeed" % filename) | ||
sublime.set_timeout_async(Printer.get("log").hide_panel, | ||
settings["delay_seconds_for_hiding_panel"] * 1000) | ||
|
||
def delete_gist(res, options): | ||
# Get file_full_name | ||
file_full_name = options["file_full_name"] | ||
base, filename = os.path.split(file_full_name) | ||
|
||
settings = util.get_settings() | ||
|
||
view = util.get_view_by_file_name(file_full_name) | ||
if view: | ||
sublime.active_window().focus_view(view) | ||
sublime.active_window().run_command("close") | ||
os.remove(file_full_name) | ||
Printer.get("log").write("%s delete succeed" % filename) | ||
sublime.set_timeout_async(Printer.get("log").hide_panel, | ||
settings["delay_seconds_for_hiding_panel"] * 1000) | ||
|
||
def create_gist(res, options): | ||
# Get filename and content | ||
filename = options["filename"] | ||
content = options["content"] | ||
|
||
# Get settings | ||
settings = util.get_settings() | ||
|
||
# Write file to workspace | ||
file_full_name = settings["workspace"] + "/" + filename | ||
with open(file_full_name, "wb") as fp: | ||
fp.write(content.encode("utf-8")) | ||
|
||
# Write cache to .cache/gists.json | ||
util.add_gists_to_cache([res.json()]) | ||
|
||
# Open created gist | ||
sublime.active_window().open_file(file_full_name) | ||
|
||
# Success message | ||
Printer.get("log").write("%s is created successfully" % filename) | ||
sublime.set_timeout_async(Printer.get("log").hide_panel, | ||
settings["delay_seconds_for_hiding_panel"] * 1000) | ||
|
||
def update_gist(res, options): | ||
# Get file_full_name | ||
file_full_name = options["file_full_name"] | ||
base, filename = os.path.split(file_full_name) | ||
|
||
settings = util.get_settings() | ||
|
||
Printer.get("log").write("%s is update successfully" % filename) | ||
sublime.set_timeout_async(Printer.get("log").hide_panel, | ||
settings["delay_seconds_for_hiding_panel"] * 1000) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import sublime | ||
|
||
|
||
class ThreadProgress(): | ||
|
||
""" | ||
Animates an indicator, [= ], in the status area while a thread runs | ||
:param thread: | ||
The thread to track for activity | ||
:param message: | ||
The message to display next to the activity indicator | ||
:param _callback: | ||
The message to display once the thread is complete | ||
""" | ||
|
||
def __init__(self, api, thread, message, _callback, _callback_options={}): | ||
self.api = api | ||
self.thread = thread | ||
self.message = message | ||
self._callback = _callback | ||
self._callback_options = _callback_options | ||
self.addend = 1 | ||
self.size = 12 | ||
sublime.set_timeout(lambda: self.run(0), 100) | ||
|
||
def run(self, i): | ||
if not self.thread.is_alive(): | ||
if hasattr(self.thread, 'result') and not self.thread.result: | ||
sublime.status_message('') | ||
return | ||
|
||
res = self.api.res | ||
if not res or res.status_code > 399: | ||
print (res.text) | ||
return | ||
|
||
# Invoke _callback | ||
self._callback(res, self._callback_options) | ||
|
||
return | ||
|
||
before = i % self.size | ||
after = (self.size - 1) - before | ||
|
||
sublime.status_message('%s [%s=%s]' % (self.message, ' ' * before, ' ' * after)) | ||
|
||
if not after: | ||
self.addend = -1 | ||
if not before: | ||
self.addend = 1 | ||
i += self.addend | ||
|
||
sublime.set_timeout(lambda: self.run(i), 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.