From 9b6f1326131755a3f44f4bc4e3deb3dc66987e4e Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Fri, 9 Mar 2012 08:08:21 -0800 Subject: [PATCH 01/52] UPdates --- README | 71 ---------- README.md | 81 +++++++++++ vimblog.vim => plugin/vimblog.vim | 215 ++++++++++++++++++------------ 3 files changed, 213 insertions(+), 154 deletions(-) delete mode 100644 README create mode 100644 README.md rename vimblog.vim => plugin/vimblog.vim (71%) diff --git a/README b/README deleted file mode 100644 index 184b3cb..0000000 --- a/README +++ /dev/null @@ -1,71 +0,0 @@ -= vimblog.vim - -== description - - For Vi, Vim or GVim users, there is a simple way to manage your blog posts. Under Vim environment, you can create new blog posts, edit, list all categories, list older posts, delete posts, turn Published into Draft posts, and vice-versa. - It is out-of-the-box working for Wordpress, but very easilly, you can make it manage Blogger, MovableType, TextPattern, etc, platforms. Its the beauty of Open Source software. Study the code, change it, and use it. It is very safe to use it because unlike proprietary software, you can check for “phone_home” procedures, etc. - -== requirements: - - * you'll need VIM compiled with Ruby scripting support - - example: for Debian/Ubuntu: sudo apt-get install vim-ruby - * please, copy this file to one of your VIM dir - - example: to your .vim home folder: $HOME/.vim/vimlog.vim - * please, add this code to your .vimrc file: - - if !exists('*Wordpress_vim') - runtime vimblog.vim - endif - - * change your blog login/password info on the get_personal_data - function bellow. - * make sure you have xmlrpc.php file in your / blog dir. If not, - change the @xml variable to find it. - * testing: open vim, ando do - :Blog rp - to get your recent 10 posts. - -== how-to - - * copy the script to your Vim scripts path, $HOME/.vim directory - * edit you .vimrc (if not exists, create it: $HOME/.vimrc) and insert: - -if !exists('*Wordpress_vim') -runtime vimblog.vim -endif - - * open the vimblog.vim script and edit the personal data in def get_personal_data method approx. at line 97. - * @site value, do not insert “http://”. Just insert the blog address, like in my case “blog.tquadrado.com” - * @xml value, insert the path to your blog’s xmlrpc.php file. If, like in my case, it is in / from your blog address, do insert “/xmlrpc.php” - * run Vim and try fetching the last 10 posts by doing: - -:Blog rp - -If you can see them, it’s fine. If not, test this: - - * check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. - * if error persist, check for the correct path for xmlrpc.php in @xml value. - -== license - -== LICENSE: - - Copyright (c) 2007 pedro mg - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e61a9b --- /dev/null +++ b/README.md @@ -0,0 +1,81 @@ +# VIMBLOG.VIM + +## Description + +For Vi, Vim or GVim users, there is a simple way to manage your blog +posts. + +In the Vim environment you can now + +* create new blog posts +* edit / posts +* list all categories +* list older posts +* Promote turn "draft" posts into "published" (and vice-versa) + +It is an out-of-the-box solution that works for Wordpress, but which can +very easilly, be customized to manage Blogger, MovableType, TextPattern, +et al. Its the beauty of Open Source software. Study the code, change +it, and use it. It is very safe to use it because unlike proprietary +software, you can check for "phone\_home" procedures, etc. + +## Requirements: + +1. You'll need VIM compiled with Ruby scripting support. Check for + this by executing `vim --version|grep ruby`. My result (MacVim + +Janus) shows: `+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime`. This means that I have ruby scripting support compiled. Debian/Ubuntu can install Ruby support with: `sudo apt-get install vim-ruby` +1. To install you several options: + 1. Copy this file to one of your VIM directories + 1. Example: copy the script file to your .vim home folder: $HOME/.vim/vimlog.vim + 1. *Pathogen Example*: If you're using Pathogen, go to your Pathogen root + directory and then `git clone` this repository + 1. *Janus Example*: If you're using Janus then you're just a + variation on the Pathogen setup. Create a `~/.janus` directory +and then add this repository as a submodule with `git add +$GIT\_REPO\_PATH vimblog`. Git will check out the plugin for you. +1. Your VIM runtime must be made aware of this plugin by means of the + following command. Make sure it is in your `~/.vimrc` or, for +MacVim + Janus users, make sure it is in `~/.vimrc.after`. + + if !exists('\*Wordpress\_vim') + runtime vimblog.vim + endif + +1. Change your blog login/password info on the `get\_personal\_data` + function in `vimblog.vim` near line 97. +1. Set the `@site` value. Do not insert `http://`. Just insert the blog + address, like in my case `blog.tquadrado.com` +1. Make sure you have xmlrpc.php file in your / blog dir. If not, + change the `@xml` variable in `vimblog.vim` to find it. +1. To verify your installation, open vim, and do `:Blog rp` to get your + recent 10 posts. + +## Troubleshooting + +### "That Didn't work" +1. Check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. +1. If the error persist, check for the correct path for xmlrpc.php in @xml value. +1. Open an issue on github + +== License + +== LICENSE: + + Copyright (c) 2007 pedro mg + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vimblog.vim b/plugin/vimblog.vim similarity index 71% rename from vimblog.vim rename to plugin/vimblog.vim index 3fdb932..886524a 100644 --- a/vimblog.vim +++ b/plugin/vimblog.vim @@ -10,18 +10,18 @@ " endif " " - change your blog login/password info on the get_personal_data -" function bellow. -" - make sure you have xmlrpc.php file in your / blog dir. If not, +" function below. +" - make sure you have xmlrpc.php file in your / blog dir. If not, " change the @xml variable to find it. -" - testing: open vim, ando do -" :Blog rp +" - testing: open vim, ando do +" :Blog rp " to get your recent 10 posts. " - Questions ? e-mail please ;) " - Using it ? please, leave a word ;) if !has('ruby') - s:ErrMsg( "Error: Required vim compiled with +ruby" ) + s:ErrMsg( "Error: Required vim compiled with +ruby was not found") finish endif @@ -29,16 +29,16 @@ endif " Language: wordpress_vim " Maintainer: pedro mg " Version: 1.1 -" Last Change: 2008 Apr 04 +" Last Change: 2012 Mar 08 " Remark: Simple functions for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back +" Remark: Please, if you fine tune this code, send it back " Remark: for version upgrade ;) function! Blog_syn_hl() " {{{2 :syntax clear :syntax keyword wpType Post Title Date - :syntax region wpTitle start=/"/ end=/$/ - :syntax region wpPostId start=/\[/ end=/\]/ + :syntax region wpTitle start=/"/ end=/$/ + :syntax region wpPostId start=/\[/ end=/\]/ :highlight wpType ctermfg=Green guifg=LightGreen :highlight wpTitle cterm=bold ctermfg=Blue guifg=Blue guibg=LightCyan gui=bold :highlight wpPostId ctermfg=Red guifg=Red @@ -48,42 +48,66 @@ endfunction function! Post_syn_hl() " {{{3 :syntax clear :runtime! syntax/html.vim " content syntax is html hl, except for headers - :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs + :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs :syntax region wpPostId start=/\[/ end=/\]/ contained - :syntax match wpFields /: .*/hs=s+2 contains=wpPostId + :syntax match wpFields /: .*/hs=s+2 contains=wpPostId :highlight wpType ctermfg=Green guifg=LightGreen gui=bold :highlight wpPostId ctermfg=Red guifg=Red :highlight wpFields ctermfg=Blue guifg=Blue guibg=LightCyan endfunction " }}}3 +function! CloseQuickfixAndOpenaPost(id) " {{{3 + cclose + new +ruby < " Version: 1.2 " Last Change: 2008 Jun 14 " Remark: script function for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back +" Remark: Please, if you fine tune this code, send it back " Remark: for version upgrade ;) " Remark: V1.2 - commands added: " Remark: - Blog link ADDRESS,TITLE,STRING -:command -nargs=* Blog call Wordpress_vim() +:command! -nargs=* Blog call Wordpress_vim() function! Wordpress_vim(start, ...) " {{{1 - call Blog_syn_hl() " comment if you don't wish syntax highlight activation + call Blog_syn_hl() " comment out if you don't wish syntax highlight activation try ruby < ") + v.append(v.count-1, " ") end ####### - # list of categories. Is opened in a new temporary window, because may me for assistance on - # creating/editing a post. + # list of categories. It is opened in a new quickfix window. + # The window can be dismissed by 'q', but if you hit on a category's line, + # that name will be yanked to the default buffer and quoted so that you can put it + # in a post. # - def blog_cl + def blog_cl #{{{2 resp = blog_api("cl") # create a new window with syntax highlight. - # this allows you to rapidelly close the window (:q!) and continue blogging. - VIM::command(":new") + # this allows you to rapidly close the window (q) and continue blogging. + configure_quicklist do + VIM::command(":set wrap") + v = VIM::Buffer.current + ["CATEGORIES LIST:", " ", resp].flatten.each do |str| + v.append(v.count, str) + end + VIM::command(%q[nnoremap :execute "normal! 0y$" \| :let @@="\"" . @@ . "\"" \|:cclose]) + end + end + + ####### # {{{3 + # Utility function used to create a quickfix window which can be closed + # with a 'q' (similar to what the Ack plugin does). This can be overridden + # by passing in a string ('action') which defines the RHS of a Vimscript + # map statement e.g. configure_quicklist(%q{:echo 'moon base alpha!'}) + # + # If a block is passed with additional VimRuby goodness, that will be executed + # in the context of the new buffer. It yields back the buffer. + # + def configure_quicklist(qaction=':cclose') #{{{2 + VIM::command(":copen 10") + VIM::command("setlocal modifiable") VIM::command("call Blog_syn_hl()") - VIM::command(":set wrap") + VIM::command("nnoremap q #{qaction}") v = VIM::Buffer.current - v.append(v.count, "CATEGORIES LIST: ") - v.append(v.count, " ") - v.append(v.count, "\"#{resp.join(' ')}\"") + yield v end ####### # recent [num] posts. Gets some info for the most recent [num] or 10 posts # - def blog_rp + def blog_rp #{{{2 VIM::evaluate("a:0").to_i > 0 ? ((num = VIM::evaluate("a:1")).to_i ? num.to_i : num = 10) : num = 10 resp = blog_api("rp", num) # create a new window with syntax highlight. - # this allows you to rapidely close the window (:q!) and get that post id. - VIM::command(":new") - VIM::command("call Blog_syn_hl()") - v = VIM::Buffer.current - v.append(v.count, "MOST RECENT #{num} POSTS: ") - v.append(v.count, " ") - resp.each { |r| - v.append(v.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") - v.append(v.count, "Title: \"#{r['post_title']}\"") - v.append(v.count, " ") - } + # this allows you to rapidly close the window (:q!) and get that post id. + configure_quicklist do |buf| + enter_action = ':call CloseQuickfixAndOpenaPost(FetchPostIDBasedOnCurrentLine())' + VIM::command("nnoremap #{enter_action}") + + buf.append(0, "Move your cursor to the line with the postID and hit to edit it.") + buf.append(buf.count, " ") + buf.append(buf.count, "#{num} MOST RECENT POSTS:") + buf.append(buf.count, " ") + + resp.each { |r| + buf.append(buf.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") + buf.append(buf.count, "Title: \"#{r['post_title']}\"") + buf.append(buf.count, " ") + } + + end end ####### # get post [id]. Fetches blog post with id [id], or the last one. # - def blog_gp + def blog_gp #{{{2 VIM::command("call Post_syn_hl()") VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("gp", id) @@ -243,7 +294,7 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("del", id) resp ? VIM.command("echo \"Blog post ##{id} successfully deleted\"") : VIM.command("echo \"Deletion problem for post id ##{id}\"") @@ -255,7 +306,7 @@ ruby < '', :string => '', :title => ''} VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil @@ -267,15 +318,15 @@ ruby < resp['postid'], 'post_title' => resp['title'], 'post_date' => same_dt_fmt(resp['dateCreated'].to_time), @@ -290,33 +341,33 @@ ruby < resp['description'] } - when "rp" + when "rp" resp = @blog.call("mt.getRecentPostTitles", @blog_id, @login, @passwd, args[0]) - arr_hash = [] + arr_hash = [] resp.each { |r| arr_hash << { 'post_id' => r['postid'], 'post_title' => r['title'], 'post_date' => r['dateCreated'].to_time } - } - return arr_hash + } + return arr_hash - when "cl" + when "cl" resp = @blog.call("mt.getCategoryList", @blog_id, @login, @passwd) - arr_hash = [] + arr_hash = [] resp.each { |r| arr_hash << r['categoryName'] } - return arr_hash + return arr_hash - when "draft" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + when "draft" + args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" + args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } - + when "publish" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" + args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } - + when "del" resp = @blog.call("metaWeblog.deletePost", "1234567890ABCDE", args[0], @login, @passwd) return resp @@ -330,18 +381,18 @@ ruby <:" + :echo "Usage for getting the list of categories in a quickfix window:" :echo " :Blog cl" catch /gp/ :echo "Usage for Get Post [id]:" @@ -372,14 +423,12 @@ EOF :echo " - rp [x] => show recent [x] posts" :echo " - gp id => get post with identification id" :echo " - np => create a new post" - :echo " - publish => publish an edited/new post" + :echo " - publish => publish an edited/new post" :echo " - draft => save edited/new post as draft" :echo " - gc => get the list of categories" :echo " - del id => delete post with identification id" :echo " --- syntax helpers:" :echo " - link ADDRESS,TITLE,STRING => insert link STRING link" endtry -endfunction +endfunction " }}}1 - - From a77b4cc8b07e4b9909b8c86a0051a0e0bf464131 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Fri, 9 Mar 2012 08:08:21 -0800 Subject: [PATCH 02/52] Updates the Vimblog * Modifications to category list * Uses a quickfix list * A single 'q' dismisses the quickfix list * Selecting on a category copies that category to the default register and wraps the category in quotes for purposes of [p]asting into blog posts * Modifications to recent posts * Uses a quickfix list * Selecting on any of the rows with the post ID will lead to that ID being loaded up in a new buffer for editing * Changes layout to be Pathogen compatible * Uses a markdown readme * Updates documentation --- README | 71 ---------- README.md | 79 +++++++++++ vimblog.vim => plugin/vimblog.vim | 215 ++++++++++++++++++------------ 3 files changed, 211 insertions(+), 154 deletions(-) delete mode 100644 README create mode 100644 README.md rename vimblog.vim => plugin/vimblog.vim (71%) diff --git a/README b/README deleted file mode 100644 index 184b3cb..0000000 --- a/README +++ /dev/null @@ -1,71 +0,0 @@ -= vimblog.vim - -== description - - For Vi, Vim or GVim users, there is a simple way to manage your blog posts. Under Vim environment, you can create new blog posts, edit, list all categories, list older posts, delete posts, turn Published into Draft posts, and vice-versa. - It is out-of-the-box working for Wordpress, but very easilly, you can make it manage Blogger, MovableType, TextPattern, etc, platforms. Its the beauty of Open Source software. Study the code, change it, and use it. It is very safe to use it because unlike proprietary software, you can check for “phone_home” procedures, etc. - -== requirements: - - * you'll need VIM compiled with Ruby scripting support - - example: for Debian/Ubuntu: sudo apt-get install vim-ruby - * please, copy this file to one of your VIM dir - - example: to your .vim home folder: $HOME/.vim/vimlog.vim - * please, add this code to your .vimrc file: - - if !exists('*Wordpress_vim') - runtime vimblog.vim - endif - - * change your blog login/password info on the get_personal_data - function bellow. - * make sure you have xmlrpc.php file in your / blog dir. If not, - change the @xml variable to find it. - * testing: open vim, ando do - :Blog rp - to get your recent 10 posts. - -== how-to - - * copy the script to your Vim scripts path, $HOME/.vim directory - * edit you .vimrc (if not exists, create it: $HOME/.vimrc) and insert: - -if !exists('*Wordpress_vim') -runtime vimblog.vim -endif - - * open the vimblog.vim script and edit the personal data in def get_personal_data method approx. at line 97. - * @site value, do not insert “http://”. Just insert the blog address, like in my case “blog.tquadrado.com” - * @xml value, insert the path to your blog’s xmlrpc.php file. If, like in my case, it is in / from your blog address, do insert “/xmlrpc.php” - * run Vim and try fetching the last 10 posts by doing: - -:Blog rp - -If you can see them, it’s fine. If not, test this: - - * check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. - * if error persist, check for the correct path for xmlrpc.php in @xml value. - -== license - -== LICENSE: - - Copyright (c) 2007 pedro mg - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md new file mode 100644 index 0000000..0adc9c2 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# VIMBLOG.VIM + +## Description + +For Vi, Vim or GVim users, there is a simple way to manage your blog +posts. + +In the Vim environment you can now + +* create new blog posts +* edit / posts +* list all categories +* list older posts +* Promote turn "draft" posts into "published" (and vice-versa) + +It is an out-of-the-box solution that works for Wordpress, but which can +very easilly, be customized to manage Blogger, MovableType, TextPattern, +et al. Its the beauty of Open Source software. Study the code, change +it, and use it. It is very safe to use it because unlike proprietary +software, you can check for "phone\_home" procedures, etc. + +## Requirements: + +1. You'll need VIM compiled with Ruby scripting support. Check for + this by executing `vim --version|grep ruby`. My result (MacVim + +Janus) shows: `+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime`. This means that I have ruby scripting support compiled. Debian/Ubuntu can install Ruby support with: `sudo apt-get install vim-ruby` +1. To install you several options: + 1. Copy this file to one of your VIM directories + 1. Example: copy the script file to your .vim home folder: $HOME/.vim/vimlog.vim + 1. *Pathogen Example*: If you're using Pathogen, go to your Pathogen root + directory and then `git clone` this repository + 1. *Janus Example*: If you're using Janus then you're just a + variation on the Pathogen setup. Create a `~/.janus` directory +and then add this repository as a submodule with `git add +$GIT\_REPO\_PATH vimblog`. Git will check out the plugin for you. +1. Your VIM runtime must be made aware of this plugin by means of the + following command. Make sure it is in your `~/.vimrc` or, for +MacVim + Janus users, make sure it is in `~/.vimrc.after`. + + if !exists('\*Wordpress\_vim') + runtime vimblog.vim + endif + +1. Change your blog login/password info on the `get\_personal\_data` + function in `vimblog.vim` near line 97. +1. Set the `@site` value. Do not insert `http://`. Just insert the blog + address, like in my case `blog.tquadrado.com` +1. Make sure you have xmlrpc.php file in your / blog dir. If not, + change the `@xml` variable in `vimblog.vim` to find it. +1. To verify your installation, open vim, and do `:Blog rp` to get your + recent 10 posts. + +## Troubleshooting + +### "That Didn't work" +1. Check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. +1. If the error persist, check for the correct path for xmlrpc.php in @xml value. +1. Open an issue on github + +## LICENSE: + + Copyright (c) 2007 pedro mg + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vimblog.vim b/plugin/vimblog.vim similarity index 71% rename from vimblog.vim rename to plugin/vimblog.vim index 3fdb932..886524a 100644 --- a/vimblog.vim +++ b/plugin/vimblog.vim @@ -10,18 +10,18 @@ " endif " " - change your blog login/password info on the get_personal_data -" function bellow. -" - make sure you have xmlrpc.php file in your / blog dir. If not, +" function below. +" - make sure you have xmlrpc.php file in your / blog dir. If not, " change the @xml variable to find it. -" - testing: open vim, ando do -" :Blog rp +" - testing: open vim, ando do +" :Blog rp " to get your recent 10 posts. " - Questions ? e-mail please ;) " - Using it ? please, leave a word ;) if !has('ruby') - s:ErrMsg( "Error: Required vim compiled with +ruby" ) + s:ErrMsg( "Error: Required vim compiled with +ruby was not found") finish endif @@ -29,16 +29,16 @@ endif " Language: wordpress_vim " Maintainer: pedro mg " Version: 1.1 -" Last Change: 2008 Apr 04 +" Last Change: 2012 Mar 08 " Remark: Simple functions for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back +" Remark: Please, if you fine tune this code, send it back " Remark: for version upgrade ;) function! Blog_syn_hl() " {{{2 :syntax clear :syntax keyword wpType Post Title Date - :syntax region wpTitle start=/"/ end=/$/ - :syntax region wpPostId start=/\[/ end=/\]/ + :syntax region wpTitle start=/"/ end=/$/ + :syntax region wpPostId start=/\[/ end=/\]/ :highlight wpType ctermfg=Green guifg=LightGreen :highlight wpTitle cterm=bold ctermfg=Blue guifg=Blue guibg=LightCyan gui=bold :highlight wpPostId ctermfg=Red guifg=Red @@ -48,42 +48,66 @@ endfunction function! Post_syn_hl() " {{{3 :syntax clear :runtime! syntax/html.vim " content syntax is html hl, except for headers - :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs + :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs :syntax region wpPostId start=/\[/ end=/\]/ contained - :syntax match wpFields /: .*/hs=s+2 contains=wpPostId + :syntax match wpFields /: .*/hs=s+2 contains=wpPostId :highlight wpType ctermfg=Green guifg=LightGreen gui=bold :highlight wpPostId ctermfg=Red guifg=Red :highlight wpFields ctermfg=Blue guifg=Blue guibg=LightCyan endfunction " }}}3 +function! CloseQuickfixAndOpenaPost(id) " {{{3 + cclose + new +ruby < " Version: 1.2 " Last Change: 2008 Jun 14 " Remark: script function for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back +" Remark: Please, if you fine tune this code, send it back " Remark: for version upgrade ;) " Remark: V1.2 - commands added: " Remark: - Blog link ADDRESS,TITLE,STRING -:command -nargs=* Blog call Wordpress_vim() +:command! -nargs=* Blog call Wordpress_vim() function! Wordpress_vim(start, ...) " {{{1 - call Blog_syn_hl() " comment if you don't wish syntax highlight activation + call Blog_syn_hl() " comment out if you don't wish syntax highlight activation try ruby < ") + v.append(v.count-1, " ") end ####### - # list of categories. Is opened in a new temporary window, because may me for assistance on - # creating/editing a post. + # list of categories. It is opened in a new quickfix window. + # The window can be dismissed by 'q', but if you hit on a category's line, + # that name will be yanked to the default buffer and quoted so that you can put it + # in a post. # - def blog_cl + def blog_cl #{{{2 resp = blog_api("cl") # create a new window with syntax highlight. - # this allows you to rapidelly close the window (:q!) and continue blogging. - VIM::command(":new") + # this allows you to rapidly close the window (q) and continue blogging. + configure_quicklist do + VIM::command(":set wrap") + v = VIM::Buffer.current + ["CATEGORIES LIST:", " ", resp].flatten.each do |str| + v.append(v.count, str) + end + VIM::command(%q[nnoremap :execute "normal! 0y$" \| :let @@="\"" . @@ . "\"" \|:cclose]) + end + end + + ####### # {{{3 + # Utility function used to create a quickfix window which can be closed + # with a 'q' (similar to what the Ack plugin does). This can be overridden + # by passing in a string ('action') which defines the RHS of a Vimscript + # map statement e.g. configure_quicklist(%q{:echo 'moon base alpha!'}) + # + # If a block is passed with additional VimRuby goodness, that will be executed + # in the context of the new buffer. It yields back the buffer. + # + def configure_quicklist(qaction=':cclose') #{{{2 + VIM::command(":copen 10") + VIM::command("setlocal modifiable") VIM::command("call Blog_syn_hl()") - VIM::command(":set wrap") + VIM::command("nnoremap q #{qaction}") v = VIM::Buffer.current - v.append(v.count, "CATEGORIES LIST: ") - v.append(v.count, " ") - v.append(v.count, "\"#{resp.join(' ')}\"") + yield v end ####### # recent [num] posts. Gets some info for the most recent [num] or 10 posts # - def blog_rp + def blog_rp #{{{2 VIM::evaluate("a:0").to_i > 0 ? ((num = VIM::evaluate("a:1")).to_i ? num.to_i : num = 10) : num = 10 resp = blog_api("rp", num) # create a new window with syntax highlight. - # this allows you to rapidely close the window (:q!) and get that post id. - VIM::command(":new") - VIM::command("call Blog_syn_hl()") - v = VIM::Buffer.current - v.append(v.count, "MOST RECENT #{num} POSTS: ") - v.append(v.count, " ") - resp.each { |r| - v.append(v.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") - v.append(v.count, "Title: \"#{r['post_title']}\"") - v.append(v.count, " ") - } + # this allows you to rapidly close the window (:q!) and get that post id. + configure_quicklist do |buf| + enter_action = ':call CloseQuickfixAndOpenaPost(FetchPostIDBasedOnCurrentLine())' + VIM::command("nnoremap #{enter_action}") + + buf.append(0, "Move your cursor to the line with the postID and hit to edit it.") + buf.append(buf.count, " ") + buf.append(buf.count, "#{num} MOST RECENT POSTS:") + buf.append(buf.count, " ") + + resp.each { |r| + buf.append(buf.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") + buf.append(buf.count, "Title: \"#{r['post_title']}\"") + buf.append(buf.count, " ") + } + + end end ####### # get post [id]. Fetches blog post with id [id], or the last one. # - def blog_gp + def blog_gp #{{{2 VIM::command("call Post_syn_hl()") VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("gp", id) @@ -243,7 +294,7 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("del", id) resp ? VIM.command("echo \"Blog post ##{id} successfully deleted\"") : VIM.command("echo \"Deletion problem for post id ##{id}\"") @@ -255,7 +306,7 @@ ruby < '', :string => '', :title => ''} VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil @@ -267,15 +318,15 @@ ruby < resp['postid'], 'post_title' => resp['title'], 'post_date' => same_dt_fmt(resp['dateCreated'].to_time), @@ -290,33 +341,33 @@ ruby < resp['description'] } - when "rp" + when "rp" resp = @blog.call("mt.getRecentPostTitles", @blog_id, @login, @passwd, args[0]) - arr_hash = [] + arr_hash = [] resp.each { |r| arr_hash << { 'post_id' => r['postid'], 'post_title' => r['title'], 'post_date' => r['dateCreated'].to_time } - } - return arr_hash + } + return arr_hash - when "cl" + when "cl" resp = @blog.call("mt.getCategoryList", @blog_id, @login, @passwd) - arr_hash = [] + arr_hash = [] resp.each { |r| arr_hash << r['categoryName'] } - return arr_hash + return arr_hash - when "draft" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + when "draft" + args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" + args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } - + when "publish" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" + args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } - + when "del" resp = @blog.call("metaWeblog.deletePost", "1234567890ABCDE", args[0], @login, @passwd) return resp @@ -330,18 +381,18 @@ ruby <:" + :echo "Usage for getting the list of categories in a quickfix window:" :echo " :Blog cl" catch /gp/ :echo "Usage for Get Post [id]:" @@ -372,14 +423,12 @@ EOF :echo " - rp [x] => show recent [x] posts" :echo " - gp id => get post with identification id" :echo " - np => create a new post" - :echo " - publish => publish an edited/new post" + :echo " - publish => publish an edited/new post" :echo " - draft => save edited/new post as draft" :echo " - gc => get the list of categories" :echo " - del id => delete post with identification id" :echo " --- syntax helpers:" :echo " - link ADDRESS,TITLE,STRING => insert link STRING link" endtry -endfunction +endfunction " }}}1 - - From cea489de2c940fcfe018a6655d5391e47af4717e Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Fri, 9 Mar 2012 21:41:27 -0800 Subject: [PATCH 03/52] Cleans up README --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0adc9c2..a216f90 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ posts. In the Vim environment you can now -* create new blog posts +* create new blog posts * edit / posts * list all categories * list older posts @@ -22,26 +22,28 @@ software, you can check for "phone\_home" procedures, etc. ## Requirements: 1. You'll need VIM compiled with Ruby scripting support. Check for - this by executing `vim --version|grep ruby`. My result (MacVim + -Janus) shows: `+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime`. This means that I have ruby scripting support compiled. Debian/Ubuntu can install Ruby support with: `sudo apt-get install vim-ruby` + this by executing `vim --version|grep ruby`. My result ([MacVim + +Janus](https://github.com/carlhuda/janus)) shows: `+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime`. This means that I have ruby scripting support compiled. Debian/Ubuntu can install Ruby support with: `sudo apt-get install vim-ruby` 1. To install you several options: 1. Copy this file to one of your VIM directories - 1. Example: copy the script file to your .vim home folder: $HOME/.vim/vimlog.vim - 1. *Pathogen Example*: If you're using Pathogen, go to your Pathogen root - directory and then `git clone` this repository + 1. *Pure Vim Example*: copy the script file to your .vim home folder: $HOME/.vim/vimlog.vim + 1. *Pathogen Example*: If you're using [Tim Pope's + Pathogen](http://www.vim.org/scripts/script.php?script_id=2332), +go to your Pathogen root directory and then `git clone` this repository 1. *Janus Example*: If you're using Janus then you're just a variation on the Pathogen setup. Create a `~/.janus` directory and then add this repository as a submodule with `git add -$GIT\_REPO\_PATH vimblog`. Git will check out the plugin for you. +$GIT_REPO_PATH vimblog`. Git will check out the plugin for you as a +[git submodule](http://book.git-scm.com/5_submodules.html) 1. Your VIM runtime must be made aware of this plugin by means of the following command. Make sure it is in your `~/.vimrc` or, for -MacVim + Janus users, make sure it is in `~/.vimrc.after`. +MacVim + Janus users, make sure it is in `~/.vimrc.after` - if !exists('\*Wordpress\_vim') - runtime vimblog.vim - endif + if !exists('\*Wordpress\_vim') + runtime vimblog.vim + endif -1. Change your blog login/password info on the `get\_personal\_data` +1. Change your blog login/password info on the `get_personal_data` function in `vimblog.vim` near line 97. 1. Set the `@site` value. Do not insert `http://`. Just insert the blog address, like in my case `blog.tquadrado.com` From 22e1e24e0b32b8a84511b03ad9788104a7a58630 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Fri, 9 Mar 2012 21:47:28 -0800 Subject: [PATCH 04/52] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a216f90..a4f150b 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ $GIT_REPO_PATH vimblog`. Git will check out the plugin for you as a following command. Make sure it is in your `~/.vimrc` or, for MacVim + Janus users, make sure it is in `~/.vimrc.after` - if !exists('\*Wordpress\_vim') - runtime vimblog.vim - endif + if !exists('\*Wordpress\_vim') + runtime vimblog.vim + endif 1. Change your blog login/password info on the `get_personal_data` function in `vimblog.vim` near line 97. From b76ef4827c200a467636dfcc0b0f40d120600e11 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Fri, 9 Mar 2012 22:47:16 -0800 Subject: [PATCH 05/52] Clean error msgs so console VIM plays nice --- plugin/vimblog.vim | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 886524a..481d934 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -1,29 +1,5 @@ -" Requirements: -" - you'll need VIM compiled with Ruby scripting support -" - example: for Debian/Ubuntu: sudo apt-get install vim-ruby -" - please, copy this file to one of your VIM dir -" - example: to your .vim home folder: $HOME/.vim/vimlog.vim -" - please, add this code to your .vimrc file: -" -" if !exists('*Wordpress_vim') -" runtime vimblog.vim -" endif -" -" - change your blog login/password info on the get_personal_data -" function below. -" - make sure you have xmlrpc.php file in your / blog dir. If not, -" change the @xml variable to find it. -" - testing: open vim, ando do -" :Blog rp -" to get your recent 10 posts. -" - Questions ? e-mail please ;) -" - Using it ? please, leave a word ;) - - -if !has('ruby') - s:ErrMsg( "Error: Required vim compiled with +ruby was not found") - finish -endif +" For use and setup documentation, consult the Readme.md file + " Vim syntax functions " Language: wordpress_vim @@ -96,6 +72,10 @@ endfunction :command! -nargs=* Blog call Wordpress_vim() function! Wordpress_vim(start, ...) " {{{1 + if !has('ruby') + echoerr("Vimblog is not operational since it was not compiled with a Ruby interpreter (+ruby)") + finish + endif call Blog_syn_hl() " comment out if you don't wish syntax highlight activation try ruby < Date: Sun, 11 Mar 2012 11:12:57 -0700 Subject: [PATCH 06/52] Adds media upload command --- plugin/vimblog.vim | 51 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 481d934..bc28794 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -69,7 +69,7 @@ endfunction " Remark: V1.2 - commands added: " Remark: - Blog link ADDRESS,TITLE,STRING -:command! -nargs=* Blog call Wordpress_vim() +:command! -nargs=* -complete=file Blog call Wordpress_vim() function! Wordpress_vim(start, ...) " {{{1 if !has('ruby') @@ -87,16 +87,20 @@ ruby < e xmlrpc_flt_xcptn(e) end end + def method_missing(sym, *args) + VIM.command("echo \"Vimblog fatal error: unable to resolve #{sym.to_s}\"") + end + ####### # class variables for personnal data. Please *change* them accordingly. # CHANGE HERE: @@ -154,6 +158,36 @@ ruby < ex + VIM::command("echo \"Encoding failed because #{ex.to_s}\"") + end + + result = blog_api("um", data) + url = "\"#\"" + + v = VIM::Buffer.current + ln = v.line_number + v.append(ln, url) + VIM::command("normal! jf#") + end ####### # save post as draft. Verifies if it is new post, or an editied existing one. # @@ -330,6 +364,11 @@ ruby < 0 ? ([] << VIM::evaluate("a:000")): '' )) EOF catch /del/ :echo "Usage for deleting a post:" @@ -397,12 +436,16 @@ EOF catch /rp/ :echo "Usage for Recent [x] Posts (defaults to last 10): " :echo " :Blog rp [x]" + catch /um/ + :echo "Usage for Upload Media" + :echo " :Blog um [filename]" catch // :echo "Usage is :Blog option [arg]" :echo " switches:" :echo " - rp [x] => show recent [x] posts" :echo " - gp id => get post with identification id" :echo " - np => create a new post" + :echo " - um [f] => upload media asset [path to asset]" :echo " - publish => publish an edited/new post" :echo " - draft => save edited/new post as draft" :echo " - gc => get the list of categories" From 2a1516a614bb304323f0fbd6f5f4f127c72b4bdf Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 14:54:59 -0700 Subject: [PATCH 07/52] Adds style configuration --- README.md | 8 ++++++++ plugin/vimblog.vim | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4f150b..c1aa952 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,14 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` 1. To verify your installation, open vim, and do `:Blog rp` to get your recent 10 posts. +## CONFIGURATION + +Here are some globals you may define in your `.vimrc`. + +`g:vimblogImageStyle="centered"` : This will provide CSS classes that +are applied to the `` tags that result from using the media upload +function. Typically you would add `centered` or `featured-image`. + ## Troubleshooting ### "That Didn't work" diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index bc28794..0182326 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -1,3 +1,4 @@ +" vim: set foldmethod=marker: " " For use and setup documentation, consult the Readme.md file @@ -181,12 +182,14 @@ ruby <\"#\"" + gas = VIM::evaluate("g:vimblogImageStyle") + gas = (gas == 0 ? '' : 'class="' + gas + '"') + url = "\"#\"" v = VIM::Buffer.current ln = v.line_number v.append(ln, url) - VIM::command("normal! jf#") + VIM::command("normal! j==f#") end ####### # save post as draft. Verifies if it is new post, or an editied existing one. From 633a7511be2c14412faf2081c00c35f817fcd05c Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 16:33:35 -0700 Subject: [PATCH 08/52] Cleans category logic; adds error reporting v. silent failure --- README.md | 13 +++++- plugin/vimblog.vim | 100 +++++++++++++++++++++++---------------------- 2 files changed, 62 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index c1aa952..bcddd65 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,23 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` 1. To verify your installation, open vim, and do `:Blog rp` to get your recent 10 posts. -## CONFIGURATION +## Configuration -Here are some globals you may define in your `.vimrc`. +here are some globals you may define in your `.vimrc`. `g:vimblogImageStyle="centered"` : This will provide CSS classes that are applied to the `` tags that result from using the media upload function. Typically you would add `centered` or `featured-image`. +## Known Issues + +*Categories*: Multiple categories on initial post creation is handled properly and multiple categories are comma-delimited. Thus you can have a category like `Science and Technology` on a line with `Dinner` like +`Science and Technology, Dinner` and things are great. When this is +retrieved *back*, the API does not preserve the separation either as +array elements or a delimited string and thus your separation breaks. +For the time being you must re-insert those commas. Thankfully the +`:Blog cl` will help you build an accurate list. + ## Troubleshooting ### "That Didn't work" diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 0182326..7b92cb1 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -91,10 +91,13 @@ ruby < e xmlrpc_flt_xcptn(e) + rescue => ex + VIM::command("echo \"Unhandled Error: #{ex} and #{ex.backtrace}\"") end end @@ -125,20 +128,20 @@ ruby < ") + v.append(v.count-1, " ") end ####### @@ -228,7 +229,8 @@ ruby < :execute "normal! 0y$" \| :let @@="\"" . @@ . "\"" \|:cclose]) + VIM::command(%q[nnoremap :execute "normal! 0y$" \| :cclose]) end end @@ -263,7 +265,7 @@ ruby < 0 ? ((num = VIM::evaluate("a:1")).to_i ? num.to_i : num = 10) : num = 10 resp = blog_api("rp", num) # create a new window with syntax highlight. @@ -289,7 +291,7 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("gp", id) @@ -311,7 +313,7 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("del", id) resp ? VIM.command("echo \"Blog post ##{id} successfully deleted\"") : VIM.command("echo \"Deletion problem for post id ##{id}\"") @@ -323,7 +325,7 @@ ruby < '', :string => '', :title => ''} VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil @@ -358,35 +360,35 @@ ruby < resp['description'] } - when "rp" - resp = @blog.call("mt.getRecentPostTitles", @blog_id, @login, @passwd, args[0]) - arr_hash = [] - resp.each { |r| arr_hash << { 'post_id' => r['postid'], - 'post_title' => r['title'], - 'post_date' => r['dateCreated'].to_time } - } - return arr_hash - - when "um" - args = ["metaWeblog.newMediaObject", @blog_id, @login, @passwd, args.pop] - result = @blog.call *args - return result - - when "cl" - resp = @blog.call("mt.getCategoryList", @blog_id, @login, @passwd) - arr_hash = [] - resp.each { |r| arr_hash << r['categoryName'] } - return arr_hash - - when "draft" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + when "rp" + resp = @blog.call("mt.getRecentPostTitles", @blog_id, @login, @passwd, args[0]) + arr_hash = [] + resp.each { |r| arr_hash << { 'post_id' => r['postid'], + 'post_title' => r['title'], + 'post_date' => r['dateCreated'].to_time } + } + return arr_hash + + when "um" + args = ["metaWeblog.newMediaObject", @blog_id, @login, @passwd, args.pop] + result = @blog.call *args + return result + + when "cl" + resp = @blog.call("mt.getCategoryList", @blog_id, @login, @passwd) + arr_hash = [] + resp.each { |r| arr_hash << r['categoryName'] } + return arr_hash + + when "draft" + args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" + args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } when "publish" - args[2] ? call = "metaWeblog.newPost" : call = "metaWeblog.editPost" - args[2] ? which_id = @blog_id : which_id = args[0]['post_id'] + call = args[2] ? "metaWeblog.newPost" : "metaWeblog.editPost" + which_id = args[2] ? @blog_id : args[0]['post_id'] resp = @blog.call(call, which_id, @login, @passwd, args[0], args[1]) # hash content, boolean state ("publish"|"draft") return { 'post_id' => resp } @@ -428,7 +430,7 @@ EOF :echo "Usage for Publishing a post:" :echo " :Blog publish" catch /gc/ - :echo "Usage for getting the list of categories in a quickfix window:" + :echo "Usage for getting the list of categories: :" :echo " :Blog cl" catch /gp/ :echo "Usage for Get Post [id]:" @@ -437,7 +439,7 @@ EOF :echo "Usage for New Post:" :echo " :Blog np" catch /rp/ - :echo "Usage for Recent [x] Posts (defaults to last 10): " + :echo "Usage for Recent [x] Posts (defaults to last 10): " :echo " :Blog rp [x]" catch /um/ :echo "Usage for Upload Media" From 92b33fcfe0a1c26830e72f88d73d32219b25dfab Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 16:42:56 -0700 Subject: [PATCH 09/52] Update README.md --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bcddd65..d095a4f 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,18 @@ For Vi, Vim or GVim users, there is a simple way to manage your blog posts. -In the Vim environment you can now +In the Vim environment you can now: * create new blog posts * edit / posts * list all categories * list older posts * Promote turn "draft" posts into "published" (and vice-versa) +* Upload media to your blog from within VIM and get a link to it + +In short, if you've been hanging on to Textmate for its blogging bundle, +you now have a comparable featureset in Vim thanks to Vimblog and +[GIFL](http://github.com/sgharms/gifl). It is an out-of-the-box solution that works for Wordpress, but which can very easilly, be customized to manage Blogger, MovableType, TextPattern, @@ -56,13 +61,23 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` here are some globals you may define in your `.vimrc`. -`g:vimblogImageStyle="centered"` : This will provide CSS classes that -are applied to the `` tags that result from using the media upload -function. Typically you would add `centered` or `featured-image`. +`g:vimblogImageStyle="css-class-1 css-class-2"` : This will provide CSS +classes that are applied to the `` tags that result from using the +media upload function. Typically you would add `centered` or +`featured-image`. + +I put mine like so: + + if !exists('\*Wordpress\_vim') + runtime vimblog.vim + g:vimblogImageStyle="centered" + endif ## Known Issues -*Categories*: Multiple categories on initial post creation is handled properly and multiple categories are comma-delimited. Thus you can have a category like `Science and Technology` on a line with `Dinner` like +*Categories*: Multiple categories on initial post creation is handled +properly and multiple categories are comma-delimited. Thus you can have +a category like `Science and Technology` on a line with `Dinner` like `Science and Technology, Dinner` and things are great. When this is retrieved *back*, the API does not preserve the separation either as array elements or a delimited string and thus your separation breaks. From f25bcc1e4e86d027c2d953a8056d92328a199cca Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 16:43:27 -0700 Subject: [PATCH 10/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d095a4f..4967579 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` ## Configuration -here are some globals you may define in your `.vimrc`. +Here are some globals you may define in your `.vimrc`. `g:vimblogImageStyle="css-class-1 css-class-2"` : This will provide CSS classes that are applied to the `` tags that result from using the From 00cbe2194b9b7b37f980557377ac59ce791f6d26 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 16:48:36 -0700 Subject: [PATCH 11/52] Fix raise message --- plugin/vimblog.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 7b92cb1..a0bb514 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -91,7 +91,7 @@ ruby < e From be74dbb32cb8407e68028330dac6851a0a2b6fb4 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 11 Mar 2012 17:31:07 -0700 Subject: [PATCH 12/52] Clean up args logic --- plugin/vimblog.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index a0bb514..29c1d71 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -92,8 +92,11 @@ ruby < e xmlrpc_flt_xcptn(e) rescue => ex @@ -165,7 +168,7 @@ ruby < 0 ? ([] << VIM::evaluate("a:000")): '' )) + Wp_vim.new(VIM::evaluate("a:start"), (VIM::evaluate("a:0") > 0 ? VIM::evaluate("a:000") : '' )) EOF catch /del/ :echo "Usage for deleting a post:" From fc248f120d83140705e4f79d46722d03becca096 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Tue, 13 Mar 2012 00:46:02 -0700 Subject: [PATCH 13/52] Tightens URL formatting --- plugin/vimblog.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 29c1d71..b71c5c3 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -96,7 +96,8 @@ ruby < e xmlrpc_flt_xcptn(e) rescue => ex @@ -105,7 +106,7 @@ ruby < ex - VIM::command("echo \"Encoding failed because #{ex.to_s}\"") + VIM::command("echom \"Encoding failed because #{ex.to_s}\"") end result = blog_api("um", data) gas = VIM::evaluate("g:vimblogImageStyle") - gas = (gas == 0 ? '' : 'class="' + gas + '"') - url = "\"#\"" + VIM::command("echo \"Your g:vimblogImageStyle configuration was not set. Check out the vimblog README.md\"") + gas = (gas.nil? ? '' : 'class="' + gas + '"') + url = "\"#\"" v = VIM::Buffer.current ln = v.line_number v.append(ln, url) VIM::command("normal! j==f#") end + ####### # save post as draft. Verifies if it is new post, or an editied existing one. # From 806a6cbf4dbba470e795b8b830461cd299cf7e06 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Wed, 14 Mar 2012 10:46:37 -0700 Subject: [PATCH 14/52] Adds preview on drafts on Mac + Chrome + Wordpress --- README.md | 2 ++ plugin/vimblog.vim | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4967579..985ea86 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ In the Vim environment you can now: * list older posts * Promote turn "draft" posts into "published" (and vice-versa) * Upload media to your blog from within VIM and get a link to it +* *Mac+Wordpress+Chrome*: After using `:Blog draft` you can preview + your draft with `p`, `\\p` by default In short, if you've been hanging on to Textmate for its blogging bundle, you now have a comparable featureset in Vim thanks to Vimblog and diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index b71c5c3..aebaf34 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -11,6 +11,7 @@ " Remark: Please, if you fine tune this code, send it back " Remark: for version upgrade ;) +" Highlighter functions{{{ 1 function! Blog_syn_hl() " {{{2 :syntax clear :syntax keyword wpType Post Title Date @@ -22,7 +23,7 @@ function! Blog_syn_hl() " {{{2 endfunction " }}}2 -function! Post_syn_hl() " {{{3 +function! Post_syn_hl() " {{{ 2 :syntax clear :runtime! syntax/html.vim " content syntax is html hl, except for headers :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs @@ -32,8 +33,10 @@ function! Post_syn_hl() " {{{3 :highlight wpPostId ctermfg=Red guifg=Red :highlight wpFields ctermfg=Blue guifg=Blue guibg=LightCyan endfunction -" }}}3 +" }}} 2 +" }}} 1 +" Auxilary Ruby commands{{{ 2 function! CloseQuickfixAndOpenaPost(id) " {{{3 cclose new @@ -42,9 +45,27 @@ ruby <f:2ly$g`." + if @@ == 'none' + echom("No preview URL found") + else + let l:url = @@ . '&preview=true' + let @@ = l:url + echo('Previewing: ' . l:url) + exec(system("open -a \"Google Chrome\" \"". l:url . "\"")) + endif + + let @@ = l:storage +endfunction +" }}}3 -function! FetchPostIDBasedOnCurrentLine() " {{{3 +function! FetchPostIDBasedOnCurrentLine() " {{{ 3 let l:temp = @@ execute "normal! yy" let l:line = @@ @@ -56,7 +77,8 @@ ruby < p :call WordpressPreviewWithChromeOnMac()") end ####### From 1708781552126c8c4ed4a094950dc83080cabf58 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 25 Mar 2012 00:28:47 -0700 Subject: [PATCH 15/52] Fetching post now gets content after a more break --- plugin/vimblog.vim | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index aebaf34..13b9069 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -142,7 +142,7 @@ ruby <\"#\"" + url = "\"#\"" v = VIM::Buffer.current ln = v.line_number @@ -376,7 +376,10 @@ ruby <' + resp['mt_text_more'] ) return { 'post_id' => resp['postid'], 'post_title' => resp['title'], 'post_date' => same_dt_fmt(resp['dateCreated'].to_time), @@ -388,7 +391,7 @@ ruby < resp['mt_allow_pings'], 'post_ping_status' => resp['mt_ping_status'], 'post_categories' => resp['categories'].join(' '), - 'post_body' => resp['description'] + 'post_body' => body } when "rp" From 55acc17a88d88cd4cbe3836de3e993158ed5cd9c Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 25 Mar 2012 11:32:11 -0700 Subject: [PATCH 16/52] Moves configuration to a global dict --- plugin/vimblog.vim | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 13b9069..8dcf05e 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -99,6 +99,11 @@ function! Wordpress_vim(start, ...) " {{{1 echoerr("Vimblog is not operational since it was not compiled with a Ruby interpreter (+ruby)") finish endif + if !exists("g:vimblogConfig") + echoerr("Vimblog is not operational since its g:vimblogConfig does not exist.") + finish + endif + call Blog_syn_hl() " comment out if you don't wish syntax highlight activation try ruby <\"#\"" From 7685215fadb1617ca266ac3febed974c326851a8 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 25 Mar 2012 11:48:12 -0700 Subject: [PATCH 17/52] Adds "view post" support for completed entries --- plugin/vimblog.vim | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 8dcf05e..a1e8f47 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -47,7 +47,7 @@ EOF endfunction " }}}3 -function! WordpressPreviewWithChromeOnMac() " {{{ 3 +function! WordpressViewWithChromeOnMac(...) " {{{ 3 let l:storage = @@ let @@ = 'none' @@ -55,9 +55,14 @@ function! WordpressPreviewWithChromeOnMac() " {{{ 3 if @@ == 'none' echom("No preview URL found") else - let l:url = @@ . '&preview=true' - let @@ = l:url - echo('Previewing: ' . l:url) + if (a:0 > 0 ) + let l:url = @@ . '&preview=true' + let @@ = l:url + echo('Previewing: ' . l:url) + else + let l:url = @@ + echo('Viewing: ' . l:url) + endif exec(system("open -a \"Google Chrome\" \"". l:url . "\"")) endif @@ -243,7 +248,7 @@ ruby < p :call WordpressPreviewWithChromeOnMac()") + VIM::command("nnoremap p :call WordpressViewWithChromeOnMac('preview-mode')") end ####### @@ -347,6 +352,7 @@ ruby < p :call WordpressViewWithChromeOnMac()") end ####### From c38cf50e32b3b01f20d8b44ccb4162f16933b9e6 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 25 Mar 2012 11:48:46 -0700 Subject: [PATCH 18/52] Updates README --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 985ea86..d58cef2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,9 @@ In the Vim environment you can now: * Promote turn "draft" posts into "published" (and vice-versa) * Upload media to your blog from within VIM and get a link to it * *Mac+Wordpress+Chrome*: After using `:Blog draft` you can preview - your draft with `p`, `\\p` by default + your draft with `p`, `\\p` by default. Additionally, if you + access a pre-existing post (`Blog rp`, then `` on a line with the ID + in it), thereafter `\\p` will launch the entry in Chrome. In short, if you've been hanging on to Textmate for its blogging bundle, you now have a comparable featureset in Vim thanks to Vimblog and @@ -61,20 +63,24 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` ## Configuration -Here are some globals you may define in your `.vimrc`. +**YOU MUST** define the following global in your `.vimrc`. -`g:vimblogImageStyle="css-class-1 css-class-2"` : This will provide CSS -classes that are applied to the `` tags that result from using the -media upload function. Typically you would add `centered` or -`featured-image`. + let g:vimblogConfig = {'login': '*username*', 'passwd': '*pw*', 'site': '*yoursite*', 'xml_rpc_path': '/xmlrpc.php', 'port': '80', 'image_style': '*classes you want to add to images*'} I put mine like so: if !exists('\*Wordpress\_vim') runtime vimblog.vim - g:vimblogImageStyle="centered" + let g:vimblogConfig = { ... my dictionary ...} endif +`image_style` : This will provide CSS classes that are applied to the +`` tags that result from using the media upload function. +Typically you would add `centered` or `featured-image`. + +Use of this configuration dictionary allows the configuration and the +code to be separated. + ## Known Issues *Categories*: Multiple categories on initial post creation is handled From ed5d2495594b26bd1c082d78f8de8b3da4654d27 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 25 Mar 2012 11:56:47 -0700 Subject: [PATCH 19/52] Removes annoying extra space on delimiter line --- plugin/vimblog.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index a1e8f47..7d16a52 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -264,7 +264,7 @@ ruby < ") + v.append(v.count-1, "") end ####### From c20733fd4a6d796d7800d6b1f26024d19050ce44 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sat, 31 Mar 2012 19:19:09 -0700 Subject: [PATCH 20/52] Adds a help function. --- plugin/vimblog.vim | 56 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 7d16a52..c39ae47 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -37,6 +37,23 @@ endfunction " }}} 1 " Auxilary Ruby commands{{{ 2 + +"{{{3 +function! BlogHelp() + echo "Usage is :Blog option [arg]" + echo " switches:" + echo " - rp [x] => show recent [x] posts" + echo " - gp id => get post with identification id" + echo " - np => create a new post" + echo " - um file => upload media asset [path to asset]" + echo " - publish => publish an edited/new post" + echo " - draft => save edited/new post as draft" + echo " - gc => get the list of categories" + echo " - del id => delete post with identification id" + echo " - help => this message" +endfunction +"}}}3 + function! CloseQuickfixAndOpenaPost(id) " {{{3 cclose new @@ -110,10 +127,14 @@ function! Wordpress_vim(start, ...) " {{{1 endif call Blog_syn_hl() " comment out if you don't wish syntax highlight activation +" }}}1 + try +" {{{1 ruby < e xmlrpc_flt_xcptn(e) rescue => ex - VIM::command("echo \"Unhandled Error: #{ex} and #{ex.backtrace}\"") + VIM::command("echo \"Unhandled Error: #{ex.to_s} and #{ex.backtrace.join('*')}\"") end end + def blog_help(args) + blog_api('help') + end + def method_missing(sym, *args) VIM.command("echo \"Vimblog fatal error: unable to resolve #{sym.to_s} with #{args}\"") end @@ -201,7 +226,7 @@ ruby < 0 ? VIM::evaluate("a:000") : '' )) EOF +" }}} 1 +" {{{ 1 catch /del/ :echo "Usage for deleting a post:" :echo " :Blog del id" @@ -492,19 +522,11 @@ EOF catch /um/ :echo "Usage for Upload Media" :echo " :Blog um [filename]" - catch // - :echo "Usage is :Blog option [arg]" - :echo " switches:" - :echo " - rp [x] => show recent [x] posts" - :echo " - gp id => get post with identification id" - :echo " - np => create a new post" - :echo " - um [f] => upload media asset [path to asset]" - :echo " - publish => publish an edited/new post" - :echo " - draft => save edited/new post as draft" - :echo " - gc => get the list of categories" - :echo " - del id => delete post with identification id" - :echo " --- syntax helpers:" - :echo " - link ADDRESS,TITLE,STRING => insert link STRING link" + catch /help/ + call BlogHelp() + catch /(.*)/ + :echo v:exception + call BlogHelp() endtry endfunction " }}}1 From da60191f35a8d6ca623a6403fbf98a43ee58c75b Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sat, 31 Mar 2012 23:39:51 -0700 Subject: [PATCH 21/52] Spelling error is fixed --- plugin/vimblog.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index c39ae47..0676655 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -167,8 +167,7 @@ ruby < Date: Sat, 31 Mar 2012 23:41:52 -0700 Subject: [PATCH 22/52] Refactors calculate_date --- plugin/vimblog.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 0676655..5005e67 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -180,6 +180,12 @@ ruby < Date: Sat, 31 Mar 2012 23:43:38 -0700 Subject: [PATCH 23/52] Fixes spelling --- plugin/vimblog.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 5005e67..d73f1b9 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -212,7 +212,8 @@ ruby < Date: Sun, 1 Apr 2012 00:00:17 -0700 Subject: [PATCH 24/52] Removes method that I think is bogus --- plugin/vimblog.vim | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index d73f1b9..02fc6f8 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -395,27 +395,13 @@ ruby < '', :string => '', :title => ''} - VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil - v.append(v.count-1, " a:0 --> #{VIM::evaluate("a:0")} ") - v.append(v.count-1, " a:1 --> #{VIM::evaluate("a:1")} ") - v.append(v.count-1, "#{link[:string]}") - end - ####### # api calls. Allways returns an hash so that if api is changed, only this # function needs to be changed. One can use between Blogger, metaWeblog or # MovableType very easily. # def blog_api(fn_api, *args) #{{{2 + VIM::command("echo \"IN the api and operating on #{fn_api}\"") begin case fn_api From 7e267214d0334024623200208d2cf09ab54226c1 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 1 Apr 2012 00:00:52 -0700 Subject: [PATCH 25/52] Adds a nice debugging method --- plugin/vimblog.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 02fc6f8..19e8aab 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -363,6 +363,31 @@ ruby < Date: Sun, 1 Apr 2012 00:08:20 -0700 Subject: [PATCH 26/52] Remove stray debug data --- plugin/vimblog.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 19e8aab..3599b7c 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -426,7 +426,6 @@ ruby < Date: Sun, 1 Apr 2012 00:00:52 -0700 Subject: [PATCH 27/52] Adds a nice debugging method --- plugin/vimblog.vim | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 02fc6f8..3599b7c 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -363,6 +363,31 @@ ruby < Date: Tue, 3 Apr 2012 12:28:27 -0700 Subject: [PATCH 28/52] Allows multiple categories --- plugin/vimblog.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 3599b7c..5e9e0f2 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -445,7 +445,7 @@ ruby < resp['comment_status'], 'post_allow_pings' => resp['mt_allow_pings'], 'post_ping_status' => resp['mt_ping_status'], - 'post_categories' => resp['categories'].join(' '), + 'post_categories' => resp['categories'].join(', '), 'post_body' => body } From 94e8ea06d6a34a70569b65af4dc7f90b5bb22590 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Tue, 3 Apr 2012 12:28:59 -0700 Subject: [PATCH 29/52] Update README.md --- README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index d58cef2..05d2cee 100644 --- a/README.md +++ b/README.md @@ -81,20 +81,9 @@ Typically you would add `centered` or `featured-image`. Use of this configuration dictionary allows the configuration and the code to be separated. -## Known Issues - -*Categories*: Multiple categories on initial post creation is handled -properly and multiple categories are comma-delimited. Thus you can have -a category like `Science and Technology` on a line with `Dinner` like -`Science and Technology, Dinner` and things are great. When this is -retrieved *back*, the API does not preserve the separation either as -array elements or a delimited string and thus your separation breaks. -For the time being you must re-insert those commas. Thankfully the -`:Blog cl` will help you build an accurate list. - ## Troubleshooting -### "That Didn't work" +### "That Didn't Work" 1. Check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. 1. If the error persist, check for the correct path for xmlrpc.php in @xml value. 1. Open an issue on github From 1fcbfd47d0067b79add626e5f8d64e70124c8105 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 18:21:20 -0700 Subject: [PATCH 30/52] Adds vim-help documentation --- doc/vimblog.txt | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 doc/vimblog.txt diff --git a/doc/vimblog.txt b/doc/vimblog.txt new file mode 100644 index 0000000..66acb8e --- /dev/null +++ b/doc/vimblog.txt @@ -0,0 +1,75 @@ +*vimblog.vim* : Plugin for blogging from within Vim + +#=============================================================================== + *vimblog-author* +Original Author: Pedro MG +Major Upgrate: Steven G. Harms +#=============================================================================== + +CONTENTS *vimblog-contents* + +|vimblog-about| Introduction +|vimblog-configuration| Configuration +|vimblog-usage| Usage + +ABOUT VIMBLOG *vimblog-about* + +For Vi, Vim or GVim users, there is a simple way to manage your blog +posts. + +In the Vim environment you can now: + + * Create new blog posts + * Edit / posts + * List all categories + * List older posts + * Promote turn "draft" posts into "published" (and vice-versa) + * Upload media to your blog from within VIM and get a link to it + * Mac+Wordpress+Chrome: After using :Blog draft you can preview + your draft with p, \p by default. Additionally, if you + access a pre-existing post (Blog rp, then on a line with the ID + in it), thereafter \p will launch the entry in Chrome. + +In short, if you've been hanging on to Textmate for its blogging bundle, +you now have a comparable featureset in Vim thanks to Vimblog and +|GIFL|. + +It is an out-of-the-box solution that works for Wordpress, but which can +very easilly, be customized to manage Blogger, MovableType, TextPattern, +et al. Its the beauty of Open Source software. Study the code, change +it, and use it. It is very safe to use it because unlike proprietary +software, you can check for "phone\_home" procedures, etc. + +VIMBLOG CONFIGURATION *vimblog-configuration* + *g:vimblogConfig* + +You must define the configuration in your ~/.vimrc by defining a +dictionary (aka a Hash) called g:vimblogConfig. + + +g:vimblogConfig = { + 'login': '*username*', + 'passwd': '*pw*', + 'site': '*yoursite*', + 'xml_rpc_path': '/xmlrpc.php', + 'port': '80', + 'image_style': '*classes you want to add to images*' +} + + +USING VIMBLOG *vimblog-usage* + +Vimblog functions are invoked from the : prompt and the keyword +"Blog". Thus :Blog np will allow you to create a new post, :Blog rp +will fetch recent posts. :Blog help will also display this help menu. + + :blog rp [x] => show recent [x] posts" + :blog gp id => get post with identification id" + :blog np => create a new post" + :blog um file => upload media asset [path to asset]" + :blog publish => publish an edited/new post" + :blog draft => save edited/new post as draft" + :blog gc => get the list of categories" + :blog del id => delete post with identification id" + :blog help => this message" + From 5b424c2f45ed6f571be3c5051821638934559daa Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 18:25:05 -0700 Subject: [PATCH 31/52] Move to using a proper syntax highlight config --- README.md | 4 ++-- plugin/vimblog.vim | 41 +---------------------------------------- 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 05d2cee..1b0862d 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,13 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` **YOU MUST** define the following global in your `.vimrc`. - let g:vimblogConfig = {'login': '*username*', 'passwd': '*pw*', 'site': '*yoursite*', 'xml_rpc_path': '/xmlrpc.php', 'port': '80', 'image_style': '*classes you want to add to images*'} + let g:vimblogConfig = {'login': '*username*', 'passwd': '*pw*', 'site': '*yoursite*', 'xml_rpc_path': '/xmlrpc.php', 'port': '80', 'image_style': '*classes you want to add to images*', additional_ft': *additional filetypes that a vimblog should syntax highlight with e.g. (markdown|textile|html) - if unset, vimblog buffers will only have 'vimblog' highlighting } I put mine like so: + let g:vimblogConfig = { ... my configuration dictionary ...} if !exists('\*Wordpress\_vim') runtime vimblog.vim - let g:vimblogConfig = { ... my dictionary ...} endif `image_style` : This will provide CSS classes that are applied to the diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 5e9e0f2..1014d1b 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -1,42 +1,7 @@ " vim: set foldmethod=marker: " " For use and setup documentation, consult the Readme.md file - -" Vim syntax functions -" Language: wordpress_vim -" Maintainer: pedro mg -" Version: 1.1 -" Last Change: 2012 Mar 08 -" Remark: Simple functions for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back -" Remark: for version upgrade ;) - -" Highlighter functions{{{ 1 -function! Blog_syn_hl() " {{{2 - :syntax clear - :syntax keyword wpType Post Title Date - :syntax region wpTitle start=/"/ end=/$/ - :syntax region wpPostId start=/\[/ end=/\]/ - :highlight wpType ctermfg=Green guifg=LightGreen - :highlight wpTitle cterm=bold ctermfg=Blue guifg=Blue guibg=LightCyan gui=bold - :highlight wpPostId ctermfg=Red guifg=Red -endfunction -" }}}2 - -function! Post_syn_hl() " {{{ 2 - :syntax clear - :runtime! syntax/html.vim " content syntax is html hl, except for headers - :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs - :syntax region wpPostId start=/\[/ end=/\]/ contained - :syntax match wpFields /: .*/hs=s+2 contains=wpPostId - :highlight wpType ctermfg=Green guifg=LightGreen gui=bold - :highlight wpPostId ctermfg=Red guifg=Red - :highlight wpFields ctermfg=Blue guifg=Blue guibg=LightCyan -endfunction -" }}} 2 -" }}} 1 - -" Auxilary Ruby commands{{{ 2 +" Auxiliary Ruby commands{{{ 2 "{{{3 function! BlogHelp() @@ -126,7 +91,6 @@ function! Wordpress_vim(start, ...) " {{{1 finish endif - call Blog_syn_hl() " comment out if you don't wish syntax highlight activation " }}}1 try @@ -288,7 +252,6 @@ ruby < q #{qaction}") v = VIM::Buffer.current yield v @@ -392,7 +354,6 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("gp", id) v = VIM::Buffer.current From 29f9a62b2137ba1e77ff8fc4961410cb208ba094 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 18:25:28 -0700 Subject: [PATCH 32/52] Remove some cruft --- plugin/vimblog.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 1014d1b..59f219f 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -72,12 +72,13 @@ endfunction " Interface: ruby " Maintainer: pedro mg " Version: 1.2 -" Last Change: 2008 Jun 14 -" Remark: script function for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back -" Remark: for version upgrade ;) -" Remark: V1.2 - commands added: -" Remark: - Blog link ADDRESS,TITLE,STRING +" Last Change: 2012 Apr 08 + +" Inhibit loading of the script per usr_41 of Vim manual +if exists("g:loaded_vimblog") + finish +endif +let g:loaded_vimblog = 1 :command! -nargs=* -complete=file Blog call Wordpress_vim() @@ -268,7 +269,6 @@ ruby < Date: Sun, 8 Apr 2012 18:26:37 -0700 Subject: [PATCH 33/52] Implements highlighting options from config dict --- plugin/vimblog.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 59f219f..6c60d27 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -260,6 +260,12 @@ ruby <") + VIM::command(%q`setlocal ft=#{get_filetype}`) + end + + def get_filetype + addtl = VIM::evaluate("g:vimblogConfig['additional_ft']") + 'vimblog' + (addtl.length > 0 ? '.' + addtl : '') end ####### @@ -369,7 +375,8 @@ ruby < p :call WordpressViewWithChromeOnMac()") + VIM::command("nnoremap p :call s:WordpressViewWithChromeOnMac()") + VIM::command(%Q`setlocal ft=#{get_filetype}`) end ####### From b4998c802bf1e51d6b5024f824eb3d84fc4804cc Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:28:06 -0700 Subject: [PATCH 34/52] Rescoped functions --- plugin/vimblog.vim | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 6c60d27..1dada7e 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -3,8 +3,9 @@ " Auxiliary Ruby commands{{{ 2 + "{{{3 -function! BlogHelp() +function! s:BlogHelp() echo "Usage is :Blog option [arg]" echo " switches:" echo " - rp [x] => show recent [x] posts" @@ -19,7 +20,7 @@ function! BlogHelp() endfunction "}}}3 -function! CloseQuickfixAndOpenaPost(id) " {{{3 +function! s:CloseQuickfixAndOpenaPost(id) " {{{3 cclose new ruby < p :call WordpressViewWithChromeOnMac('preview-mode')") + VIM::command("nnoremap p WordpressViewWithChromeOnMac('preview-mode')") end ####### # new post. Creates a template for a new post. # def blog_np(*args) #{{{2 - @post_date = same_dt_fmt(Time.now) + @post_date = same_dt_fmt(Time.now) @post_author = @user v = VIM::Buffer.current v.append(v.count-1, "Title : ") @@ -278,9 +279,7 @@ ruby < q #{qaction}") + VIM::command("setl ft=vimblog.qf") v = VIM::Buffer.current yield v end @@ -314,18 +315,18 @@ ruby < #{enter_action}") buf.append(0, "Move your cursor to the line with the postID and hit to edit it.") - buf.append(buf.count, " ") + buf.append(buf.count, "") buf.append(buf.count, "#{num} MOST RECENT POSTS:") - buf.append(buf.count, " ") + buf.append(buf.count, "") resp.each { |r| buf.append(buf.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") buf.append(buf.count, "Title: \"#{r['post_title']}\"") - buf.append(buf.count, " ") + buf.append(buf.count, "") } end @@ -375,7 +376,7 @@ ruby < p :call s:WordpressViewWithChromeOnMac()") + VIM::command("nnoremap p :call WordpressViewWithChromeOnMac()") VIM::command(%Q`setlocal ft=#{get_filetype}`) end @@ -507,10 +508,10 @@ EOF :echo "Usage for Upload Media" :echo " :Blog um [filename]" catch /help/ - call BlogHelp() + call BlogHelp() catch /(.*)/ :echo v:exception - call BlogHelp() + call BlogHelp() endtry endfunction " }}}1 From 4101f04e9eb6f3620b2f9fe67d0f1fb63b9985d5 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:40:43 -0700 Subject: [PATCH 35/52] Adds a help function. --- plugin/vimblog.vim | 56 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 7d16a52..c39ae47 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -37,6 +37,23 @@ endfunction " }}} 1 " Auxilary Ruby commands{{{ 2 + +"{{{3 +function! BlogHelp() + echo "Usage is :Blog option [arg]" + echo " switches:" + echo " - rp [x] => show recent [x] posts" + echo " - gp id => get post with identification id" + echo " - np => create a new post" + echo " - um file => upload media asset [path to asset]" + echo " - publish => publish an edited/new post" + echo " - draft => save edited/new post as draft" + echo " - gc => get the list of categories" + echo " - del id => delete post with identification id" + echo " - help => this message" +endfunction +"}}}3 + function! CloseQuickfixAndOpenaPost(id) " {{{3 cclose new @@ -110,10 +127,14 @@ function! Wordpress_vim(start, ...) " {{{1 endif call Blog_syn_hl() " comment out if you don't wish syntax highlight activation +" }}}1 + try +" {{{1 ruby < e xmlrpc_flt_xcptn(e) rescue => ex - VIM::command("echo \"Unhandled Error: #{ex} and #{ex.backtrace}\"") + VIM::command("echo \"Unhandled Error: #{ex.to_s} and #{ex.backtrace.join('*')}\"") end end + def blog_help(args) + blog_api('help') + end + def method_missing(sym, *args) VIM.command("echo \"Vimblog fatal error: unable to resolve #{sym.to_s} with #{args}\"") end @@ -201,7 +226,7 @@ ruby < 0 ? VIM::evaluate("a:000") : '' )) EOF +" }}} 1 +" {{{ 1 catch /del/ :echo "Usage for deleting a post:" :echo " :Blog del id" @@ -492,19 +522,11 @@ EOF catch /um/ :echo "Usage for Upload Media" :echo " :Blog um [filename]" - catch // - :echo "Usage is :Blog option [arg]" - :echo " switches:" - :echo " - rp [x] => show recent [x] posts" - :echo " - gp id => get post with identification id" - :echo " - np => create a new post" - :echo " - um [f] => upload media asset [path to asset]" - :echo " - publish => publish an edited/new post" - :echo " - draft => save edited/new post as draft" - :echo " - gc => get the list of categories" - :echo " - del id => delete post with identification id" - :echo " --- syntax helpers:" - :echo " - link ADDRESS,TITLE,STRING => insert link STRING link" + catch /help/ + call BlogHelp() + catch /(.*)/ + :echo v:exception + call BlogHelp() endtry endfunction " }}}1 From 07439af3a7a7c5525aabebe2811664a0bf313138 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:40:48 -0700 Subject: [PATCH 36/52] Spelling error is fixed --- plugin/vimblog.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index c39ae47..0676655 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -167,8 +167,7 @@ ruby < Date: Sun, 8 Apr 2012 20:40:52 -0700 Subject: [PATCH 37/52] Refactors calculate_date --- plugin/vimblog.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 0676655..5005e67 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -180,6 +180,12 @@ ruby < Date: Sun, 8 Apr 2012 20:40:55 -0700 Subject: [PATCH 38/52] Fixes spelling --- plugin/vimblog.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 5005e67..d73f1b9 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -212,7 +212,8 @@ ruby < Date: Sun, 8 Apr 2012 20:40:57 -0700 Subject: [PATCH 39/52] Removes method that I think is bogus --- plugin/vimblog.vim | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index d73f1b9..02fc6f8 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -395,27 +395,13 @@ ruby < '', :string => '', :title => ''} - VIM::evaluate("a:0").to_i > 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil - v.append(v.count-1, " a:0 --> #{VIM::evaluate("a:0")} ") - v.append(v.count-1, " a:1 --> #{VIM::evaluate("a:1")} ") - v.append(v.count-1, "#{link[:string]}") - end - ####### # api calls. Allways returns an hash so that if api is changed, only this # function needs to be changed. One can use between Blogger, metaWeblog or # MovableType very easily. # def blog_api(fn_api, *args) #{{{2 + VIM::command("echo \"IN the api and operating on #{fn_api}\"") begin case fn_api From 807fb170f3f396b7316194ed14b32d0f4472dda4 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:41:00 -0700 Subject: [PATCH 40/52] Adds a nice debugging method --- plugin/vimblog.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 02fc6f8..19e8aab 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -363,6 +363,31 @@ ruby < Date: Sun, 8 Apr 2012 20:41:05 -0700 Subject: [PATCH 41/52] Remove stray debug data --- plugin/vimblog.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 19e8aab..3599b7c 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -426,7 +426,6 @@ ruby < Date: Sun, 8 Apr 2012 20:41:51 -0700 Subject: [PATCH 42/52] Allows multiple categories --- plugin/vimblog.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 3599b7c..5e9e0f2 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -445,7 +445,7 @@ ruby < resp['comment_status'], 'post_allow_pings' => resp['mt_allow_pings'], 'post_ping_status' => resp['mt_ping_status'], - 'post_categories' => resp['categories'].join(' '), + 'post_categories' => resp['categories'].join(', '), 'post_body' => body } From bb09b95694a12d3d08b428fd8ee1c9f91cf8e1f9 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:41:54 -0700 Subject: [PATCH 43/52] Update README.md --- README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index d58cef2..05d2cee 100644 --- a/README.md +++ b/README.md @@ -81,20 +81,9 @@ Typically you would add `centered` or `featured-image`. Use of this configuration dictionary allows the configuration and the code to be separated. -## Known Issues - -*Categories*: Multiple categories on initial post creation is handled -properly and multiple categories are comma-delimited. Thus you can have -a category like `Science and Technology` on a line with `Dinner` like -`Science and Technology, Dinner` and things are great. When this is -retrieved *back*, the API does not preserve the separation either as -array elements or a delimited string and thus your separation breaks. -For the time being you must re-insert those commas. Thankfully the -`:Blog cl` will help you build an accurate list. - ## Troubleshooting -### "That Didn't work" +### "That Didn't Work" 1. Check if the script is being found, by typing :B + TAB key. Upon code completion, it is ok. Remember, capital B. 1. If the error persist, check for the correct path for xmlrpc.php in @xml value. 1. Open an issue on github From c91b6140d116dcd4453a50635356735d61eb2a16 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:41:56 -0700 Subject: [PATCH 44/52] Adds vim-help documentation --- doc/vimblog.txt | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 doc/vimblog.txt diff --git a/doc/vimblog.txt b/doc/vimblog.txt new file mode 100644 index 0000000..66acb8e --- /dev/null +++ b/doc/vimblog.txt @@ -0,0 +1,75 @@ +*vimblog.vim* : Plugin for blogging from within Vim + +#=============================================================================== + *vimblog-author* +Original Author: Pedro MG +Major Upgrate: Steven G. Harms +#=============================================================================== + +CONTENTS *vimblog-contents* + +|vimblog-about| Introduction +|vimblog-configuration| Configuration +|vimblog-usage| Usage + +ABOUT VIMBLOG *vimblog-about* + +For Vi, Vim or GVim users, there is a simple way to manage your blog +posts. + +In the Vim environment you can now: + + * Create new blog posts + * Edit / posts + * List all categories + * List older posts + * Promote turn "draft" posts into "published" (and vice-versa) + * Upload media to your blog from within VIM and get a link to it + * Mac+Wordpress+Chrome: After using :Blog draft you can preview + your draft with p, \p by default. Additionally, if you + access a pre-existing post (Blog rp, then on a line with the ID + in it), thereafter \p will launch the entry in Chrome. + +In short, if you've been hanging on to Textmate for its blogging bundle, +you now have a comparable featureset in Vim thanks to Vimblog and +|GIFL|. + +It is an out-of-the-box solution that works for Wordpress, but which can +very easilly, be customized to manage Blogger, MovableType, TextPattern, +et al. Its the beauty of Open Source software. Study the code, change +it, and use it. It is very safe to use it because unlike proprietary +software, you can check for "phone\_home" procedures, etc. + +VIMBLOG CONFIGURATION *vimblog-configuration* + *g:vimblogConfig* + +You must define the configuration in your ~/.vimrc by defining a +dictionary (aka a Hash) called g:vimblogConfig. + + +g:vimblogConfig = { + 'login': '*username*', + 'passwd': '*pw*', + 'site': '*yoursite*', + 'xml_rpc_path': '/xmlrpc.php', + 'port': '80', + 'image_style': '*classes you want to add to images*' +} + + +USING VIMBLOG *vimblog-usage* + +Vimblog functions are invoked from the : prompt and the keyword +"Blog". Thus :Blog np will allow you to create a new post, :Blog rp +will fetch recent posts. :Blog help will also display this help menu. + + :blog rp [x] => show recent [x] posts" + :blog gp id => get post with identification id" + :blog np => create a new post" + :blog um file => upload media asset [path to asset]" + :blog publish => publish an edited/new post" + :blog draft => save edited/new post as draft" + :blog gc => get the list of categories" + :blog del id => delete post with identification id" + :blog help => this message" + From 705b807486c269d4d5d32642c03fb2696109bf15 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:42:00 -0700 Subject: [PATCH 45/52] Move to using a proper syntax highlight config --- README.md | 4 ++-- plugin/vimblog.vim | 41 +---------------------------------------- 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 05d2cee..1b0862d 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,13 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` **YOU MUST** define the following global in your `.vimrc`. - let g:vimblogConfig = {'login': '*username*', 'passwd': '*pw*', 'site': '*yoursite*', 'xml_rpc_path': '/xmlrpc.php', 'port': '80', 'image_style': '*classes you want to add to images*'} + let g:vimblogConfig = {'login': '*username*', 'passwd': '*pw*', 'site': '*yoursite*', 'xml_rpc_path': '/xmlrpc.php', 'port': '80', 'image_style': '*classes you want to add to images*', additional_ft': *additional filetypes that a vimblog should syntax highlight with e.g. (markdown|textile|html) - if unset, vimblog buffers will only have 'vimblog' highlighting } I put mine like so: + let g:vimblogConfig = { ... my configuration dictionary ...} if !exists('\*Wordpress\_vim') runtime vimblog.vim - let g:vimblogConfig = { ... my dictionary ...} endif `image_style` : This will provide CSS classes that are applied to the diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 5e9e0f2..1014d1b 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -1,42 +1,7 @@ " vim: set foldmethod=marker: " " For use and setup documentation, consult the Readme.md file - -" Vim syntax functions -" Language: wordpress_vim -" Maintainer: pedro mg -" Version: 1.1 -" Last Change: 2012 Mar 08 -" Remark: Simple functions for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back -" Remark: for version upgrade ;) - -" Highlighter functions{{{ 1 -function! Blog_syn_hl() " {{{2 - :syntax clear - :syntax keyword wpType Post Title Date - :syntax region wpTitle start=/"/ end=/$/ - :syntax region wpPostId start=/\[/ end=/\]/ - :highlight wpType ctermfg=Green guifg=LightGreen - :highlight wpTitle cterm=bold ctermfg=Blue guifg=Blue guibg=LightCyan gui=bold - :highlight wpPostId ctermfg=Red guifg=Red -endfunction -" }}}2 - -function! Post_syn_hl() " {{{ 2 - :syntax clear - :runtime! syntax/html.vim " content syntax is html hl, except for headers - :syntax keyword wpType Post Title Date Author Link Permalink Allow Comments Allow Pings Categs - :syntax region wpPostId start=/\[/ end=/\]/ contained - :syntax match wpFields /: .*/hs=s+2 contains=wpPostId - :highlight wpType ctermfg=Green guifg=LightGreen gui=bold - :highlight wpPostId ctermfg=Red guifg=Red - :highlight wpFields ctermfg=Blue guifg=Blue guibg=LightCyan -endfunction -" }}} 2 -" }}} 1 - -" Auxilary Ruby commands{{{ 2 +" Auxiliary Ruby commands{{{ 2 "{{{3 function! BlogHelp() @@ -126,7 +91,6 @@ function! Wordpress_vim(start, ...) " {{{1 finish endif - call Blog_syn_hl() " comment out if you don't wish syntax highlight activation " }}}1 try @@ -288,7 +252,6 @@ ruby < q #{qaction}") v = VIM::Buffer.current yield v @@ -392,7 +354,6 @@ ruby < 0 ? ((id = VIM::evaluate("a:1")) ? id : id = nil) : id = nil resp = blog_api("gp", id) v = VIM::Buffer.current From 8e5216ff12d493e9acf29622cf582d2e70c28ee2 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:42:03 -0700 Subject: [PATCH 46/52] Remove some cruft --- plugin/vimblog.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 1014d1b..59f219f 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -72,12 +72,13 @@ endfunction " Interface: ruby " Maintainer: pedro mg " Version: 1.2 -" Last Change: 2008 Jun 14 -" Remark: script function for vim blogging bundle in ruby. -" Remark: Please, if you fine tune this code, send it back -" Remark: for version upgrade ;) -" Remark: V1.2 - commands added: -" Remark: - Blog link ADDRESS,TITLE,STRING +" Last Change: 2012 Apr 08 + +" Inhibit loading of the script per usr_41 of Vim manual +if exists("g:loaded_vimblog") + finish +endif +let g:loaded_vimblog = 1 :command! -nargs=* -complete=file Blog call Wordpress_vim() @@ -268,7 +269,6 @@ ruby < Date: Sun, 8 Apr 2012 20:42:05 -0700 Subject: [PATCH 47/52] Implements highlighting options from config dict --- plugin/vimblog.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 59f219f..6c60d27 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -260,6 +260,12 @@ ruby <") + VIM::command(%q`setlocal ft=#{get_filetype}`) + end + + def get_filetype + addtl = VIM::evaluate("g:vimblogConfig['additional_ft']") + 'vimblog' + (addtl.length > 0 ? '.' + addtl : '') end ####### @@ -369,7 +375,8 @@ ruby < p :call WordpressViewWithChromeOnMac()") + VIM::command("nnoremap p :call s:WordpressViewWithChromeOnMac()") + VIM::command(%Q`setlocal ft=#{get_filetype}`) end ####### From 300c3133d2c54d31805958593b31a9527b131c06 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:42:07 -0700 Subject: [PATCH 48/52] Rescoped functions --- plugin/vimblog.vim | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 6c60d27..1dada7e 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -3,8 +3,9 @@ " Auxiliary Ruby commands{{{ 2 + "{{{3 -function! BlogHelp() +function! s:BlogHelp() echo "Usage is :Blog option [arg]" echo " switches:" echo " - rp [x] => show recent [x] posts" @@ -19,7 +20,7 @@ function! BlogHelp() endfunction "}}}3 -function! CloseQuickfixAndOpenaPost(id) " {{{3 +function! s:CloseQuickfixAndOpenaPost(id) " {{{3 cclose new ruby < p :call WordpressViewWithChromeOnMac('preview-mode')") + VIM::command("nnoremap p WordpressViewWithChromeOnMac('preview-mode')") end ####### # new post. Creates a template for a new post. # def blog_np(*args) #{{{2 - @post_date = same_dt_fmt(Time.now) + @post_date = same_dt_fmt(Time.now) @post_author = @user v = VIM::Buffer.current v.append(v.count-1, "Title : ") @@ -278,9 +279,7 @@ ruby < q #{qaction}") + VIM::command("setl ft=vimblog.qf") v = VIM::Buffer.current yield v end @@ -314,18 +315,18 @@ ruby < #{enter_action}") buf.append(0, "Move your cursor to the line with the postID and hit to edit it.") - buf.append(buf.count, " ") + buf.append(buf.count, "") buf.append(buf.count, "#{num} MOST RECENT POSTS:") - buf.append(buf.count, " ") + buf.append(buf.count, "") resp.each { |r| buf.append(buf.count, "Post : [#{r['post_id']}] Date: #{r['post_date']}") buf.append(buf.count, "Title: \"#{r['post_title']}\"") - buf.append(buf.count, " ") + buf.append(buf.count, "") } end @@ -375,7 +376,7 @@ ruby < p :call s:WordpressViewWithChromeOnMac()") + VIM::command("nnoremap p :call WordpressViewWithChromeOnMac()") VIM::command(%Q`setlocal ft=#{get_filetype}`) end @@ -507,10 +508,10 @@ EOF :echo "Usage for Upload Media" :echo " :Blog um [filename]" catch /help/ - call BlogHelp() + call BlogHelp() catch /(.*)/ :echo v:exception - call BlogHelp() + call BlogHelp() endtry endfunction " }}}1 From 4853e9d0ab90a00168418bbb840dd6d2fdc5c359 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 8 Apr 2012 20:48:52 -0700 Subject: [PATCH 49/52] Adds file detect; syntax highlight --- ftdetect/vimblog.vim | 1 + syntax/vimblog.vim | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 ftdetect/vimblog.vim create mode 100644 syntax/vimblog.vim diff --git a/ftdetect/vimblog.vim b/ftdetect/vimblog.vim new file mode 100644 index 0000000..caff9bd --- /dev/null +++ b/ftdetect/vimblog.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.blog set filetype=vimblog diff --git a/syntax/vimblog.vim b/syntax/vimblog.vim new file mode 100644 index 0000000..4273799 --- /dev/null +++ b/syntax/vimblog.vim @@ -0,0 +1,25 @@ +if exists("b:current_syntax") + finish +endif + +syntax keyword wpType Post Title Date Author Link + \ Permalink Allow Comments Allow Pings Categs + +syntax match wpFields /: .*/hs=s+2 contains=wpPostId, wpTitle + +syntax region wpTitle start=/"/ end=/$/ contained +syntax region wpPostId start=/\[/ end=/\]/ contained + +if &background ==? "dark" + highlight wpType ctermfg=Green guifg=LightGreen + \ gui=bold + highlight wpPostId ctermfg=Red guifg=Red + highlight wpFields ctermfg=Blue guifg=Blue + \ guibg=LightCyan +else + highlight wpType ctermfg=Green guifg=DarkMagenta + \ gui=bold + highlight wpPostId ctermfg=Red guifg=Red + highlight wpFields ctermfg=Blue guifg=Blue + \ guifg=DarkCyan +endif From 68095c1a249582030b4763c18e52f3e2c7346258 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 22 Apr 2012 20:07:46 -0700 Subject: [PATCH 50/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b0862d..0d93d21 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Janus](https://github.com/carlhuda/janus)) shows: `+reltime +rightleft +ruby +sc go to your Pathogen root directory and then `git clone` this repository 1. *Janus Example*: If you're using Janus then you're just a variation on the Pathogen setup. Create a `~/.janus` directory -and then add this repository as a submodule with `git add +and then add this repository as a submodule with `git submodule add $GIT_REPO_PATH vimblog`. Git will check out the plugin for you as a [git submodule](http://book.git-scm.com/5_submodules.html) 1. Your VIM runtime must be made aware of this plugin by means of the From 859da9b778d0ff23f16c1b94546558fdd892ac07 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 22 Apr 2012 20:11:43 -0700 Subject: [PATCH 51/52] Cleaned up README form vestigial bad steps. --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0d93d21..f77a296 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,9 @@ MacVim + Janus users, make sure it is in `~/.vimrc.after` runtime vimblog.vim endif -1. Change your blog login/password info on the `get_personal_data` - function in `vimblog.vim` near line 97. -1. Set the `@site` value. Do not insert `http://`. Just insert the blog - address, like in my case `blog.tquadrado.com` -1. Make sure you have xmlrpc.php file in your / blog dir. If not, - change the `@xml` variable in `vimblog.vim` to find it. -1. To verify your installation, open vim, and do `:Blog rp` to get your - recent 10 posts. +1. Update your configuration credentials as described in the next section +1. After completing configuration, you can verify your installation by opening vim, and executing `:Blog rp` to get your + recent 10 posts. If you see them, then congratulations, you're ready to go. ## Configuration From e638da176efafaa0e98727242efd8e2adb644421 Mon Sep 17 00:00:00 2001 From: "Steven G. Harms" Date: Sun, 22 Apr 2012 21:16:00 -0700 Subject: [PATCH 52/52] Provides debug function --- plugin/vimblog.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/vimblog.vim b/plugin/vimblog.vim index 1dada7e..7e3be93 100644 --- a/plugin/vimblog.vim +++ b/plugin/vimblog.vim @@ -124,6 +124,10 @@ ruby <