soywiki 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/soywiki.rb +2 -21
- data/lib/soywiki.vim +10 -6
- data/lib/string_ext.rb +20 -0
- metadata +3 -2
data/lib/soywiki.rb
CHANGED
@@ -1,26 +1,7 @@
|
|
1
|
-
|
2
|
-
class String
|
3
|
-
# not Windows compatible
|
4
|
-
def to_file_path
|
5
|
-
self.gsub(".", "/")
|
6
|
-
end
|
7
|
-
|
8
|
-
def to_page_title
|
9
|
-
self.gsub("/", ".")
|
10
|
-
end
|
11
|
-
|
12
|
-
def short_page_title
|
13
|
-
self.to_page_title.split('.')[1]
|
14
|
-
end
|
15
|
-
|
16
|
-
def namespace
|
17
|
-
self.to_page_title.split('.')[0]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
1
|
+
require 'string_ext'
|
21
2
|
|
22
3
|
module Soywiki
|
23
|
-
VERSION = '0.1.
|
4
|
+
VERSION = '0.1.5'
|
24
5
|
WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
|
25
6
|
|
26
7
|
def self.run
|
data/lib/soywiki.vim
CHANGED
@@ -91,7 +91,7 @@ endfunc
|
|
91
91
|
|
92
92
|
func! s:list_pages()
|
93
93
|
let s:search_for_link = ""
|
94
|
-
call s:page_list_window(s:get_page_list(), "Select page: ")
|
94
|
+
call s:page_list_window(s:get_page_list(), 'select-page', "Select page: ")
|
95
95
|
endfunc
|
96
96
|
|
97
97
|
func! s:trim_link(link)
|
@@ -257,6 +257,9 @@ func! s:get_page_list()
|
|
257
257
|
" no file current in buffer
|
258
258
|
if len(bufname('%')) == 0
|
259
259
|
return split(system(s:ls_command), "\n")
|
260
|
+
elseif bufname('') == 'pages-linking-in'
|
261
|
+
" this needs refactoring to rely less on state
|
262
|
+
return s:pages_linking_in
|
260
263
|
else
|
261
264
|
return split(system(s:ls_command . " | grep -vF '" . s:page_title() . "'" ), "\n")
|
262
265
|
endif
|
@@ -291,11 +294,11 @@ func! s:reduce_matches()
|
|
291
294
|
endif
|
292
295
|
endfunc
|
293
296
|
|
294
|
-
function! s:page_list_window(page_match_list, prompt)
|
297
|
+
function! s:page_list_window(page_match_list, buffer_name, prompt)
|
295
298
|
" remember the original window
|
296
299
|
let s:return_to_winnr = winnr()
|
297
300
|
let s:matching_pages = a:page_match_list
|
298
|
-
topleft split
|
301
|
+
exec "topleft split ".a:buffer_name
|
299
302
|
setlocal completefunc=CompletePageTitle
|
300
303
|
setlocal buftype=nofile
|
301
304
|
setlocal noswapfile
|
@@ -327,7 +330,7 @@ function! CompletePageTitle(findstart, base)
|
|
327
330
|
return s:get_page_list()
|
328
331
|
else
|
329
332
|
let res = []
|
330
|
-
if bufname('') == 'page
|
333
|
+
if bufname('') == 'select-page'
|
331
334
|
let pages = s:get_page_list()
|
332
335
|
for m in pages
|
333
336
|
if m =~ '\c' . base
|
@@ -348,6 +351,7 @@ function! CompletePageTitle(findstart, base)
|
|
348
351
|
endif
|
349
352
|
endfun
|
350
353
|
|
354
|
+
|
351
355
|
function! s:select_page()
|
352
356
|
let page = s:trimString( get(split(getline(line('.')), ": "), 1) )
|
353
357
|
close
|
@@ -371,7 +375,7 @@ endfunction
|
|
371
375
|
" in different namespaces
|
372
376
|
|
373
377
|
func! s:list_pages_linking_in()
|
374
|
-
let s:pages_linking_in
|
378
|
+
let s:pages_linking_in = split(system(s:find_pages_linking_in_command . s:page_title()), "\n")
|
375
379
|
" cursor should jump to this string after the selected page is loaded:
|
376
380
|
let s:search_for_link = s:title_without_namespace(s:page_title())
|
377
381
|
if len(s:pages_linking_in) == 1
|
@@ -379,7 +383,7 @@ func! s:list_pages_linking_in()
|
|
379
383
|
elseif len(s:pages_linking_in) == 0
|
380
384
|
echom "No pages link to " . s:page_title() . "!"
|
381
385
|
else
|
382
|
-
call s:page_list_window(s:pages_linking_in, "Pages that link to " . s:page_title() . ": ")
|
386
|
+
call s:page_list_window(s:pages_linking_in, "pages-linking-in", "Pages that link to " . s:page_title() . ": ")
|
383
387
|
endif
|
384
388
|
endfunc
|
385
389
|
|
data/lib/string_ext.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class String
|
2
|
+
# not Windows compatible
|
3
|
+
def to_file_path
|
4
|
+
self.gsub(".", "/")
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_page_title
|
8
|
+
self.gsub("/", ".")
|
9
|
+
end
|
10
|
+
|
11
|
+
def short_page_title
|
12
|
+
self.to_page_title.split('.')[1]
|
13
|
+
end
|
14
|
+
|
15
|
+
def namespace
|
16
|
+
self.to_page_title.split('.')[0]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Choi
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- bin/soywiki-rename
|
58
58
|
- lib/soywiki.rb
|
59
59
|
- lib/soywiki.vim
|
60
|
+
- lib/string_ext.rb
|
60
61
|
- soywiki.gemspec
|
61
62
|
- website/.gitignore
|
62
63
|
- website/bottom.markdown
|