Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add options and toggles for showing duration and curl cmd

Option and toggle for showing duration for query, defaults to show
duration
Option and Toggle for showing curl cmd used for query, defaults to off
because the output has a "--" in it that technically isn't allowed in
xml
Minor other changes
  • Loading branch information...
commit 85b11907c8c8914e8168f2150c67eb5fb8e329e4 1 parent 414c50b
@coledarr authored committed
Showing with 41 additions and 6 deletions.
  1. +41 −6 plugin/vim-xqmarklogic.vim
View
47 plugin/vim-xqmarklogic.vim
@@ -22,19 +22,45 @@
" would be to fix the xquery output) For large responses this can be slow
"
" TODO The user and password are encoded in this file, and should be changed
-" (prompt for password and cache for later calls)
+" (prompt for password and cache for later calls) Or at least allow setting
+" the values
" TODO Consider a different script instead of xq.xqy. Use XCC, RestFUL
" interface (MarkLogic6 and later), or even just package up the xq.xqy
" TODO xq.xqy hardcodes database, but it would be better to be configurable
" (db http header can be set to override hardcoded default). Best would be
" configured on a per buffer basis and maybe a default set in .vimrc
+" TODO add a real help doc
"
" Maintainer: Darren Cole <http://github.com/coledarr/vim-xqmarklogic>
-" Version: 0.1
+" Version: 0.3
-map <Leader>B :XQ<cr>
-command -buffer XQ :execute s:QueryMarkLogic(expand("%"))
+" Options
+let s:curlCmd=0
+let s:showDuration=1
+
+" Toggle Options
+command -buffer XQtoggleCurlCmdAppend :execute s:toggleCurlCmdAppend()
+function! s:toggleCurlCmdAppend()
+ if (s:curlCmd)
+ let s:curlCmd=0
+ else
+ let s:curlCmd=1
+ endif
+endfunction
+command -buffer XQToggleShowDuration :execute s:toggleShowDuration()
+function! s:toggleShowDuration()
+ if (s:showDuration)
+ let s:showDuration=0
+ else
+ let s:showDuration=1
+ endif
+endfunction
+
+" Running the Query
+map <Leader>B :XQmlquery<cr>
+
+command -buffer XQmlquery :execute s:QueryMarkLogic(expand("%"))
let s:host = "localhost"
let s:uri = "http://"
@@ -44,8 +70,7 @@ let s:password = "password"
let s:xq = "/xq.xqy"
" Used for preview window
-let s:out = tempname()
-
+"let s:out = tempname()
function! s:QueryMarkLogic(fname)
" Use preview window
"pedit s:out
@@ -56,8 +81,18 @@ function! s:QueryMarkLogic(fname)
setlocal buftype=nofile
setlocal filetype=xml
+ if (s:curlCmd)
+ call append(0, '<!-- curl --digest --user ' . s:user . ':XXXXXX -s -X PUT -d@"' . a:fname . '" ' . s:uri . s:host . ':' . s:port . s:xq . ' -->')
+ endif
+
+ let start=reltime()
execute 'r! curl --digest --user ' . s:user . ':' . s:password . ' -s -X PUT -d@"' . a:fname . '" ' . s:uri . s:host . ':' . s:port . s:xq
"execut 'r! curl --digest --user admin:password -s -X PUT -d@"' . a:fname . '" http://localhost:8002/xq.xqy'
+ if (s:showDuration)
+ let end=reltimestr(reltime(start))
+ call append(0, '<!-- query_duration="' . end .'" -->')
+ endif
+
silent! :%s/></>
</g
Please sign in to comment.
Something went wrong with that request. Please try again.