This entry was posted on 火曜日, 5月 6th, 2008 at 23:09:36 and is filed under vim. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


vimからwordpressに投稿してみる
前回のコードを単純にvimのbufferから読むようにしただけ
以下ソース
vim2wp.vim
function WP_post()
python << EOF
username=‘username‘
password=‘XXXXXXX‘
# xmlrpc.phpのある場所を指定しておく
blog_url=‘http://xxxxx/xmlrpc.php‘
python << EOF
username=‘username‘
password=‘XXXXXXX‘
# xmlrpc.phpのある場所を指定しておく
blog_url=‘http://xxxxx/xmlrpc.php‘
import vim
import xmlrpclib
wp = xmlrpclib.ServerProxy(blog_url)
content=unicode(‘\n‘.join(vim.current.buffer[:]), ‘utf-8‘)
title=unicode(vim.eval("input(’title :’)"), ‘utf-8‘)
if title == ”:
print "cancel post."
else:
category=vim.eval("input(’category :’)")
post={‘title‘:title,‘description‘:content}
categoryList = dict([(x['categoryName'], x['categoryId']) for x in wp.wp.getCategories(0,username,password)])
postID = wp.metaWeblog.newPost(”,username,password,post,1)
if category in categoryList.keys():
wp.mt.setPostCategories(postID, username, password,[{'categoryId':categoryList[category]}])
print "Finish post."
EOF
endfunction
:so vim2wp.vim
で、読み込んで
:call WP_post()
で、実行
title:
と聞かれるのでエントリーのタイトルを入力
何も入力しないとキャンセル
category :
次にカテゴリーを聞いてくるので入力
何も入力しないとデフォルトカテゴリーが適用される
Leave a Reply
