Skip to content

Commit

Permalink
Move version variable to autoload script, include in every message
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Sep 4, 2011
1 parent dd866d6 commit f0d2b02
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -45,4 +45,4 @@ If you have questions, bug reports, suggestions, etc. the author can be contacte
## License

This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
© 2010 Peter Odding &lt;<peter@peterodding.com>&gt;.
© 2011 Peter Odding &lt;<peter@peterodding.com>&gt;.
30 changes: 16 additions & 14 deletions autoload/xolox/publish.vim
@@ -1,8 +1,10 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: May 26, 2011
" Last Change: September 4, 2011
" URL: http://peterodding.com/code/vim/publish/

let g:xolox#publish#version = '1.7.3'

function! xolox#publish#resolve_files(directory, pathnames) " {{{1
" Create a dictionary that maps the fully resolved pathnames of the files to
" be published to the absolute pathnames provided by the user. This enables
Expand Down Expand Up @@ -47,21 +49,21 @@ function! xolox#publish#find_tags(files_to_publish) " {{{1
let tag_name = string(entry.name)
let this_path = string(entry.filename)
let other_path = string(other.filename)
let msg = "publish.vim: Ignoring duplicate tag %s! (duplicate is in %s, first was in %s)"
call xolox#misc#msg#warn(msg, tag_name, this_path, other_path)
let msg = "publish.vim %s: Ignoring duplicate tag %s! (duplicate is in %s, first was in %s)"
call xolox#misc#msg#warn(msg, g:xolox#publish#version, tag_name, this_path, other_path)
endif
endif
endif
endfor
if num_duplicates > 3
let more = num_duplicates - 3
let msg = "publish.vim: Ignored %s more duplicate tag%s!"
call xolox#misc#msg#warn(msg, more, more == 1 ? '' : 's')
let msg = "publish.vim: %s Ignored %s more duplicate tag%s!"
call xolox#misc#msg#warn(msg, g:xolox#publish#version, more, more == 1 ? '' : 's')
endif
unlet s:cached_contents
let msg = "publish.vim: Found %i tag%s to publish in %s."
let msg = "publish.vim %s: Found %i tag%s to publish in %s."
let numtags = len(tags_to_publish)
call xolox#misc#timer#stop(msg, numtags, numtags != 1 ? 's' : '', start)
call xolox#misc#timer#stop(msg, g:xolox#publish#version, numtags, numtags != 1 ? 's' : '', start)
return tags_to_publish
endfunction

Expand Down Expand Up @@ -147,17 +149,17 @@ function! xolox#publish#rsync_check(target) " {{{1
endif
endif
endif
call xolox#misc#timer#stop("publish.vim: Checked rsync support in %s.", start)
call xolox#misc#timer#stop("publish.vim %s: Checked rsync support in %s.", g:xolox#publish#version, start)
return result
endfunction

function! xolox#publish#run_rsync(target, tempdir) " {{{1
let start = xolox#misc#timer#start()
let target = fnameescape(a:target . '/')
let tempdir = fnameescape(a:tempdir . '/')
call xolox#misc#msg#info("publish.vim: Uploading files to %s using rsync.", a:target)
call xolox#misc#msg#info("publish.vim %s: Uploading files to %s using rsync.", g:xolox#publish#version, a:target)
execute '!rsync -vr' tempdir target
call xolox#misc#timer#stop("publish.vim: Finished uploading in %s.", start)
call xolox#misc#timer#stop("publish.vim %s: Finished uploading in %s.", g:xolox#publish#version, start)
if v:shell_error
throw "publish.vim: Failed to run rsync!"
endif
Expand All @@ -174,12 +176,12 @@ function! xolox#publish#create_dirs(target_path) " {{{1
if !isdirectory(current_directory)
let msg = "Failed to create directory %s! What now?"
if confirm(printf(msg, string(current_directory)), "&Abort\n&Ignore") == 1
let msg = "publish.vim: Failed to create %s, aborting .."
call xolox#misc#msg#warn(msg, string(current_directory))
let msg = "publish.vim %s: Failed to create %s, aborting .."
call xolox#misc#msg#warn(msg, g:xolox#publish#version, string(current_directory))
return 0
else
let msg = "publish.vim: Failed to create %s, ignoring .."
call xolox#misc#msg#warn(msg, string(current_directory))
let msg = "publish.vim %s: Failed to create %s, ignoring .."
call xolox#misc#msg#warn(msg, g:xolox#publish#version, string(current_directory))
continue
endif
endif
Expand Down
12 changes: 6 additions & 6 deletions doc/publish.txt
Expand Up @@ -14,7 +14,7 @@ in Vim scripting so I decided to clean up my code and release it. If you're
wondering what the result looks like, I've published the plug-in source code
[2] as a demonstration.

==============================================================================
===============================================================================
*publish-installation-usage*
Installation & usage ~

