rbmediawiki 0.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/util/genall.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/sh
2
+
3
+ ruby genqueryymlfromdesc.rb > queries.yml
4
+ ruby genotherymlfromdesc.rb > other.yml
5
+ ruby genquerycodefromyml.rb > queries.rb
6
+ ruby genothercodefromyml.rb > other.rb
@@ -0,0 +1,27 @@
1
+ #This script generates code from a yml description of the api (requests *other* than action=query, that ahs its own generator). The yml description can be obtained from the mediawikidocumentation using genotherymlfromdesc
2
+ require 'yaml'
3
+
4
+ Apiconf = YAML::load(File.open("other.yml"))
5
+
6
+ str =""
7
+ Apiconf.each {|root|
8
+ root.each {|method|
9
+ if Apiconf[method]
10
+ str += "def #{method}("
11
+ Apiconf[method].each {|param|
12
+ str += "#{param} = nil, "
13
+ }
14
+ str = str+ "post_me = nil)\n\n"
15
+ Apiconf[method].each {|param|
16
+ str += " post_me = add_post('#{param}', #{param}, post_me)\n"
17
+ }
18
+ str += " post_me = add_post('action', '#{method}', post_me)\n"
19
+ str += " post_me = format(post_me, 'xml')\n"
20
+ str += " result = make_request(post_me)\n"
21
+ str += " return result\n"
22
+ str += "end\n\n"
23
+ end
24
+ }
25
+ }
26
+
27
+ puts str
@@ -0,0 +1,23 @@
1
+ #this script generates an yml from the description of request to the api other than action=query. the description can be obtained at http://es.wikipedia.org/w/api.php
2
+
3
+ file = File.new("desc", "r")
4
+
5
+ str = ""
6
+ parameters = false
7
+ file.each {|line|
8
+ case line
9
+ when /^\* (.*)=(.*) \*/
10
+ str += "#{$2}:\n"
11
+ when /^Parameters.*/
12
+ parameters = true
13
+ when /^Example.*/
14
+ parameters = false
15
+ when /^ (\w*)\s*- (.*)/
16
+ if parameters
17
+ str += " - #{$1}\n"
18
+ end
19
+ end
20
+ }
21
+ puts str
22
+ file.close
23
+
@@ -0,0 +1,29 @@
1
+ #This script generates code from a yml description of the api (requests to the method action=query, other actions have another generator). The yml description can be obtained from the mediawikidocumentation using genqueryymlfromdesc
2
+ require 'yaml'
3
+
4
+ Apiconf = YAML::load(File.open("queries.yml"))
5
+
6
+ str =""
7
+ Apiconf.each {|root|
8
+ root.each {|method|
9
+ if Apiconf[method]
10
+ method =~ /(.*)=(.*)/
11
+ str += "def query_#{$1}_#{$2}(titles = nil, "
12
+ Apiconf[method].each {|param|
13
+ str += "#{param} = nil, "
14
+ }
15
+ str = str+ "pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)\n\n"
16
+ Apiconf[method].each {|param|
17
+ str += " post_me = add_post('#{param}', #{param}, post_me)\n"
18
+ }
19
+ str += " post_me = add_post('#{$1}', '#{$2}', post_me)\n"
20
+ str += " post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)\n"
21
+ str += " post_me = format(post_me, 'xml')\n"
22
+ str += " result = make_request(post_me)\n"
23
+ str += " return result\n"
24
+ str += "end\n\n"
25
+ end
26
+ }
27
+ }
28
+
29
+ puts str
@@ -0,0 +1,22 @@
1
+ #this script generates an yml from the description of request to the api for action=query. the description can be obtained at http://es.wikipedia.org/w/api.php
2
+ file = File.new("querydesc", "r")
3
+
4
+ str = ""
5
+ parameters = false
6
+ file.each {|line|
7
+ case line
8
+ when /^\* (.*)=(.*) \(.*\) \*/
9
+ str += "#{$1}=#{$2}:\n"
10
+ when /^Parameters.*/
11
+ parameters = true
12
+ when /^Example.*/
13
+ parameters = false
14
+ when /^ (\w*)\s*- (.*)/
15
+ if parameters
16
+ str += " - #{$1}\n"
17
+ end
18
+ end
19
+ }
20
+ puts str
21
+ file.close
22
+
data/util/other.yml ADDED
@@ -0,0 +1,126 @@
1
+ expandtemplates:
2
+ - title
3
+ - text
4
+ - generatexml
5
+ parse:
6
+ - title
7
+ - text
8
+ - page
9
+ - redirects
10
+ - oldid
11
+ - prop
12
+ - pst
13
+ - onlypst
14
+ feedwatchlist:
15
+ - feedformat
16
+ - hours
17
+ - allrev
18
+ help:
19
+ paraminfo:
20
+ - modules
21
+ - querymodules
22
+ - mainmodule
23
+ - pagesetmodule
24
+ purge:
25
+ - titles
26
+ rollback:
27
+ - title
28
+ - user
29
+ - token
30
+ - summary
31
+ - markbot
32
+ delete:
33
+ - title
34
+ - pageid
35
+ - token
36
+ - reason
37
+ - watch
38
+ - unwatch
39
+ - oldimage
40
+ undelete:
41
+ - title
42
+ - token
43
+ - reason
44
+ - timestamps
45
+ protect:
46
+ - title
47
+ - token
48
+ - protections
49
+ - expiry
50
+ - reason
51
+ - cascade
52
+ - watch
53
+ block:
54
+ - user
55
+ - token
56
+ - gettoken
57
+ - expiry
58
+ - reason
59
+ - anononly
60
+ - nocreate
61
+ - autoblock
62
+ - noemail
63
+ - hidename
64
+ - allowusertalk
65
+ - reblock
66
+ unblock:
67
+ - id
68
+ - user
69
+ - token
70
+ - gettoken
71
+ - reason
72
+ move:
73
+ - from
74
+ - fromid
75
+ - to
76
+ - token
77
+ - reason
78
+ - movetalk
79
+ - movesubpages
80
+ - noredirect
81
+ - watch
82
+ - unwatch
83
+ edit:
84
+ - title
85
+ - section
86
+ - text
87
+ - token
88
+ - summary
89
+ - minor
90
+ - notminor
91
+ - bot
92
+ - basetimestamp
93
+ - starttimestamp
94
+ - recreate
95
+ - createonly
96
+ - nocreate
97
+ - captchaword
98
+ - captchaid
99
+ - watch
100
+ - unwatch
101
+ - md5
102
+ - prependtext
103
+ - appendtext
104
+ - undo
105
+ - undoafter
106
+ emailuser:
107
+ - target
108
+ - subject
109
+ - text
110
+ - token
111
+ - ccme
112
+ watch:
113
+ - title
114
+ - unwatch
115
+ patrol:
116
+ - token
117
+ - rcid
118
+ import:
119
+ - token
120
+ - summary
121
+ - xml
122
+ - interwikisource
123
+ - interwikipage
124
+ - fullhistory
125
+ - templates
126
+ - namespace
data/util/queries.yml ADDED
@@ -0,0 +1,247 @@
1
+ prop=info:
2
+ - inprop
3
+ - intoken
4
+ - incontinue
5
+ prop=revisions:
6
+ - rvprop
7
+ - rvlimit
8
+ - rvstartid
9
+ - rvendid
10
+ - rvstart
11
+ - rvend
12
+ - rvdir
13
+ - rvuser
14
+ - rvexcludeuser
15
+ - rvexpandtemplates
16
+ - rvgeneratexml
17
+ - rvsection
18
+ - rvtoken
19
+ - rvcontinue
20
+ - rvdiffto
21
+ prop=links:
22
+ - plnamespace
23
+ - pllimit
24
+ - plcontinue
25
+ prop=langlinks:
26
+ - lllimit
27
+ - llcontinue
28
+ prop=images:
29
+ - imlimit
30
+ - imcontinue
31
+ prop=imageinfo:
32
+ - iiprop
33
+ - iilimit
34
+ - iistart
35
+ - iiend
36
+ - iiurlwidth
37
+ - iiurlheight
38
+ - iicontinue
39
+ prop=templates:
40
+ - tlnamespace
41
+ - tllimit
42
+ - tlcontinue
43
+ prop=categories:
44
+ - clprop
45
+ - clshow
46
+ - cllimit
47
+ - clcontinue
48
+ - clcategories
49
+ prop=extlinks:
50
+ - ellimit
51
+ - eloffset
52
+ prop=categoryinfo:
53
+ - cicontinue
54
+ prop=duplicatefiles:
55
+ - dflimit
56
+ - dfcontinue
57
+ list=allimages:
58
+ - aifrom
59
+ - aiprefix
60
+ - aiminsize
61
+ - aimaxsize
62
+ - ailimit
63
+ - aidir
64
+ - aisha1
65
+ - aisha1base36
66
+ - aiprop
67
+ list=allpages:
68
+ - apfrom
69
+ - apprefix
70
+ - apnamespace
71
+ - apfilterredir
72
+ - apminsize
73
+ - apmaxsize
74
+ - apprtype
75
+ - apprlevel
76
+ - apprfiltercascade
77
+ - aplimit
78
+ - apdir
79
+ - apfilterlanglinks
80
+ list=alllinks:
81
+ - alcontinue
82
+ - alfrom
83
+ - alprefix
84
+ - alunique
85
+ - alprop
86
+ - alnamespace
87
+ - allimit
88
+ list=allcategories:
89
+ - acfrom
90
+ - acprefix
91
+ - acdir
92
+ - aclimit
93
+ - acprop
94
+ list=allusers:
95
+ - aufrom
96
+ - auprefix
97
+ - augroup
98
+ - auprop
99
+ - aulimit
100
+ - auwitheditsonly
101
+ list=backlinks:
102
+ - bltitle
103
+ - blcontinue
104
+ - blnamespace
105
+ - blfilterredir
106
+ - bllimit
107
+ - blredirect
108
+ list=blocks:
109
+ - bkstart
110
+ - bkend
111
+ - bkdir
112
+ - bkids
113
+ - bkusers
114
+ - bkip
115
+ - bklimit
116
+ - bkprop
117
+ list=categorymembers:
118
+ - cmtitle
119
+ - cmprop
120
+ - cmnamespace
121
+ - cmcontinue
122
+ - cmlimit
123
+ - cmsort
124
+ - cmdir
125
+ - cmstart
126
+ - cmend
127
+ - cmstartsortkey
128
+ - cmendsortkey
129
+ list=deletedrevs:
130
+ - drstart
131
+ - drend
132
+ - drdir
133
+ - drfrom
134
+ - drcontinue
135
+ - drunique
136
+ - druser
137
+ - drexcludeuser
138
+ - drnamespace
139
+ - drlimit
140
+ - drprop
141
+ list=embeddedin:
142
+ - eititle
143
+ - eicontinue
144
+ - einamespace
145
+ - eifilterredir
146
+ - eilimit
147
+ list=imageusage:
148
+ - iutitle
149
+ - iucontinue
150
+ - iunamespace
151
+ - iufilterredir
152
+ - iulimit
153
+ - iuredirect
154
+ list=logevents:
155
+ - leprop
156
+ - letype
157
+ - lestart
158
+ - leend
159
+ - ledir
160
+ - leuser
161
+ - letitle
162
+ - lelimit
163
+ list=recentchanges:
164
+ - rcstart
165
+ - rcend
166
+ - rcdir
167
+ - rcnamespace
168
+ - rcprop
169
+ - rctoken
170
+ - rcshow
171
+ - rclimit
172
+ - rctype
173
+ list=search:
174
+ - srsearch
175
+ - srnamespace
176
+ - srwhat
177
+ - srredirects
178
+ - sroffset
179
+ - srlimit
180
+ list=usercontribs:
181
+ - uclimit
182
+ - ucstart
183
+ - ucend
184
+ - uccontinue
185
+ - ucuser
186
+ - ucuserprefix
187
+ - ucdir
188
+ - ucnamespace
189
+ - ucprop
190
+ - ucshow
191
+ list=watchlist:
192
+ - wlallrev
193
+ - wlstart
194
+ - wlend
195
+ - wlnamespace
196
+ - wldir
197
+ - wllimit
198
+ - wlprop
199
+ - wlshow
200
+ list=watchlistraw:
201
+ - wrcontinue
202
+ - wrnamespace
203
+ - wrlimit
204
+ - wrprop
205
+ - wrshow
206
+ list=exturlusage:
207
+ - euprop
208
+ - euoffset
209
+ - euprotocol
210
+ - euquery
211
+ - eunamespace
212
+ - eulimit
213
+ list=users:
214
+ - usprop
215
+ - ususers
216
+ list=random:
217
+ - rnnamespace
218
+ - rnlimit
219
+ - rnredirect
220
+ list=protectedtitles:
221
+ - ptnamespace
222
+ - ptlevel
223
+ - ptlimit
224
+ - ptdir
225
+ - ptstart
226
+ - ptend
227
+ - ptprop
228
+ list=globalblocks:
229
+ - bgstart
230
+ - bgend
231
+ - bgdir
232
+ - bgids
233
+ - bgaddresses
234
+ - bgip
235
+ - bglimit
236
+ - bgprop
237
+ meta=siteinfo:
238
+ - siprop
239
+ - sifilteriw
240
+ - sishowalldb
241
+ meta=userinfo:
242
+ - uiprop
243
+ meta=allmessages:
244
+ - ammessages
245
+ - amfilter
246
+ - amlang
247
+ - amfrom