soywiki 0.9.8 → 0.9.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/README.markdown +13 -5
- data/bin/soywiki-expand +4 -61
- data/bin/soywiki-rename +5 -117
- data/lib/path_helper.rb +24 -0
- data/lib/soywiki.rb +2 -1
- data/lib/soywiki.vim +2 -2
- data/lib/soywiki/expander.rb +86 -0
- data/lib/soywiki/renamer.rb +153 -0
- metadata +17 -19
- checksums.yaml +0 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -46,8 +46,7 @@ SoyWiki is free and open source.
|
|
46
46
|
## Prerequisites
|
47
47
|
|
48
48
|
* a recent version of Vim (SoyWiki is developed against Vim 7.2 and 7.3)
|
49
|
-
* a recent version of Ruby: Ruby 1.9.2
|
50
|
-
* RubyGems (if Ruby version is older than 1.9)
|
49
|
+
* a recent version of Ruby: at least Ruby 1.9.3, but we recommend 2.0.0 or above
|
51
50
|
* a recent version of [Git][git] (1.7.0.4 or above to be safe)
|
52
51
|
|
53
52
|
[git]:http://git-scm.com/
|
@@ -56,9 +55,11 @@ The current version of SoyWiki assumes a Unix environment.
|
|
56
55
|
|
57
56
|
To use SoyWiki you should be fairly good at using Vim.
|
58
57
|
|
59
|
-
To install Ruby
|
58
|
+
To install Ruby we recommend using the a ruby version manager,
|
59
|
+
like [RVM Version Manager][rvm] or [rbenv][rbenv].
|
60
60
|
|
61
61
|
[rvm]:http://rvm.beginrescueend.com
|
62
|
+
[rbenv]: https://github.com/sstephenson/rbenv
|
62
63
|
|
63
64
|
Most of SoyWiki's commands should work even if you don't have Git
|
64
65
|
installed. But the revision history commands will not.
|
@@ -70,7 +71,7 @@ installed. But the revision history commands will not.
|
|
70
71
|
Test your installation by typing `soywiki -h`. You should see SoyWiki's help.
|
71
72
|
|
72
73
|
If you run into any PATH errors, try the following: Install the RVM
|
73
|
-
Version Manager, then install
|
74
|
+
Version Manager, then install a recent version of ruby through RVM, and run `gem
|
74
75
|
install soywiki`. This should solve any installation issues.
|
75
76
|
|
76
77
|
If you ever want to uninstall SoyWiki from your system, execute this command:
|
@@ -520,9 +521,16 @@ You can also join the [Google Group][group] and comment there.
|
|
520
521
|
|
521
522
|
The original version of Soywiki was created by Daniel Choi (email: dhchoi at gmail.com).
|
522
523
|
|
523
|
-
Soywiki is now being maintained and extended by Tim
|
524
|
+
Soywiki is now being maintained and extended by Tim Reddehase (github: [@0robustus1][tim]).
|
524
525
|
|
525
526
|
[tim]:https://github.com/0robustus1
|
526
527
|
|
528
|
+
## Roadmap
|
529
|
+
|
530
|
+
There are some more git-related features (e.g. push from inside vim)
|
531
|
+
we would like to implement before releasing 1.0.
|
532
|
+
However with the 1.0 release we will no longer support
|
533
|
+
ruby versions below `2.0.0`.
|
534
|
+
|
527
535
|
|
528
536
|
|
data/bin/soywiki-expand
CHANGED
@@ -1,64 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'soywiki'
|
3
|
+
require 'expander'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# first letter
|
8
|
-
|
9
|
-
WIKI_LINK_PATTERN = /^\s*([a-z0-9]\w+\.)?[A-Z][a-z]+[A-Z0-9]\w*\s*$/
|
10
|
-
|
11
|
-
PROCESSED_FILES = []
|
12
|
-
|
13
|
-
def indent(text, level, mode)
|
14
|
-
return text if mode == 'seamless'
|
15
|
-
return text if level == 0
|
16
|
-
('|' * level) + ' ' + text
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def divider
|
21
|
-
puts '+' + '-' * 78 + '+'
|
22
|
-
end
|
23
|
-
|
24
|
-
def expand(file, mode, level=0)
|
25
|
-
PROCESSED_FILES << file
|
26
|
-
lines = File.readlines(file)
|
27
|
-
if mode == 'seamless'
|
28
|
-
lines.shift # strips title
|
29
|
-
end
|
30
|
-
lines = lines.join.strip.split("\n")
|
31
|
-
lines.each do |line|
|
32
|
-
# note that the wiki link must be alone on the line to be expanded
|
33
|
-
if line =~ WIKI_LINK_PATTERN
|
34
|
-
link = line.strip
|
35
|
-
if link =~ /(\A|\s)[A-Z]/ # short link in namespace (relative link)
|
36
|
-
namespace = file.namespace
|
37
|
-
link = [namespace, link].join('.')
|
38
|
-
end
|
39
|
-
if File.file?(link.to_file_path) && !PROCESSED_FILES.include?(link.to_file_path)
|
40
|
-
if mode == 'seamful'
|
41
|
-
divider
|
42
|
-
end
|
43
|
-
expand(link.to_file_path, mode, level + 1) # recursive call
|
44
|
-
if mode == 'seamful'
|
45
|
-
divider
|
46
|
-
end
|
47
|
-
elsif PROCESSED_FILES.include?(link)
|
48
|
-
puts indent("#{link} [[already expanded]]", level, mode)
|
49
|
-
elsif !File.file?(link.to_file_path)
|
50
|
-
puts indent("#{link} [[no file found]]", level, mode)
|
51
|
-
else
|
52
|
-
puts indent("#{link}", level, mode)
|
53
|
-
end
|
54
|
-
else
|
55
|
-
puts indent(line, level, mode)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
mode, file = *ARGV
|
61
|
-
|
62
|
-
expand(file, mode)
|
63
|
-
|
64
|
-
|
5
|
+
repo_path, mode, file = *ARGV
|
6
|
+
expander = Soywiki::Expander.new(repo_path, mode, file)
|
7
|
+
puts expander.expand
|
data/bin/soywiki-rename
CHANGED
@@ -1,123 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
3
|
require 'soywiki'
|
4
|
-
require '
|
4
|
+
require 'renamer'
|
5
5
|
|
6
|
-
repo_path,
|
6
|
+
repo_path, old_name, new_name = *ARGV
|
7
7
|
repo_path = Pathname.new(repo_path)
|
8
|
+
renamer = Soywiki::Renamer.new(repo_path, old_name, new_name)
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
define_method :portion do |full_path|
|
12
|
-
full_path = Pathname.new(full_path) if full_path.is_a?(String)
|
13
|
-
full_path.relative_path_from(repo_path).to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method :full do |path|
|
17
|
-
path = Pathname.new(path) if path.is_a?(String)
|
18
|
-
return path.to_s if path.absolute?
|
19
|
-
repo_path.join(path).to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def report(file, oldname, newname)
|
23
|
-
MEMO << " - In #{file}: #{oldname.to_page_title} -> #{newname.to_page_title}"
|
24
|
-
end
|
25
|
-
|
26
|
-
def change_all_absolute_links(oldname, newname)
|
27
|
-
MEMO << "- Updating all absolute links"
|
28
|
-
target_files = `grep -rlF '#{portion(oldname).to_page_title}' #{full('')}`.strip.split(/\n/)
|
29
|
-
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
30
|
-
text = File.read(file)
|
31
|
-
begin
|
32
|
-
regex = /\b#{portion(oldname).to_page_title}\b/
|
33
|
-
matches = text.scan(regex)
|
34
|
-
text = text.gsub(regex, portion(newname).to_page_title)
|
35
|
-
File.open(file, 'w') {|f| f.puts text}
|
36
|
-
report file, portion(oldname).to_page_title, portion(newname).to_page_title
|
37
|
-
rescue
|
38
|
-
puts "Error processing #{file}: #$!"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def change_unqualified_inbound_links_in_same_namespace(oldname, newname)
|
44
|
-
MEMO << "- Updating unqualified inbound links"
|
45
|
-
target_files = `grep -rlF '#{portion(oldname).short_page_title}' #{full(portion(oldname).namespace)}`.strip.split(/\n/)
|
46
|
-
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
47
|
-
text = File.read(file)
|
48
|
-
begin
|
49
|
-
text = text.gsub(/(\A|\s)(#{portion(oldname).short_page_title}\b)/, '\1' + portion(newname).to_page_title)
|
50
|
-
File.open(file, 'w') {|f| f.puts text}
|
51
|
-
report file, portion(oldname).short_page_title, portion(newname)
|
52
|
-
rescue
|
53
|
-
puts "Error processing #{file}: #$!"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
RELATIVE_LINK_REGEX = /(\A|\s)([A-Z][a-z]+[A-Z0-9]\w*)/
|
59
|
-
|
60
|
-
def absolutize_unqualified_outbound_links(oldname, newname)
|
61
|
-
MEMO << "Absolutizing unqualified inbound links"
|
62
|
-
target_file = full(newname).to_file_path
|
63
|
-
if File.exist?(target_file)
|
64
|
-
text = File.read(target_file)
|
65
|
-
begin
|
66
|
-
matches = text.scan(RELATIVE_LINK_REGEX).map {|x| x[1]}.
|
67
|
-
select {|match| match.strip != "" }.
|
68
|
-
select {|match| File.exist?( portion(oldname).namespace + "/#{match}" ) }
|
69
|
-
puts MEMO << " - In file #{target_file}: matches: #{matches.inspect}"
|
70
|
-
|
71
|
-
text = text.gsub(RELATIVE_LINK_REGEX) do |match|
|
72
|
-
if matches.include?($2)
|
73
|
-
res = "#$1#{portion(oldname).namespace}.#{$2}"
|
74
|
-
MEMO << " - In file #{target_file}: #{$2} -> #{res.strip}"
|
75
|
-
res
|
76
|
-
else
|
77
|
-
MEMO << " - In file #{target_file}: skipping #{$2}"
|
78
|
-
match
|
79
|
-
end
|
80
|
-
end
|
81
|
-
File.open(target_file, 'w') {|f| f.puts text}
|
82
|
-
rescue
|
83
|
-
puts "Error processing #{target_file}: #$!"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
# Three other cases to cover, involving namespaces:
|
90
|
-
#
|
91
|
-
# Case 1: newname is in same namespace as oldname
|
92
|
-
#
|
93
|
-
# In the directory for OldName's namespace, change all unqualified referenecs to
|
94
|
-
# OldName to NewName
|
95
|
-
|
96
|
-
if portion(oldname).namespace == portion(newname).namespace
|
97
|
-
MEMO << "- Updating unqualified links in same namespace"
|
98
|
-
target_files = `grep -rlF '#{portion(oldname).short_page_title}' #{full(portion(oldname).namespace)}`.strip.split(/\n/)
|
99
|
-
target_files.select {|f| f !~ /(\.swp|\.swo)$/}.each do |file|
|
100
|
-
text = File.read(file)
|
101
|
-
begin
|
102
|
-
text = text.gsub(/(\A|\s)(#{portion(oldname).short_page_title})\b/, '\1' + portion(newname).short_page_title)
|
103
|
-
File.open(file, 'w') {|f| f.puts text}
|
104
|
-
report file, portion(oldname).short_page_title, portion(newname).short_page_title
|
105
|
-
rescue
|
106
|
-
puts "Error processing #{file}: #$!"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
# Case 2: newname is in different namespace from oldname
|
110
|
-
# oldname.namespace != newname.namespace
|
111
|
-
else
|
112
|
-
# In the directory for OldName's namespace, change all unqualified references to
|
113
|
-
# OldName to newnamespace.NewName (i.e. NewName).
|
114
|
-
change_unqualified_inbound_links_in_same_namespace(oldname, newname)
|
115
|
-
# And in the renamed file, change all unqualified references to
|
116
|
-
# PageName to oldnamespace.PageName
|
117
|
-
absolutize_unqualified_outbound_links(oldname, newname)
|
118
|
-
end
|
119
|
-
|
120
|
-
# Finally,
|
121
|
-
change_all_absolute_links oldname, newname
|
122
|
-
|
123
|
-
puts MEMO.join("\n")
|
10
|
+
renamer.rename
|
11
|
+
renamer.print_report
|
data/lib/path_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module PathHelper
|
4
|
+
|
5
|
+
def repo_path=(repo_path)
|
6
|
+
@repo_path = repo_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def repo_path
|
10
|
+
@repo_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def repo_relative(path)
|
14
|
+
ensure_path(path).relative_path_from(repo_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def in_repo(path)
|
18
|
+
repo_path.join(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ensure_path(path)
|
22
|
+
path.is_a?(Pathname) ? path : Pathname.new(path)
|
23
|
+
end
|
24
|
+
end
|
data/lib/soywiki.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'string_ext'
|
2
|
+
require 'path_helper'
|
2
3
|
module Template_Substitution; end
|
3
4
|
module Soywiki
|
4
|
-
VERSION = '0.9.8'
|
5
|
+
VERSION = '0.9.8.1'
|
5
6
|
WIKI_WORD = /\b([a-z0-9][\w_]+\.)?[A-Z][a-z]+[A-Z0-9]\w*\b/
|
6
7
|
SCHEMES = %w{https http file soyfile}
|
7
8
|
HYPERLINK = %r|\b(?:#{SCHEMES.join('|')})://[^ >)\n\]]+|
|
data/lib/soywiki.vim
CHANGED
@@ -587,10 +587,10 @@ func! s:expand(seamless, vertical)
|
|
587
587
|
if a:seamless == 1
|
588
588
|
" seamful, the default
|
589
589
|
echom "Expanding seamfully. Please wait."
|
590
|
-
let res = system(s:expand_command . " seamless " . bufname('%'))
|
590
|
+
let res = system(s:expand_command . " " . s:wiki_root() . " seamless " . bufname('%'))
|
591
591
|
else " seamless
|
592
592
|
echom "Expanding seamlessly. Please wait."
|
593
|
-
let res = system(s:expand_command . " seamful " . bufname('%'))
|
593
|
+
let res = system(s:expand_command . " " . s:wiki_root() . " seamful " . bufname('%'))
|
594
594
|
endif
|
595
595
|
if a:vertical
|
596
596
|
botright vnew
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Soywiki
|
2
|
+
class Expander
|
3
|
+
# Takes any wiki link that stands alone on a line and expands it
|
4
|
+
# this is different from Soywiki::WIKI_WORD in that it requires ^\s* before the
|
5
|
+
# first letter
|
6
|
+
|
7
|
+
WIKI_LINK_PATTERN = /^\s*([a-z0-9]\w+\.)?[A-Z][a-z]+[A-Z0-9]\w*\s*$/
|
8
|
+
|
9
|
+
attr_reader :mode, :file, :processed_files
|
10
|
+
attr_reader :repo_path, :file_path
|
11
|
+
attr_reader :expanded_text
|
12
|
+
|
13
|
+
include PathHelper
|
14
|
+
|
15
|
+
def initialize(repo_path, mode, file)
|
16
|
+
@repo_path = ensure_path(repo_path)
|
17
|
+
@mode = mode
|
18
|
+
@file_path = ensure_path(file)
|
19
|
+
@file = repo_relative(file).to_s
|
20
|
+
@processed_files = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def seamless?
|
24
|
+
mode == 'seamless'
|
25
|
+
end
|
26
|
+
|
27
|
+
def seamful?
|
28
|
+
mode == 'seamful'
|
29
|
+
end
|
30
|
+
|
31
|
+
def indent(text, level)
|
32
|
+
return text if seamless?
|
33
|
+
return text if level == 0
|
34
|
+
('|' * level) + ' ' + text
|
35
|
+
end
|
36
|
+
|
37
|
+
def divider
|
38
|
+
'+' + '-' * 78 + '+'
|
39
|
+
end
|
40
|
+
|
41
|
+
def register_in_expansion(text, inline=false)
|
42
|
+
@expanded_text ||= ''
|
43
|
+
full_text = inline ? text : text + "\n"
|
44
|
+
@expanded_text << full_text
|
45
|
+
end
|
46
|
+
|
47
|
+
def recursive_expand(file_path, name, level=0)
|
48
|
+
processed_files << file_path
|
49
|
+
lines = file_path.readlines
|
50
|
+
title = lines.shift # takes title
|
51
|
+
lines = lines.join.strip.split("\n")
|
52
|
+
if seamful?
|
53
|
+
register_in_expansion divider unless level == 0
|
54
|
+
register_in_expansion indent(title, level)
|
55
|
+
end
|
56
|
+
lines.each do |line|
|
57
|
+
# note that the wiki link must be alone on the line to be expanded
|
58
|
+
if line =~ WIKI_LINK_PATTERN
|
59
|
+
link = line.strip
|
60
|
+
if link =~ /(\A|\s)[A-Z]/ # short link in namespace (relative link)
|
61
|
+
link = [name.namespace, link].join('.')
|
62
|
+
end
|
63
|
+
link_file_path = in_repo(link.to_file_path)
|
64
|
+
if link_file_path.file? && !processed_files.include?(link_file_path)
|
65
|
+
recursive_expand(link_file_path, link, level + 1) # recursive call
|
66
|
+
elsif processed_files.include?(link_file_path)
|
67
|
+
register_in_expansion indent("#{link} [[already expanded]]", level)
|
68
|
+
elsif !link_file_path.file?
|
69
|
+
register_in_expansion indent("#{link} [[no file found]]", level)
|
70
|
+
else
|
71
|
+
register_in_expansion indent("#{link}", level)
|
72
|
+
end
|
73
|
+
else
|
74
|
+
register_in_expansion indent(line, level)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
register_in_expansion divider if seamful? && level != 0
|
78
|
+
end
|
79
|
+
|
80
|
+
def expand
|
81
|
+
recursive_expand(file_path, file.to_page_title)
|
82
|
+
expanded_text
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
module Soywiki
|
2
|
+
class Renamer
|
3
|
+
attr_reader :repo_path, :old_name, :new_name
|
4
|
+
attr_reader :memo
|
5
|
+
|
6
|
+
include PathHelper
|
7
|
+
|
8
|
+
def initialize(repo_path, old_name, new_name)
|
9
|
+
@repo_path = ensure_path(repo_path)
|
10
|
+
@old_path = ensure_path(old_name)
|
11
|
+
@new_path = ensure_path(new_name)
|
12
|
+
@old_name = repo_relative(@old_path).to_s
|
13
|
+
@new_name = repo_relative(@new_path).to_s
|
14
|
+
@memo = ["Updating inbound and outbound links..."]
|
15
|
+
end
|
16
|
+
|
17
|
+
def namespace(query=nil)
|
18
|
+
self.instance_variable_get("@#{query}_name").namespace
|
19
|
+
rescue
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def page_title(query=nil)
|
24
|
+
self.instance_variable_get("@#{query}_name").to_page_title
|
25
|
+
rescue
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def short_page_title(query=nil)
|
30
|
+
self.instance_variable_get("@#{query}_name").short_page_title
|
31
|
+
rescue
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def report(file, oldname, newname)
|
36
|
+
@memo << " - In #{file}: #{oldname} -> #{newname}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def memorize(message)
|
40
|
+
@memo ||= []
|
41
|
+
@memo << message if message.is_a?(String)
|
42
|
+
@memo += message if message.is_a?(Array)
|
43
|
+
message
|
44
|
+
end
|
45
|
+
|
46
|
+
def print_report
|
47
|
+
puts @memo.join("\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
def grep_for_files(search, where, ignore=/(\.swp|\.swo)$/)
|
51
|
+
cmd = "grep -rlF '#{search}' #{where}"
|
52
|
+
puts cmd
|
53
|
+
files = `#{cmd}`.strip.split(/\n/)
|
54
|
+
ignore ? files.select { |f| f !~ ignore } : files
|
55
|
+
end
|
56
|
+
|
57
|
+
def change_all_absolute_links
|
58
|
+
memorize "- Updating all absolute links"
|
59
|
+
grep_for_files(page_title(:old), repo_path).each do |file|
|
60
|
+
text = File.read(file)
|
61
|
+
begin
|
62
|
+
regex = /\b#{page_title(:old)}\b/
|
63
|
+
matches = text.scan(regex)
|
64
|
+
text = text.gsub(regex, page_title(:new))
|
65
|
+
File.open(file, 'w') {|f| f.puts text}
|
66
|
+
report file, page_title(:old), page_title(:new)
|
67
|
+
rescue
|
68
|
+
puts "Error processing #{file}: #$!"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def change_unqualified_inbound_links_in_same_namespace
|
74
|
+
memorize "- Updating unqualified inbound links"
|
75
|
+
grep_for_files(short_page_title(:old), in_repo(namespace(:old))).each do |file|
|
76
|
+
text = File.read(file)
|
77
|
+
begin
|
78
|
+
text = text.gsub(/(\A|\s)(#{short_page_title(:old)}\b)/, '\1' + page_title(:new))
|
79
|
+
File.open(file, 'w') {|f| f.puts text}
|
80
|
+
report file, short_page_title(:old), new_name
|
81
|
+
rescue
|
82
|
+
puts "Error processing #{file}: #$!"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
RELATIVE_LINK_REGEX = /(\A|\s)([A-Z][a-z]+[A-Z0-9]\w*)/
|
88
|
+
|
89
|
+
def absolutize_unqualified_outbound_links
|
90
|
+
memorize "Absolutizing unqualified inbound links"
|
91
|
+
target_file = ensure_path(in_repo(new_name).to_s.to_file_path)
|
92
|
+
if target_file.exist?
|
93
|
+
text = target_file.read
|
94
|
+
begin
|
95
|
+
matches = text.scan(RELATIVE_LINK_REGEX).map {|x| x[1]}.
|
96
|
+
select {|match| match.strip != "" }.
|
97
|
+
select {|match| in_repo("#{namespace(:old)}/#{match}").exist? }
|
98
|
+
puts memorize(" - In file #{target_file}: matches: #{matches.inspect}")
|
99
|
+
|
100
|
+
text = text.gsub(RELATIVE_LINK_REGEX) do |match|
|
101
|
+
if matches.include?($2)
|
102
|
+
res = "#$1#{namespace(:old)}.#{$2}"
|
103
|
+
memorize " - In file #{target_file}: #{$2} -> #{res.strip}"
|
104
|
+
res
|
105
|
+
else
|
106
|
+
memorize " - In file #{target_file}: skipping #{$2}"
|
107
|
+
match
|
108
|
+
end
|
109
|
+
end
|
110
|
+
File.open(target_file, 'w') {|f| f.puts text}
|
111
|
+
rescue
|
112
|
+
puts "Error processing #{target_file}: #$!"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def rename
|
118
|
+
# Three other cases to cover, involving namespaces:
|
119
|
+
#
|
120
|
+
# Case 1: newname is in same namespace as oldname
|
121
|
+
#
|
122
|
+
# In the directory for OldName's namespace, change all unqualified references to
|
123
|
+
# OldName to NewName
|
124
|
+
|
125
|
+
if namespace(:old) == namespace(:new)
|
126
|
+
memorize "- Updating unqualified links in same namespace"
|
127
|
+
grep_for_files(short_page_title(:old), in_repo(namespace(:old))).each do |file|
|
128
|
+
text = File.read(file)
|
129
|
+
begin
|
130
|
+
text = text.gsub(/(\A|\s)(#{short_page_title(:old)})\b/, '\1' + short_page_title(:new))
|
131
|
+
File.open(file, 'w') {|f| f.puts text}
|
132
|
+
report file, short_page_title(:old), short_page_title(:new)
|
133
|
+
rescue
|
134
|
+
puts "Error processing #{file}: #$!"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
# Case 2: newname is in different namespace from oldname
|
138
|
+
# oldname.namespace != newname.namespace
|
139
|
+
else
|
140
|
+
# In the directory for OldName's namespace, change all unqualified references to
|
141
|
+
# OldName to newnamespace.NewName (i.e. NewName).
|
142
|
+
change_unqualified_inbound_links_in_same_namespace
|
143
|
+
# And in the renamed file, change all unqualified references to
|
144
|
+
# PageName to oldnamespace.PageName
|
145
|
+
absolutize_unqualified_outbound_links
|
146
|
+
end
|
147
|
+
|
148
|
+
# Finally,
|
149
|
+
change_all_absolute_links
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soywiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.8
|
4
|
+
version: 0.9.8.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Daniel Choi
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: A personal and collaborative wiki for Vim users
|
14
15
|
email:
|
@@ -22,7 +23,7 @@ executables:
|
|
22
23
|
extensions: []
|
23
24
|
extra_rdoc_files: []
|
24
25
|
files:
|
25
|
-
-
|
26
|
+
- .gitignore
|
26
27
|
- Gemfile
|
27
28
|
- Gemfile.lock
|
28
29
|
- MIT-LICENSE.txt
|
@@ -35,45 +36,42 @@ files:
|
|
35
36
|
- bin/soywiki-rename
|
36
37
|
- lib/index_template.html.haml
|
37
38
|
- lib/page_template.html.haml
|
39
|
+
- lib/path_helper.rb
|
38
40
|
- lib/plugin.erb
|
39
41
|
- lib/soywiki.rb
|
40
42
|
- lib/soywiki.vim
|
43
|
+
- lib/soywiki/expander.rb
|
41
44
|
- lib/soywiki/html.rb
|
45
|
+
- lib/soywiki/renamer.rb
|
42
46
|
- lib/string_ext.rb
|
43
47
|
- plugin/soywiki_starter.vim
|
44
48
|
- soywiki.gemspec
|
45
49
|
homepage: http://danielchoi.com/software/soywiki.html
|
46
50
|
licenses:
|
47
51
|
- MIT
|
48
|
-
|
49
|
-
|
50
|
-
For optional compilation of the wiki to html you will need:
|
51
|
-
- haml
|
52
|
-
and for markdown support:
|
53
|
-
- rdiscount
|
52
|
+
post_install_message: ! "For optional compilation of the wiki to html you will need:\n
|
53
|
+
- haml\nand for markdown support:\n - rdiscount\n"
|
54
54
|
rdoc_options: []
|
55
55
|
require_paths:
|
56
56
|
- lib
|
57
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
58
59
|
requirements:
|
59
|
-
- -
|
60
|
+
- - ! '>='
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
63
65
|
requirements:
|
64
|
-
- -
|
66
|
+
- - ! '>='
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: '0'
|
67
69
|
requirements:
|
68
|
-
-
|
69
|
-
|
70
|
-
- haml
|
71
|
-
and for markdown support:
|
72
|
-
- rdiscount
|
70
|
+
- ! "For optional compilation of the wiki to html you will need:\n - haml\nand for
|
71
|
+
markdown support:\n - rdiscount\n"
|
73
72
|
rubyforge_project: soywiki
|
74
|
-
rubygems_version:
|
73
|
+
rubygems_version: 1.8.23
|
75
74
|
signing_key:
|
76
|
-
specification_version:
|
75
|
+
specification_version: 3
|
77
76
|
summary: Wiki with Vim interface and Git repo
|
78
77
|
test_files: []
|
79
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 6c1e6152993b6e0820791c73ebdea116eef9efff
|
4
|
-
data.tar.gz: 7ade48e0f2a70e0f238d2cc6e15f1d7f9c195718
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 51957fd552e2ddae5997da054797930e43739a83f2e8edd28d11ecb0e4448af5afdb705e3517c4836b52fc8a59dbb4afd576cebca58a8ffbb5eca30821651313
|
7
|
-
data.tar.gz: 4bf43baa95088be55aec5e4d047a1cf6b5005c9be544b1284018e9e117d2c6dcefe6eeb32e44fa4cd04051e83228c65a7a20d0ade060a3aa087ef8d3f7a492bf
|