Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add License (MIT), prompt for password, quote curl command better

Add explicit LICENSE file for license terms.  Use an MIT type license
Change to 1.1.0 since I changed XQsetPassword to prompt instead taking
an argument.
Add XQsetDefaultPassword to set a default password not just one for the
current buffer
Prompt for password when it isn't set in vimrc
Add better quotes for curl command (it works in csh now)
  • Loading branch information...
commit 910e46ab22b0b13ee8877f5e82f0389322d549ba 1 parent 28c16d7
@coledarr authored
Showing with 68 additions and 23 deletions.
  1. +19 −0 LICENSE
  2. +13 −9 doc/xqmarklogic.txt
  3. +36 −14 ftplugin/xquery.vim
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2012 Darren Cole
+
+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 OR COPYRIGHT HOLDERS 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.
View
22 doc/xqmarklogic.txt
@@ -3,7 +3,7 @@
Author: Darren Cole http://github.com/coledarr/vim-xqmarklogic
-Integrating MarkLogic xqueries into vim, and displays the result in another
+Integrates MarkLogic XQueries into vim, and displays the result in another
window. This is a filetype plugin that is only available when in an XQuery
file.
@@ -44,7 +44,7 @@ Few ways to do this:
1. use pathogen.vim https://github.com/tpope/vim-pathogen
2. use vundle https://github.com/gmarik/vundle
3. use another plugin manager
- 4. Otherwise copy the doc/* and ftplugin/* to your cooresponding ~/.vim/
+ 4. Otherwise copy the doc/* and ftplugin/* to your corresponding ~/.vim/
directories (create them if they don't exist yet). Run :helptags
See pathogen.vim's documentation to set it up (it's easy). Then put the
@@ -54,7 +54,7 @@ Vundle has even more features (can update plugins automatically) See the
documentation from the link above.
MARKLOGIC CONFIGURATION *xqmarklogic-config-marklogic*
-You will need MarkLogic running, a MarkLogic App Server setup to run a xquery,
+You will need MarkLogic running, a MarkLogic App Server setup to run a XQuery,
curl, and this xqmarklogic file type plugin. MarkLogic provides an XML
database, and even has a free version called MarkLogic Express.
See: http://www.marklogic.com/
@@ -156,8 +156,12 @@ COMMANDS *xqmarklogic-commands*
*XQsetUser* sets the user to use for login to the string argument
-*XQsetPassword* sets the password to use for login to the string
- argument
+*XQsetPassword* prompts for the password to use in the current XQuery
+ buffer.
+
+*XQsetDefaultPassword* prompts for the default password to use in all XQuery
+ buffers if not already set
+
*XQsetURI* sets the URI to use to the string argument
*XQsetHost* sets the host to use to the string argument
@@ -178,14 +182,14 @@ COMMANDS *xqmarklogic-commands*
and display the output in a new results window.
*XQexploreDb* Display in a new results window each document in the current database, a
- database uri, the root element, and any collections it
+ database URI, the root element, and any collections it
is part of. This is very similar to the "Explore"
button in MarkLogic's Query Console.
==============================================================================
RESULTS WINDOW *xqmarklogic-results*
The results window is a |buftype| nofile, with the filetype set to xml, and
-has a few mappings for convience. These mappings are only set for the results
+has a few mappings for convenience. These mappings are only set for the results
window, and are not affected by |g:xqmarklogic_noMappings|.
q Close the results window.
@@ -212,8 +216,8 @@ Global default values can be set in you |vimrc| file.
(which is used by MarkLogic by default and
wont work)
*g:xqmarklogic_defaultUser* The default User, if not set uses 'admin'
-*g:xqmarklogic_defaultPassword* The default password to use, if not set
- you will probably have problems.
+*g:xqmarklogic_defaultPassword* The default password to use, instead of
+ prompting for it on first query of each buffer
*g:xqmarklogic_defaultScript* The default name of the xq.xqy, if not set
uses '/xq.xqy'
*g:xqmarklogic_defaultDb* The default Database to query against, if
View
50 ftplugin/xquery.vim
@@ -1,6 +1,6 @@
" xquery.vim - <Leader>B or <C-CR> run buffer against marklogic as an xquery
" Maintainer: Darren Cole <http://github.com/coledarr/vim-xqmarklogic>
-" Version: 1.0.7
+" Version: 1.1.0
" TODO: Add support for: GetLatestVimScripts: ### ### :AutoInstall: xqmarklogic
" TODO: see *glvs-plugins* might not work, but should at least try
"
@@ -27,8 +27,7 @@
" Assumes xml responses, for now tries to break up lines and re-indent For
" large responses this can be slow
"
-" TODO Prompt for password if unset
-" TODO output something more useful when curl returns an error
+" TODO output something more useful when curl return errors or status
" TODO should probably use <Plug>...
@@ -44,13 +43,11 @@ function! s:initSettings() "{{{
let g:xqmarklogic_defaultUser='admin'
endif
let b:xqmarklogic_user=g:xqmarklogic_defaultUser
- " TODO Want error if no global password set
- if !exists('g:xqmarklogic_defaultPassword')
- let g:xqmarklogic_defaultPassword=''
- let b:xqmarklogic_password=''
- unlet b:xqmarklogic_password
+ " only set b:xqmarklogic_password if there is a default password
+ " then prompt for it if needed later
+ if exists('g:xqmarklogic_defaultPassword')
+ let b:xqmarklogic_password=g:xqmarklogic_defaultPassword
endif
- let b:xqmarklogic_password=g:xqmarklogic_defaultPassword
if !exists('g:xqmarklogic_defaultURI')
let g:xqmarklogic_defaultURI='http://'
endif
@@ -127,9 +124,14 @@ function! s:setUser(user)
let b:xqmarklogic_user = a:user
endfunction
-command -buffer -nargs=1 XQsetPassword :execute s:setPort(<args>)
-function! s:setPassword(password)
- let b:xqmarklogic_password = a:password
+command -buffer XQsetPassword :execute s:setPassword()
+function! s:setPassword()
+ let b:xqmarklogic_password = inputsecret('MarkLogic ' . b:xqmarklogic_user . ' password:')
+endfunction
+
+command -buffer XQsetDefaultPassword :execute s:setDefaultPassword()
+function! s:setDefaultPassword()
+ let g:xqmarklogic_defaultPassword = inputsecret('MarkLogic ' . b:xqmarklogic_user . ' password:')
endfunction
command -buffer -nargs=1 XQsetURI :execute s:setURI(<args>)
@@ -260,7 +262,6 @@ command -buffer XQmlqueryArgs :execute s:QueryGenericMarkLogic(<args>)
function! s:QueryGenericMarkLogic(data, bufferQuery)
" setup local settings
let l:user = b:xqmarklogic_user
- let l:password = b:xqmarklogic_password
let l:uri = b:xqmarklogic_uri
let l:host = b:xqmarklogic_host
let l:port = b:xqmarklogic_port
@@ -273,6 +274,27 @@ function! s:QueryGenericMarkLogic(data, bufferQuery)
let l:showDb = b:xqmarklogic_showDb
let l:info=''
+ " prompt for password if b:xqmarklogic_password and
+ " g:xqmarklogic_defaultPassword are unset
+ let l:password = ''
+ if !exists('b:xqmarklogic_password')
+ if !exists('g:xqmarklogic_defaultPassword')
+ let l:password = inputsecret('MarkLogic ' . b:xqmarklogic_user . ' password:')
+ " since default password was unset assume we should use the same
+ " for all passwords
+ " TODO decide if this is best. Might be better not to do this,
+ " and let XQsetDefaultPassword provide a solution instead
+ "let g:xqmarklogic_defaultPassword = l:password
+ else
+ " since default exists use that password
+ let l:password = g:xqmarklogic_defaultPassword
+ endif
+ " keep password for next time
+ let b:xqmarklogic_password = l:password
+ else
+ let l:password = b:xqmarklogic_password
+ endif
+
" Could use preview window
"let s:out = tempname()
"pedit s:out
@@ -306,7 +328,7 @@ function! s:QueryGenericMarkLogic(data, bufferQuery)
let l:info .= ' db="' . l:db . '"'
endif
- let curlCmd='curl --digest --user ' . l:user . ':' . l:password . ' -s -X PUT -d"' . a:data . '" ' . l:uri . l:host . ':' . l:port . l:script . '?db='.l:db
+ let curlCmd='curl --digest --user ' . l:user . ':' . l:password . ' -s -X PUT -d"' . a:data . '" ' . "'" . l:uri . l:host . ':' . l:port . l:script . '?db='.l:db . "'"
if (l:showCurlCmd)
call append(0, '<!-- ' . curlCmd . ' -->')
Please sign in to comment.
Something went wrong with that request. Please try again.