def assign_callback(self, index): if index == -1: return elif index == 0: self.post_type = 'post' thread = plugin.WordpressApiCall(GetPosts({ 'number': 200, 'post_type': 'post' })) elif index == 1: self.post_type = 'page' thread = plugin.WordpressApiCall(GetPosts({ 'number': 200, 'post_type': 'page' })) # add the thread to the list self.wc.add_thread(thread) self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # grab the passed in post id self.post_id = kwargs.get('id', None) # create threaded API calls because the http connections could take awhile thread = plugin.WordpressApiCall(GetPost(self.post_id)) thread2 = plugin.WordpressApiCall(GetPostStatusList()) # save a copy of the current view when ran self.view = self.window.active_view() # add the thread to the list self.wc.add_thread(thread) self.wc.add_thread(thread2)
def setup_command(self, *args, **kwargs): # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(GetPost(kwargs.get('id'))) self.view = self.window.active_view() # add the thread to the list self.wc.add_thread(thread)
def update_post(self): self.post.post_status = self.cur_status thread = plugin.WordpressApiCall(EditPost(self.post.id, self.post)) self.wc.add_thread(thread) self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall( DeleteTerm(kwargs.get('taxonomy', None), kwargs.get('id'))) # add the thread to the list self.wc.add_thread(thread)
def update_page(self): self.page.parent_id = self.new_page_id thread = plugin.WordpressApiCall(EditPost(self.page.id, self.page)) self.wc.add_thread(thread) self.wc.init_threads(self.thread_callback)
def thread_callback(self, result, *args, **kwargs): if type(result) is not WordPressPost and type( result) is bool and result == False: sublime.status_message('Unable to save ' + self.post.title + '.') return elif type(result) is bool and result == True: sublime.status_message('Successfully saved ' + self.post.title + '.') return self.post = result # retreive the new content from the view the command was ran on self.post.content = self.view.substr( sublime.Region(0, self.view.size())) # adjust thumbnail to contain the attachment id if isinstance(self.post.thumbnail, dict): self.post.thumbnail = self.post.thumbnail['attachment_id'] if self.post_id and self.post: # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(EditPost(self.post.id, self.post)) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback)
def doDone(self, path): self.path = path if not os.path.exists(self.path): sublime.error_message('Invalid path.') return data = {} data['name'] = os.path.basename(self.path) data['type'] = mimetypes.guess_type(self.path)[0] # read the binary file and let the XMLRPC library encode it into base64 with open(self.path, 'rb') as img: data['bits'] = xmlrpc_client.Binary(img.read()) pprint.pprint(data) # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(UploadFile(data)) # add the thread to the list self.wc.add_thread(thread) # initialize the threads since we added them after run_command self.wc.init_threads(self.thread_callback)
def update_post(self): self.post.terms = [ term for term in self.terms if term.id in self.selected_terms ] #pprint.pprint(self.post.terms) thread = plugin.WordpressApiCall(EditPost(self.post.id, self.post)) self.wc.add_thread(thread) self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # create threaded API calls because the http connections could take awhile thread = plugin.WordpressApiCall(GetPostTypes()) #thread = plugin.WordpressApiCall(GetPosts({ 'number': 200, 'post_type': self.post_type })) # save a copy of the current view when ran self.view = self.window.active_view() # add the thread to the list self.wc.add_thread(thread)
def doDone(self, value): to_update = {self.cur_option.name: value} # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(SetOptions(to_update)) # add the thread to the list self.wc.add_thread(thread) # initialize the threads since we added them after run_command self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # grab the active view self.view = self.window.active_view() # grab the id and title from the commands arguments, or the current view's status keys self.id = kwargs.get('id', self.view.get_status('Post ID')) self.title = kwargs.get('title', self.view.get_status('Post Title')) # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(DeletePost(self.id)) # add the thread to the list self.wc.add_thread(thread)
def doDone(self, keyword): # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall( GetPosts({ 'post_type': 'post', 's': keyword })) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback)
def doDone(self, name): # save the old name self.old_name = self.term.name # assign the new name to this term self.term.name = name # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(EditTerm(self.term.id, self.term)) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback)
def doDone(self, name): # initialize an empty WordPress term self.term = WordPressTerm() self.term.taxonomy = 'category' #new_term.parent = parent_cat.id self.term.name = name # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(NewTerm(self.term)) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback)
def doDone(self, name): # initialize an empty WordPress post self.post = WordPressPost() # assign the new name to this post self.post.title = name self.post.post_type = None # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(EditPost(self.id, self.post)) # add the thread to the list self.wc.add_thread(thread) # initialize the threads since we added them after run_command self.wc.init_threads(self.thread_callback)
def doDone(self, name): # initialize an empty wordpress post self.post = WordPressPost() # intialize the post with the inputted name and some empty content self.post.title = name self.post.content = '' self.post.post_type = self.post_type # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(NewPost(self.post)) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback)
def choose_taxonomy_callback(self, index): # the user cancelled the panel if index == -1: return # Do Nothing if index == 0: self.choose_taxonomy(self.taxes) return # loop through all of the retreived taxonomies for tax in self.taxes: # check for a matching title for the selected quick panel option if tax.name == self.taxonomy_options[index]: self.cur_tax = tax thread = plugin.WordpressApiCall(GetTerms(tax.name)) self.wc.add_thread(thread) self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # initialize empty posts array self.posts = [] self.children = None # grab post_type argument or substitute with a post type of post self.post_type = kwargs.get('post_type', 'post') # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall( GetPosts({ 'number': 200, 'post_type': self.post_type })) # add the thread to the list self.wc.add_thread(thread) # setup some options for the quick panel self.options = [['New ' + self.wc.unslugify(self.post_type), '']]
def setup_command(self, *args, **kwargs): # grab the active view self.view = sublime.active_window().active_view() self.post_id = self.view.get_status('Post ID') # check if this view is a WordPress post if self.post_id: # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(GetPost(self.post_id)) # add the thread to the list self.wc.add_thread(thread) # initiate any threads we have self.wc.init_threads(self.thread_callback) return # run sublime's original save command self.view.run_command("save")
def setup_command(self, *args, **kwargs): # grab the passed in post id self.page_id = kwargs.get('id', None) self.post_type = kwargs.get('post_type', None) if self.post_type != "page": sublime.status_message('This post isn\'t a page, trying anyway...') #return # create threaded API calls because the http connections could take awhile #thread = plugin.WordpressApiCall(GetPost(self.page_id)) thread = plugin.WordpressApiCall( GetPosts({ 'number': 200, 'post_type': self.post_type })) # save a copy of the current view when ran self.view = self.window.active_view() # add the thread to the list self.wc.add_thread(thread)
def setup_command(self, *args, **kwargs): # grab the active view self.view = self.window.active_view() # grab the id and title from the commands arguments, or the current view's status keys self.post_id = kwargs.get('post_id') self.attachment_id = kwargs.get('attachment_id') self.post_type = kwargs.get('post_type') self.post_title = kwargs.get('post_title') post = WordPressPost() post.title = None post.thumbnail = self.attachment_id post.id = self.post_id post.post_type = None # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(EditPost(post.id, post)) # add the thread to the list self.wc.add_thread(thread) # initialize the threads since we added them after run_command self.wc.init_threads(self.thread_callback)
def setup_command(self, *args, **kwargs): # create threaded API call because the http connections could take awhile thread = plugin.WordpressApiCall(GetOptions([])) # add the thread to the list self.wc.add_thread(thread)