Expand Down Expand Up @@ -53,7 +53,7 @@ the script as '~/publish_test.vim' and try it in Vim by executing the command
moment and after that you will find a bunch of syntax highlighted, interlinked
HTML documents in the 'target' directory!

==============================================================================
===============================================================================
Publishing to a remote location (website) ~

As you can see from the example above it's possible to publish files directly
Expand All @@ -73,7 +73,7 @@ automatically use rsync [6] when both the local and remote system have it
installed. This cuts the time to publish to a remote location in half and
enables the plug-in to automatically create directories on the remote side.

==============================================================================
===============================================================================
*publish-contact*
Contact ~

Expand All @@ -82,14 +82,14 @@ contacted at peter@peterodding.com. The latest version is available at
http://peterodding.com/code/vim/publish/ and http://github.com/xolox/vim-publish.
If you like the script please vote for it on Vim Online [7].

==============================================================================
===============================================================================
*publish-license*
License ~

This software is licensed under the MIT license [8]. Copyright 2010 Peter
This software is licensed under the MIT license [8]. Copyright 2011 Peter
Odding <peter@peterodding.com>.

==============================================================================
===============================================================================
*publish-references*
References ~

Expand Down
24 changes: 11 additions & 13 deletions plugin/publish.vim
@@ -1,14 +1,12 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: May 26, 2011
" Last Change: September 4, 2011
" URL: http://peterodding.com/code/vim/publish/
" License: MIT
" Version: 1.7.2

" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 2252 1 :AutoInstall: publish.zip

" Don't source the plug-in when its already been loaded or &compatible is set.
" Don't source the plug-in when it's already been loaded or &compatible is set.
if &cp || exists('g:loaded_publish')
finish
endif
Expand All @@ -23,7 +21,7 @@ endif

function! Publish(source, target, files) abort
let start = xolox#misc#timer#start()
call xolox#misc#msg#info("Preparing to publish file%s ..", len(a:files) == 1 ? '' : 's')
call xolox#misc#msg#info("publish.vim %s: Preparing to publish file%s ..", g:xolox#publish#version, len(a:files) == 1 ? '' : 's')
let s:files_to_publish = xolox#publish#resolve_files(a:source, a:files)
call xolox#publish#update_tags(values(s:files_to_publish))
let s:tags_to_publish = xolox#publish#find_tags(s:files_to_publish)
Expand All @@ -40,7 +38,7 @@ function! Publish(source, target, files) abort
let source_path = xolox#misc#path#merge(a:source, pathname)
let suffix = g:publish_omit_dothtml ? '' : '.html'
let target_path = xolox#misc#path#merge(target_dir, pathname . suffix)
call xolox#misc#msg#info("Publishing %s", string(pathname))
call xolox#misc#msg#info("publish.vim %s: Publishing %s", g:xolox#publish#version, string(pathname))
if !xolox#publish#create_dirs(target_path)
return
endif
Expand All @@ -60,13 +58,13 @@ function! Publish(source, target, files) abort
let highlight_start = xolox#misc#timer#start()
call xolox#publish#munge_syntax_items()
runtime syntax/2html.vim
let msg = "publish.vim: The 2html.vim script took %s to highlight %s."
call xolox#misc#timer#stop(msg, highlight_start, pathname)
let msg = "publish.vim %s: The 2html.vim script took %s to highlight %s."
call xolox#misc#timer#stop(msg, g:xolox#publish#version, highlight_start, pathname)
if exists('tags_to_links_command')
let tags_to_links_start = xolox#misc#timer#start()
silent execute tags_to_links_command
let msg = "publish.vim: Finished converting tags in %s to links in %s."
call xolox#misc#timer#stop(msg, pathname, tags_to_links_start)
let msg = "publish.vim %s: Finished converting tags in %s to links in %s."
call xolox#misc#timer#stop(msg, g:xolox#publish#version, pathname, tags_to_links_start)
endif
call xolox#publish#customize_html(pathname)
silent execute 'write!' fnameescape(target_path)
Expand All @@ -76,9 +74,9 @@ function! Publish(source, target, files) abort
if rsync_target != ''
call xolox#publish#run_rsync(rsync_target, rsync_dir)
endif
let msg = "publish.vim: Published %i file%s to %s."
call xolox#misc#msg#info(msg, len(a:files), len(a:files) == 1 ? '' : 's', a:target)
call xolox#misc#timer#stop("Finished publishing files in %s.", start)
let msg = "publish.vim %s: Published %i file%s to %s."
call xolox#misc#msg#info(msg, g:xolox#publish#version, len(a:files), len(a:files) == 1 ? '' : 's', a:target)
call xolox#misc#timer#stop("publish.vim %s: Finished publishing files in %s.", g:xolox#publish#version, start)
call xolox#publish#prep_env(0)
endfunction

Expand Down

0 comments on commit f0d2b02

Please sign in to comment.