--- blog.vim.orig 2008-08-06 20:28:36.000000000 +0800 +++ blog.vim 2008-08-06 21:28:09.000000000 +0800 @@ -15,13 +15,13 @@ " Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. " " Maintainer: Adrien Friggeri -" URL: http://www.friggeri.net/projets/vimblog/ +" URL: http://www.friggeri.net/projets/vimpress/ " Version: 0.9 " Last Change: 2007 July 13 " " Commands : -" ":BlogList" -" Lists all articles in the blog +" ":BlogList [count]" +" Lists recent articles in the blog, default is 10, use 0 for all " ":BlogNew" " Opens page to write new article " ":BlogOpen " @@ -40,7 +40,7 @@ " Just fill in the blanks, do not modify the highlighted parts and everything " should be ok. -command! -nargs=0 BlogList exec("py blog_list_posts()") +command! -nargs=* BlogList exec("py blog_list_posts()") command! -nargs=0 BlogNew exec("py blog_new_post()") command! -nargs=0 BlogSend exec("py blog_send_post()") command! -nargs=1 BlogOpen exec('py blog_open_post()') @@ -93,6 +93,7 @@ strid = get_meta("StrID") title = get_meta("Title") + slug = get_meta("Slug") cats = [i.strip() for i in get_meta("Cats").split(",")] if enable_tags: tags = get_meta("Tags") @@ -108,6 +109,7 @@ if enable_tags: post = { 'title': title, + 'wp_slug': slug, 'description': content, 'categories': cats, 'mt_keywords': tags @@ -115,6 +117,7 @@ else: post = { 'title': title, + 'wp_slug': slug, 'description': content, 'categories': cats, } @@ -147,6 +150,7 @@ vim.current.buffer[0] = "\"=========== Meta ============\n" vim.current.buffer.append("\"StrID : ") vim.current.buffer.append("\"Title : ") + vim.current.buffer.append("\"Slug : ") vim.current.buffer.append("\"Cats : "+blog_get_cats()) if enable_tags: vim.current.buffer.append("\"Tags : ") @@ -165,6 +169,7 @@ 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("\"Slug : "+(post["wp_slug"]).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")) @@ -190,16 +195,14 @@ except: pass -def blog_list_posts(): +def blog_list_posts(count=10): try: - lessthan = handler.getRecentPosts('',blog_username, blog_password,1)[0]["postid"] - size = len(lessthan) - allposts = handler.getRecentPosts('',blog_username, blog_password,int(lessthan)) + allposts = handler.getRecentPosts('',blog_username, blog_password, count) 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.current.buffer.append(("%-7s\t" % p["postid"]) + (p["title"]).encode("utf-8")) vim.command('set nomodified') blog_edit_off() vim.current.window.cursor = (2, 0)