wikian 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -8
- data/lib/wikian.rb +3 -0
- data/lib/wikian/post.rb +1 -1
- data/lib/wikian/search.rb +10 -5
- data/lib/wikian/subcommand.rb +5 -0
- data/lib/wikian/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6044c74a22baf5f757da1f68bc65f0758da46a41ee3567b19b0a61688d3b7034
|
4
|
+
data.tar.gz: 415490e2958ed48196c97ddbca6f3a86afff1c7ee535c9d1a1ed39bf3313bce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3155eb0bc4f6a2a1648eb186072bda807b4af64ef79d9034e0c597900a5b2a9ed7b6d498a469545596673b37a0323360d59eef8f043b2710fcea462bf3ec7b55
|
7
|
+
data.tar.gz: cc705511bc328eeb488180ce7940f64eaa2e82f0b8302cbc26cb93e38aeff15b7f6ccd20b3f08d8ea5ec2dd2ab0eedeb9ca4297f01bae0b18a05995e5ec56f3e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -70,24 +70,28 @@ $ wi post -s 2 Wikipedia:Sandbox.en.wikipedia.org.wiki
|
|
70
70
|
Article uploaded
|
71
71
|
```
|
72
72
|
|
73
|
-
To search for a
|
73
|
+
To search for a term in Wikipedia:
|
74
74
|
|
75
75
|
```
|
76
|
-
$ wi
|
77
|
-
Creating template wiki.yml
|
78
|
-
|
79
|
-
$ wi s
|
76
|
+
$ wi s Mr. Fixit
|
80
77
|
Writing to Mr. Fixit.json
|
81
78
|
```
|
82
79
|
|
83
80
|
To get your last 10 Wikipedia contributions:
|
84
81
|
|
85
82
|
```
|
86
|
-
$ wi c -t
|
87
|
-
Creating template wiki.yml
|
88
|
-
|
89
83
|
$ wi c
|
90
84
|
Writing to User:Example_User.contributions.en.wikipedia.org.json
|
91
85
|
```
|
92
86
|
|
87
|
+
To tune the request parameters create a config file with any of these:
|
88
|
+
```
|
89
|
+
$ wi g -t
|
90
|
+
|
91
|
+
$ wi c -t
|
92
|
+
|
93
|
+
$ wi s -t
|
94
|
+
```
|
95
|
+
|
96
|
+
|
93
97
|
Vim users should try [mediawiki.vim](https://en.wikipedia.org/wiki/Help:Text_editor_support#Vim) which adds syntax highlighting and abbreviations for wikitext files.
|
data/lib/wikian.rb
CHANGED
@@ -113,6 +113,9 @@ class Wikian
|
|
113
113
|
# append wikitext to section 2 of the article
|
114
114
|
wi post -a -s 2 Wikipedia:Sandbox.en.wikipedia.org.wiki
|
115
115
|
|
116
|
+
# search for multiple terms in Wikipedia
|
117
|
+
wi search term 1:term 2:term 3
|
118
|
+
|
116
119
|
# heavy use of the API may require cache validation
|
117
120
|
wi post -c 1234:someMessage spider-Man.wiki
|
118
121
|
|
data/lib/wikian/post.rb
CHANGED
@@ -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.mtime(input_file).utc.iso8601}}}
|
134
|
+
metadata = {'meta' => {params['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)
|
data/lib/wikian/search.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
class Wikian
|
2
2
|
class WikianGetError < StandardError; end
|
3
|
-
class
|
3
|
+
class MissingSearchTermError < WikianGetError; end
|
4
4
|
|
5
5
|
class Search < Subcommand
|
6
6
|
def initialize(args)
|
7
7
|
super
|
8
8
|
|
9
|
-
|
9
|
+
srsearch = non_opt_args.join(' ')
|
10
10
|
|
11
|
-
|
11
|
+
raise MissingSearchTermError if srsearch.empty?
|
12
|
+
|
13
|
+
@params.merge!('srsearch' => srsearch, 'format' => Wikian::RESPONSE_FORMAT)
|
14
|
+
|
15
|
+
@output_file = srsearch
|
12
16
|
|
13
17
|
@query = @params.to_query
|
14
18
|
|
@@ -30,8 +34,9 @@ class Wikian
|
|
30
34
|
- query
|
31
35
|
list:
|
32
36
|
- search
|
33
|
-
srsearch: # text to search for. You can use multiple
|
34
|
-
|
37
|
+
#srsearch: # text to search for. You can use multiple
|
38
|
+
# - Mr. Fixit
|
39
|
+
# - Term 2
|
35
40
|
eos
|
36
41
|
end
|
37
42
|
end
|
data/lib/wikian/subcommand.rb
CHANGED
@@ -43,6 +43,11 @@ class Wikian
|
|
43
43
|
exit
|
44
44
|
end
|
45
45
|
|
46
|
+
# return args that dont start with '-'
|
47
|
+
def non_opt_args
|
48
|
+
args.reject {|p| p[0] == '-'}
|
49
|
+
end
|
50
|
+
|
46
51
|
# HTTP response file name. Its extension depends on the 'content-type' header
|
47
52
|
def response_file
|
48
53
|
output_file + '.' + res.meta['content-type'].split('/').last.sub(/;.*/,'')
|
data/lib/wikian/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergioro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Get and update Wikipedia articles
|
14
14
|
email:
|