soywiki 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,6 +105,24 @@ or you can `export SOYWIKI_VIM=mvim` in your `~/.bash_profile` and then
105
105
  just run `soywiki`.
106
106
 
107
107
 
108
+ You can start SoyWiki from within a running Vim session. To set this up,
109
+ first install or update SoyWiki, and then run
110
+
111
+ soywiki --install-plugin
112
+
113
+ Please note that you will need to run this command after each time you update
114
+ SoyWiki to a newer version.
115
+
116
+ Assuming the plugin is installed, you can start SoyWiki from within a
117
+ running Vim session by typing the command
118
+
119
+ :Soywiki
120
+
121
+ Make sure when you do this that Vim's working directory is the root of
122
+ your wiki directory. You can change the working directory for the
123
+ current Vim window with `:lcd`. See `:help lcd` for more info.
124
+
125
+
108
126
  ## Basic usage
109
127
 
110
128
  For basic use, SoyWiki works exactly like a typical wiki.
@@ -119,8 +137,8 @@ link them together. You'll be surprised at how powerful this simple mechanism
119
137
  is for organizing your notes.
120
138
 
121
139
  In SoyWiki, a wiki page is a simple text file that has a WikiWord title
122
- on the first line and any text your want to insert below that. (You may
123
- alter the title line at the top, but it helps you see what wiki page
140
+ on the first line. Beyond that, you can append any text you want. (You
141
+ may alter the title line at the top, but it helps you see what wiki page
124
142
  you're on.) SoyWiki will create stub WikiPages for you automatically as
125
143
  you traverse WikiLinks that don't yet reference any content.
126
144
 
@@ -195,6 +213,7 @@ this. You can press `CTRL-^` to toggle between the current page and the
195
213
  last page you looked at.
196
214
 
197
215
  * `,m` opens the page list
216
+ * `,n` opens the namespace list
198
217
  * `,M` opens the inbound links page list
199
218
 
200
219
  You can view all the pages in your wiki, most recently modified first,
@@ -207,6 +226,9 @@ When you're on a wiki page and you want to see all the other wiki pages
207
226
  that link in to it, press `,M`. If there is only one page that links in,
208
227
  you'll be taken there automatically.
209
228
 
229
+ `,n` lets you select from your namespaces. Choosing one will take you to
230
+ the `HomePage` of that namespace.
231
+
210
232
  * `,o` opens the first web hyperlink under or after the cursor in the default external web browser
211
233
  * `ENTER` opens the web hyperlink under the cursor in the default external web browser
212
234
  * `,O` opens the web hyperlink under the cursor in a vertical split window
@@ -10,4 +10,8 @@ xs = Dir.glob('*/*').
10
10
  sort_by {|x| File.stat(x).mtime }.
11
11
  reverse.map {|x| x.to_page_title }
12
12
 
13
+ if ARGV.first == '-n'
14
+ xs = xs.map {|x| x.namespace}.uniq.sort
15
+ end
16
+
13
17
  puts xs.join("\n")
@@ -1,7 +1,7 @@
1
1
  require 'string_ext'
2
2
 
3
3
  module Soywiki
4
- VERSION = '0.5.8'
4
+ VERSION = '0.5.9'
5
5
  WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
6
6
  HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
7
7
 
@@ -106,6 +106,12 @@ func! s:list_pages()
106
106
  end
107
107
  endfunc
108
108
 
109
+ func! s:list_namespaces()
110
+ let s:search_for_link = ""
111
+ let pages = s:get_namespace_list()
112
+ call s:page_list_window(pages, 'select-page', "Select namespace: ")
113
+ endfunc
114
+
109
115
  func! s:trim_link(link)
110
116
  let link = matchstr(a:link, s:wiki_link_pattern)
111
117
  return link
@@ -303,7 +309,7 @@ func! s:omit_this_page(page_list)
303
309
  endif
304
310
  endfunc
305
311
 
306
- " This function both sets a script variable and returns the value.
312
+ "
307
313
  func! s:get_page_list()
308
314
  " no file current in buffer
309
315
  if len(bufname('')) == 0
@@ -318,6 +324,11 @@ func! s:get_page_list()
318
324
  return pages
319
325
  endfunction
320
326
 
327
+ func! s:get_namespace_list()
328
+ let pages = split(system(s:ls_command . " -n"), "\n")
329
+ return pages
330
+ endfunction
331
+
321
332
 
322
333
  func! s:pages_in_this_namespace(pages)
323
334
  let namespace = s:page_namespace()
@@ -385,7 +396,7 @@ function! CompletePageTitle(findstart, base)
385
396
  else
386
397
  let base = s:trimString(a:base)
387
398
  if (base == '')
388
- return s:get_page_list()
399
+ return s:matching_pages
389
400
  else
390
401
  let res = []
391
402
  if bufname('') == 'select-page'
@@ -397,7 +408,7 @@ function! CompletePageTitle(findstart, base)
397
408
  endfor
398
409
  else
399
410
  " autocomplete inline
400
- let pages = base =~ '\C^[a-z]' ? s:get_page_list() : s:pages_in_this_namespace(s:get_page_list())
411
+ let pages = base =~ '\C^[a-z]' ? s:matching_pages : s:pages_in_this_namespace(s:matching_pages)
401
412
  for m in pages
402
413
  if m =~ '^\c' . base
403
414
  call add(res, m)
@@ -416,9 +427,13 @@ function! s:select_page()
416
427
  if (page == '') " no selection
417
428
  return
418
429
  end
419
- let match = ""
430
+ " if time is just a namespace, append .HomePage to it
431
+ if page =~ '^[a-z][[:alnum:]_]\+$'
432
+ let page = page . ".HomePage"
433
+ endif
434
+
420
435
  for item in s:matching_pages
421
- if (item == page)
436
+ if (page =~ item)
422
437
  call s:load_page(page, 0)
423
438
  break
424
439
  end
@@ -581,6 +596,8 @@ endfunc
581
596
  func! s:global_mappings()
582
597
  nnoremap <leader>m :call <SID>list_pages()<CR>
583
598
  nnoremap <leader>M :call <SID>list_pages_linking_in()<CR>
599
+ nnoremap <leader>n :call <SID>list_namespaces()<CR>
600
+
584
601
  nnoremap <silent> <leader>o :call <SID>find_next_href_and_open()<cr>
585
602
  nnoremap <silent> q :close<cr>
586
603
  " for netrw vertical split
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 8
9
- version: 0.5.8
8
+ - 9
9
+ version: 0.5.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi