diff -cr plugin.orig/blog.vim plugin/blog.vim *** plugin.orig/blog.vim Fri Aug 31 12:14:10 2007 --- plugin/blog.vim Fri Aug 31 12:16:04 2007 *************** *** 61,67 **** # Do not edit below # ##################### ! handler = xmlrpclib.ServerProxy(blog_url).metaWeblog edit = 1 def blog_edit_off(): --- 61,67 ---- # Do not edit below # ##################### ! handler = xmlrpclib.ServerProxy(blog_url) edit = 1 def blog_edit_off(): *************** *** 89,95 **** end = start + 1 while not vim.current.buffer[end][0] == '"': end +=1 ! return " ".join(vim.current.buffer[start:end]).split(":")[1].strip() strid = get_meta("StrID") title = get_meta("Title") --- 89,96 ---- end = start + 1 while not vim.current.buffer[end][0] == '"': end +=1 ! text = " ".join(vim.current.buffer[start:end]).split(":")[1].strip() ! return unicode(text, vim.eval('&encoding')).encode('utf8', 'replace') strid = get_meta("StrID") title = get_meta("Title") *************** *** 102,107 **** --- 103,109 ---- text_start +=1 text_start +=1 text = '\n'.join(vim.current.buffer[text_start:]) + text = unicode(text, vim.eval('&encoding')).encode('utf8', 'replace') content = text *************** *** 120,131 **** } if strid == '': ! strid = handler.newPost('', blog_username, blog_password, post, 1) vim.current.buffer[get_line("StrID")] = "\"StrID : "+strid else: ! handler.editPost(strid, blog_username, blog_password, post, 1) vim.command('set nomodified') --- 122,133 ---- } if strid == '': ! strid = handler.metaWeblog.newPost('', blog_username, blog_password, post, 1) vim.current.buffer[get_line("StrID")] = "\"StrID : "+strid else: ! handler.metaWeblog.editPost(strid, blog_username, blog_password, post, 1) vim.command('set nomodified') *************** *** 133,142 **** def blog_new_post(): def blog_get_cats(): ! l = handler.getCategories('', blog_username, blog_password) s = "" for i in l: ! s = s + (i["description"].encode("utf-8"))+", " if s != "": return s[:-2] else: --- 135,144 ---- def blog_new_post(): def blog_get_cats(): ! l = handler.mt.getCategoryList('', blog_username, blog_password) s = "" for i in l: ! s = s + (i["categoryName"].encode(vim.eval('&encoding')))+", " if s != "": return s[:-2] else: *************** *** 158,175 **** def blog_open_post(id): try: ! post = handler.getPost(id, blog_username, blog_password) blog_edit_on() vim.command("set syntax=blogsyntax") del vim.current.buffer[:] vim.current.buffer[0] = "\"=========== Meta ============\n" ! vim.current.buffer.append("\"StrID : "+str(id)) ! vim.current.buffer.append("\"Title : "+(post["title"]).encode("utf-8")) ! vim.current.buffer.append("\"Cats : "+",".join(post["categories"]).encode("utf-8")) ! if enable_tags: ! vim.current.buffer.append("\"Tags : "+(post["mt_keywords"]).encode("utf-8")) vim.current.buffer.append("\"========== Content ==========\n") ! content = (post["description"]).encode("utf-8") for line in content.split('\n'): vim.current.buffer.append(line) text_start = 0 --- 160,177 ---- def blog_open_post(id): try: ! post = handler.metaWeblog.getPost(id, blog_username, blog_password) blog_edit_on() vim.command("set syntax=blogsyntax") del vim.current.buffer[:] vim.current.buffer[0] = "\"=========== Meta ============\n" ! vim.current.buffer.append("\"StrID : "+id) ! vim.current.buffer.append("\"Title : "+(post["title"]).encode(vim.eval('&encoding'))) ! vim.current.buffer.append("\"Cats : "+",".join(post["categories"]).encode(vim.eval('&encoding'))) ! if enable_tags and post.has_key("mt_keywords"): ! vim.current.buffer.append("\"Tags : "+(post["mt_keywords"]).encode(vim.eval('&encoding'))) vim.current.buffer.append("\"========== Content ==========\n") ! content = (post["description"]).encode(vim.eval('&encoding')) for line in content.split('\n'): vim.current.buffer.append(line) text_start = 0 *************** *** 180,208 **** vim.command('set nomodified') vim.command('set textwidth=0') except: ! sys.stderr.write("An error has occured") def blog_list_edit(): try: row,col = vim.current.window.cursor id = vim.current.buffer[row-1].split()[0] ! blog_open_post(int(id)) except: pass def blog_list_posts(): try: ! lessthan = handler.getRecentPosts('',blog_username, blog_password,1)[0]["postid"] ! size = len(lessthan) ! allposts = handler.getRecentPosts('',blog_username, blog_password,int(lessthan)) del vim.current.buffer[:] vim.command("set syntax=blogsyntax") vim.current.buffer[0] = "\"====== List of Posts =========" for p in allposts: ! vim.current.buffer.append(("".zfill(size-len(p["postid"])).replace("0", " ")+p["postid"])+"\t"+(p["title"]).encode("utf-8")) vim.command('set nomodified') blog_edit_off() vim.current.window.cursor = (2, 0) vim.command('map :py blog_list_edit()') except: ! sys.stderr.write("An error has occured") --- 182,209 ---- vim.command('set nomodified') vim.command('set textwidth=0') except: ! sys.stderr.write("An error has occured:" + sys.exc_info()[0]) def blog_list_edit(): try: row,col = vim.current.window.cursor id = vim.current.buffer[row-1].split()[0] ! blog_open_post(id) except: pass def blog_list_posts(): try: ! lessthan = 10 ! allposts = handler.metaWeblog.getRecentPosts('',blog_username, blog_password,lessthan) del vim.current.buffer[:] vim.command("set syntax=blogsyntax") vim.current.buffer[0] = "\"====== List of Posts =========" for p in allposts: ! vim.current.buffer.append((p["postid"])+"\t"+(p["title"]).encode(vim.eval('&encoding'))) vim.command('set nomodified') blog_edit_off() vim.current.window.cursor = (2, 0) vim.command('map :py blog_list_edit()') except: ! sys.stderr.write("An error has occured:" + sys.exc_info()[0])