Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 25, 2012
Steven G. Harms Moves configuration to a global dict 55acc17
Steven G. Harms Adds "view post" support for completed entries 7685215
Steven G. Harms Updates README c38cf50
Showing with 40 additions and 20 deletions.
  1. +13 −7 README.md
  2. +27 −13 plugin/vimblog.vim
View
20 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 `<Leader>p`, `\\p` by default
+ your draft with `<Leader>p`, `\\p` by default. Additionally, if you
+ access a pre-existing post (`Blog rp`, then `<CR>` 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 `<img>` 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
+`<img>` 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
View
40 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
@@ -99,6 +104,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 <<EOF
@@ -135,13 +145,15 @@ ruby <<EOF
# class variables for personnal data. Please *change* them accordingly.
# CHANGE HERE:
def get_personal_data
- @login = "" # insert your login here
- @passwd = "" # insert your password here
- @site = "" # insert your blog url here, but do not use http://
- @xml = "/xmlrpc.php" # change if necessary
- @port = 80 # change if necessary
+ config = VIM::evaluate("g:vimblogConfig")
+ VIM::command("echo \"Your g:vimblogConfig configuration was not set. Check out the vimblog README.md\"") unless config
+ @login = config["login"]
+ @passwd = config["passwd"]
+ @site = config["site"]
+ @xml = config["xml_rpc_path"]
+ @port = config["port"]
@blog_id = 0
- @user = 1
+ @user = 1
end
@@ -213,8 +225,9 @@ ruby <<EOF
end
result = blog_api("um", data)
- gas = VIM::evaluate("g:vimblogImageStyle")
- VIM::command("echo \"Your g:vimblogImageStyle configuration was not set. Check out the vimblog README.md\"") unless gas
+ config = VIM::evaluate("g:vimblogConfig")
+ gas = config['image_style']
+ VIM::command("echo \"Your g:vimblogConfig['image_style'] configuration was not set. Check out the vimblog README.md\"") unless gas
gas = (gas.nil? ? '' : 'class="' + gas + '"')
url = "<a target=\"_new\" href=\"#{result['url']}\"><img #{gas} src=\"#{result['url']}\" alt=\"#\"></a>"
@@ -235,7 +248,7 @@ ruby <<EOF
VIM::command("enew!")
VIM::command("Blog gp #{resp['post_id']}")
end
- VIM::command("nnoremap <buffer> <Leader>p :call WordpressPreviewWithChromeOnMac()<cr>")
+ VIM::command("nnoremap <buffer> <Leader>p :call WordpressViewWithChromeOnMac('preview-mode')<cr>")
end
#######
@@ -339,6 +352,7 @@ ruby <<EOF
v.append(v.count-1, " ")
v.append(v.count-1, " ")
resp['post_body'].each_line { |l| v.append(v.count-1, l.strip)}
+ VIM::command("nnoremap <buffer> <Leader>p :call WordpressViewWithChromeOnMac()<cr>")
end
#######

No commit comments for this range

Something went wrong with that request. Please try again.