wikian 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/wikian.rb +1 -0
- data/lib/wikian/contributions.rb +1 -1
- data/lib/wikian/get.rb +1 -1
- data/lib/wikian/post.rb +26 -11
- data/lib/wikian/search.rb +1 -1
- data/lib/wikian/subcommand.rb +1 -1
- data/lib/wikian/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66726501f7fd096888803fc73c97612ef35b26e3246c54c4f9fbb7ea887c9d78
|
4
|
+
data.tar.gz: 9cda60a1184cb39a79cec8a93cb36fba2cde382bb7d1d69ca7d1beb79f36dc4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5370603bfe66ffe85be969cbb5eadcd4f96dedcc59c594effb81f76c1b7538ba9588f822e7ef50c52c04a46e54217e086d93cd64cda742607018d1e5c9d81dc9
|
7
|
+
data.tar.gz: b9039ccf6311700d85ce6b80f62a8a9238e08ba3727a684e82764ace39778975bff5f543932e91b84749f1e094e89cef68a671d24607026fab75300366d3a85c
|
data/Gemfile.lock
CHANGED
data/lib/wikian.rb
CHANGED
@@ -78,6 +78,7 @@ class Wikian
|
|
78
78
|
-a, --append append the input file
|
79
79
|
-c, --captcha ID:MESSAGE captcha info
|
80
80
|
-d, --debug print debugging messages
|
81
|
+
-f, --force force post (this ignores edit conflicts)
|
81
82
|
-h, --help print this help message
|
82
83
|
-m, --message MESSAGE add a commit message (HIGHLY recommended)
|
83
84
|
-p, --prepend prepend the input file
|
data/lib/wikian/contributions.rb
CHANGED
data/lib/wikian/get.rb
CHANGED
data/lib/wikian/post.rb
CHANGED
@@ -28,7 +28,7 @@ class Wikian
|
|
28
28
|
|
29
29
|
@debug = (args & %w(-d)).length > 0 ? true : false
|
30
30
|
rescue => e
|
31
|
-
puts "#{e.class} in #{__FILE__}
|
31
|
+
puts "#{e.class} in #{__FILE__}", e.message
|
32
32
|
exit
|
33
33
|
end
|
34
34
|
|
@@ -55,9 +55,9 @@ class Wikian
|
|
55
55
|
|
56
56
|
get_latest_revision
|
57
57
|
|
58
|
-
if @body_text && Time.parse(params['starttimestamp']) < Time.parse(params['basetimestamp'])
|
59
|
-
puts "
|
60
|
-
merge_versions
|
58
|
+
if !args.include?('-f') && @body_text && Time.parse(params['starttimestamp']) < Time.parse(params['basetimestamp'])
|
59
|
+
puts "Edit conflict detected"
|
60
|
+
merge_versions(@body_text, latest_content)
|
61
61
|
end
|
62
62
|
|
63
63
|
get_csrf_token
|
@@ -131,7 +131,7 @@ class Wikian
|
|
131
131
|
timestamp
|
132
132
|
else
|
133
133
|
FileUtils.mkdir_p(Wikian.meta_dir)
|
134
|
-
metadata = {'meta' => {'title' => {'timestamp' => File.
|
134
|
+
metadata = {'meta' => {'title' => {'timestamp' => File.mtime(input_file).utc.iso8601}}}
|
135
135
|
File.write(Wikian.meta_file, YAML.dump(metadata))
|
136
136
|
end
|
137
137
|
wikitext = File.read(input_file)
|
@@ -154,16 +154,30 @@ class Wikian
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
157
|
+
# merge two version with diff.
|
158
|
+
# TODO the merge command is ADDING differences, but it should MERGE differences.
|
159
|
+
def merge_versions(content_one, content_two)
|
160
|
+
tmp_local = Tempfile.open {|f| f.write content_one; f}
|
161
|
+
tmp_latest = Tempfile.open {|f| f.write content_two; f}
|
162
|
+
|
163
|
+
diff_cmd = "diff #{tmp_local.path} #{tmp_latest.path}"
|
164
|
+
system("#{diff_cmd}")
|
165
|
+
|
166
|
+
# raise error until the above TODO is solved
|
167
|
+
raise WikiMergeError, "Please merge with latest version and try again"
|
168
|
+
|
169
|
+
merge_cmd = "diff --line-format %L #{tmp_local.path} #{tmp_latest.path}"
|
170
|
+
@body_text = %x(#{merge_cmd})
|
162
171
|
rescue => e
|
163
|
-
puts "
|
172
|
+
puts "#{e.class} in #{__FILE__}", e.message
|
164
173
|
exit
|
165
174
|
end
|
166
175
|
|
176
|
+
def update_metadata
|
177
|
+
metadata['meta'].merge!(params['title'] => {'timestamp' => Time.now.utc.iso8601})
|
178
|
+
File.write(Wikian.meta_file, YAML.dump(metadata))
|
179
|
+
end
|
180
|
+
|
167
181
|
def upload_article
|
168
182
|
@query = URI.encode_www_form(params)
|
169
183
|
puts("\nUploading the wiki article using csrf token #{csrf_token}") if debug
|
@@ -182,6 +196,7 @@ class Wikian
|
|
182
196
|
"Try pasing the '-r' option to remove '#{csrf_cookie_file}'",
|
183
197
|
"Or pass '-d' option for debugging"
|
184
198
|
else
|
199
|
+
update_metadata
|
185
200
|
puts "Article uploaded"
|
186
201
|
end
|
187
202
|
end
|
data/lib/wikian/search.rb
CHANGED
data/lib/wikian/subcommand.rb
CHANGED
data/lib/wikian/version.rb
CHANGED