soywiki 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/soywiki-rename +8 -8
- data/lib/soywiki.rb +1 -1
- data/lib/soywiki.vim +2 -1
- metadata +2 -2
data/bin/soywiki-rename
CHANGED
@@ -13,12 +13,12 @@ end
|
|
13
13
|
def change_all_absolute_links(oldname, newname)
|
14
14
|
MEMO << "- Updating all absolute links"
|
15
15
|
target_files = `grep -rlF '#{oldname.to_page_title}' *`.strip.split(/\n/)
|
16
|
-
target_files.each do |file|
|
16
|
+
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
17
17
|
text = File.read(file)
|
18
18
|
begin
|
19
19
|
regex = /\b#{oldname.to_page_title}\b/
|
20
20
|
matches = text.scan(regex)
|
21
|
-
text.gsub
|
21
|
+
text = text.gsub(regex, newname.to_page_title)
|
22
22
|
File.open(file, 'w') {|f| f.puts text}
|
23
23
|
report file, oldname.to_page_title, newname.to_page_title
|
24
24
|
rescue
|
@@ -30,10 +30,10 @@ end
|
|
30
30
|
def change_unqualified_inbound_links_in_same_namespace(oldname, newname)
|
31
31
|
MEMO << "- Updating unqualified inbound links"
|
32
32
|
target_files = `grep -rlF '[^.]#{oldname.short_page_title}' #{oldname.namespace}/*`.strip.split(/\n/)
|
33
|
-
target_files.each do |file|
|
33
|
+
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
34
34
|
text = File.read(file)
|
35
35
|
begin
|
36
|
-
text.gsub
|
36
|
+
text = text.gsub(/(\A|\s)#{oldname.short_page_title}\b/, "." + newname)
|
37
37
|
File.open(file, 'w') {|f| f.puts text}
|
38
38
|
report file, oldname.short_page_title, newname
|
39
39
|
rescue
|
@@ -42,7 +42,7 @@ def change_unqualified_inbound_links_in_same_namespace(oldname, newname)
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
RELATIVE_LINK_REGEX =/(\A
|
45
|
+
RELATIVE_LINK_REGEX =/(\A|\s)([A-Z][a-z]+[A-Z]\w*)/
|
46
46
|
|
47
47
|
def absolutize_unqualified_outbound_links(oldname, newname)
|
48
48
|
MEMO << "Absolutizing unqualified inbound links"
|
@@ -51,7 +51,7 @@ def absolutize_unqualified_outbound_links(oldname, newname)
|
|
51
51
|
text = File.read(target_file)
|
52
52
|
begin
|
53
53
|
matches = text.scan(RELATIVE_LINK_REGEX)
|
54
|
-
text.gsub
|
54
|
+
text = text.gsub(RELATIVE_LINK_REGEX, oldname.namespace + '.\1')
|
55
55
|
File.open(target_file, 'w') {|f| f.puts text}
|
56
56
|
MEMO << " - In file #{target_file}: Absolutized these unqualified links: #{matches.inspect}"
|
57
57
|
rescue
|
@@ -71,10 +71,10 @@ end
|
|
71
71
|
if oldname.namespace == newname.namespace
|
72
72
|
MEMO << "- Updating unqualified links in same namespace"
|
73
73
|
target_files = `grep -rlF '#{oldname.short_page_title}' #{oldname.namespace}/*`.strip.split(/\n/)
|
74
|
-
target_files.each do |file|
|
74
|
+
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
75
75
|
text = File.read(file)
|
76
76
|
begin
|
77
|
-
text.gsub
|
77
|
+
text = text.gsub(/(\A|\s)(#{oldname.short_page_title})\b/, newname.short_page_title)
|
78
78
|
File.open(file, 'w') {|f| f.puts text}
|
79
79
|
report file, oldname.short_page_title, newname.short_page_title
|
80
80
|
rescue
|
data/lib/soywiki.rb
CHANGED
data/lib/soywiki.vim
CHANGED
@@ -239,8 +239,9 @@ func! s:rename_page(page_path_or_title)
|
|
239
239
|
write!
|
240
240
|
let original_file = bufname('')
|
241
241
|
echo system("git mv " . original_file . " " . newfile)
|
242
|
+
call system("git commit -am 'rename wiki page'")
|
242
243
|
exec "!" . s:rename_links_command . original_file . " " . newfile
|
243
|
-
call system("git commit -am 'rename wiki
|
244
|
+
call system("git commit -am 'rename wiki links'")
|
244
245
|
exec "e " . newfile
|
245
246
|
else
|
246
247
|
call s:display_invalid_wiki_word_error(page_title)
|