sunflower 0.4.5 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,339 +0,0 @@
1
- require 'orderedhash'
2
- require 'hpricot'
3
- require 'net/http'
4
- require 'sunflower-core.rb'
5
- require 'sunflower-listmaker.rb'
6
- include Net
7
-
8
- $datafile=File.open('aktual.txt','w')
9
- $datafile.sync=true
10
-
11
- id2team={}
12
- begin
13
- File.open('id2team.txt') do |f|
14
- id2team.replace Hash[*f.read.strip.split(/\r?\n|\t/)]
15
- end
16
- rescue
17
- end
18
-
19
- # comes from http://rubyforge.org/frs/?group_id=6257&release_id=36721
20
- module Levenshtein
21
- VERSION = "0.2.0"
22
-
23
- # Returns the Levenshtein distance as a number between 0.0 and
24
- # 1.0. It's basically the Levenshtein distance divided by the
25
- # length of the longest sequence.
26
-
27
- def self.normalized_distance(s1, s2, threshold=nil)
28
- s1, s2 = s2, s1 if s1.length > s2.length # s1 is the short one; s2 is the long one.
29
-
30
- if s2.length == 0
31
- 0.0 # Since s1.length < s2.length, s1 must be empty as well.
32
- else
33
- if threshold
34
- if d = self.distance(s1, s2, (threshold*s2.length+1).to_i)
35
- d.to_f/s2.length
36
- else
37
- nil
38
- end
39
- else
40
- self.distance(s1, s2).to_f/s2.length
41
- end
42
- end
43
- end
44
-
45
- # Returns the Levenshtein distance between two sequences.
46
- #
47
- # The two sequences can be two strings, two arrays, or two other
48
- # objects. Strings, arrays and arrays of strings are handled with
49
- # optimized (very fast) C code. All other sequences are handled
50
- # with generic (fast) C code.
51
- #
52
- # The sequences should respond to :length and :[] and all objects
53
- # in the sequences (as returned by []) should response to :==.
54
-
55
- def self.distance(s1, s2, threshold=nil)
56
- s1, s2 = s2, s1 if s1.length > s2.length # s1 is the short one; s2 is the long one.
57
-
58
- # Handle some basic circumstances.
59
-
60
- return 0 if s1 == s2
61
- return s2.length if s1.length == 0
62
-
63
- if threshold
64
- return nil if (s2.length-s1.length) >= threshold
65
-
66
- a1, a2 = nil, nil
67
- a1, a2 = s1, s2 if s1.respond_to?(:-) and s2.respond_to?(:-)
68
- a1, a2 = s1.scan(/./), s2.scan(/./) if s1.respond_to?(:scan) and s2.respond_to?(:scan)
69
-
70
- if a1 and a2
71
- return nil if (a1-a2).length >= threshold
72
- return nil if (a2-a1).length >= threshold
73
- end
74
- end
75
-
76
- distance_fast_or_slow(s1, s2, threshold)
77
- end
78
-
79
- def self.distance_fast_or_slow(s1, s2, threshold) # :nodoc:
80
- if respond_to?(:levenshtein_distance_fast)
81
- levenshtein_distance_fast(s1, s2, threshold) # Implemented in C.
82
- else
83
- levenshtein_distance_slow(s1, s2, threshold) # Implemented in Ruby.
84
- end
85
- end
86
-
87
- def self.levenshtein_distance_slow(s1, s2, threshold) # :nodoc:
88
- row = (0..s1.length).to_a
89
-
90
- 1.upto(s2.length) do |y|
91
- prow = row
92
- row = [y]
93
-
94
- 1.upto(s1.length) do |x|
95
- row[x] = [prow[x]+1, row[x-1]+1, prow[x-1]+(s1[x-1]==s2[y-1] ? 0 : 1)].min
96
- end
97
-
98
- # Stop analysing this sequence as soon as the best possible
99
- # result for this sequence is bigger than the best result so far.
100
- # (The minimum value in the next row will be equal to or greater
101
- # than the minimum value in this row.)
102
-
103
- return nil if threshold and row.min >= threshold
104
- end
105
-
106
- row[-1]
107
- end
108
- end
109
-
110
-
111
- def puts *arg
112
- arg.each{|str| $stdout.puts str; $datafile.puts str}
113
- end
114
-
115
- def saveData
116
- =begin
117
- File.open('aktualdata.txt','w'){|f|
118
- f.write "
119
- $notfound=#{$notfound.length}
120
- $same=#{$same.length}
121
- $diff=#{$diff.length}
122
- ----
123
- $notfound:
124
- # {$notfound.join "\n"}
125
- ----
126
- $same:
127
- # {$same.join "\n"}
128
- ----
129
- $diff:
130
- # {$diff.join "\n"}
131
- "
132
- }
133
- =end
134
- end
135
-
136
- def get(url)
137
- return HTTP.get(URI.parse(url))
138
- end
139
-
140
- def getPlayerData url
141
- r=get url
142
- r=~/<b>All time playing career<\/b>/
143
- r=$'
144
- r=~/<a name=games><\/a>/
145
- table=$`.strip
146
-
147
- h=Hpricot.parse table
148
- rows=h.search 'tr+tr'
149
-
150
- data={}
151
- rows.each do |r|
152
- if r.at('td')['colspan']==nil && (r.inner_html=~/No appearance data available/)==nil
153
- cells=r.search 'td'
154
- team=cells[0].search('font a')[0].inner_html.strip
155
- teamid=cells[0].search('font a')[0]['href'].sub(/\A.+?(\d+)\Z/, '\1')
156
- matches=cells[4].at('font').inner_html.split('(').map{|m| m.gsub(/[^0-9]/,'').to_i}
157
- matches=matches[0]+matches[1]
158
- goals=cells[5].at('font').inner_html.gsub(/[^0-9]/,'').to_i
159
-
160
- data[team]=[matches,goals,teamid]
161
- end
162
- end
163
- return data
164
- end
165
-
166
- def searchForPlayer text
167
- d=get "http://www.soccerbase.com/search.sd?search_string=#{CGI.escape text}&search_cat=players"
168
- d=~/window.location = "(http:[^"]+)"/
169
-
170
- return $1
171
- end
172
-
173
- $edits=0
174
- $summary='aktualizacja danych o meczach piłkarza'
175
-
176
- puts 'Making list...'
177
- s=Sunflower.new('pl.wikipedia.org')
178
- s.login
179
- enw=Sunflower.new('en.wikipedia.org')
180
- enw.login
181
-
182
- # list=(
183
- # s.makeList('category-r', 'Kategoria:Piłkarze Aston Villa F.C.')+
184
- # s.makeList('category-r', 'Kategoria:Piłkarze Chelsea F.C.')+
185
- # s.makeList('category-r', 'Kategoria:Piłkarze Liverpool F.C.')
186
- # ).uniq
187
- # list=(
188
- # s.makeList('category-r', 'Kategoria:Piłkarze angielskich klubów')+
189
- # s.makeList('category-r', 'Kategoria:Piłkarze walijskich klubów')
190
- # ).uniq
191
-
192
- # list.delete_if{|i| i=~/^Kategoria:/}
193
-
194
- # File.open('lista-pilkarze.txt','w').write list.join("\n")
195
- # list=File.open('lista-pilkarze.txt').read.split(/\r?\n/)
196
- list=['Wikipedysta:Matma Rex/brudnopis']
197
-
198
- puts 'Done!'
199
- puts ''
200
-
201
- $notfound=[]
202
- $same=[]
203
- $diff=[]
204
-
205
- list.each_with_index do |art, i|
206
- exit if $edits>4
207
-
208
- # finding data
209
- puts "* [[#{art}]]"
210
- pPl=Page.new(art, 'pl')
211
- pPl.read=~/\[\[en:([^\]]+)\]\]/
212
- if $1
213
- artEn=$1
214
- puts "** Interwiki-en: [[:en:#{artEn}]]"
215
- else
216
- artEn=art
217
- puts "** No interwiki; guessing [[:en:#{art}]]"
218
- end
219
-
220
- pPl.read=~/\{\{soccerbase.*?(\d+).*?\}\}|soccerbase\.com\/players_details\.sd\?playerid=(\d+)/i
221
- if $1||$2
222
- soccid=$1||$2
223
- url="http://www.soccerbase.com/players_details.sd?playerid=#{soccid}"
224
- puts '** Found id on plwiki'
225
- else
226
- pEn=Page.new(art, 'en')
227
- pEn.read=~/\{\{soccerbase.*?(\d+).*?\}\}|soccerbase\.com\/players_details\.sd\?playerid=(\d+)/i
228
- if $1||$2
229
- soccid=$1||$2
230
- url="http://www.soccerbase.com/players_details.sd?playerid=#{soccid}"
231
- puts '** Found id on enwiki'
232
- else
233
- url=searchForPlayer(art)||searchForPlayer(artEn)
234
- end
235
- end
236
-
237
- if url==nil
238
- puts '** Not found.'
239
- $notfound<<art
240
- else
241
- data=getPlayerData url
242
- puts "** URL: #{url}"
243
- unless data.empty?
244
- puts "** Found info on soccerbase."
245
- else
246
- puts '** Found, but no data.'
247
- $notfound<<art
248
- end
249
- end
250
-
251
- pPl.read =~ /występy\(gole\)\s*=(.+)/
252
- if $1==nil
253
- puts '** Wiki: error. No infobox?'
254
- else
255
- a=$1.split(/\s*<br.*?>\s*/)[-1].strip
256
- a=~/(\d+)\s*\((\d+)\)/
257
- matchesW, goalsW = $1.to_i, $2.to_i
258
- puts "** Wiki info: #{matchesW} matches, #{goalsW} goals."
259
- end
260
-
261
- saveData if i%30==0 && i!=0
262
-
263
- # $change=File.open('changelist.txt','w')
264
- # $change.sync=true
265
-
266
- # editing
267
- if data
268
- #$change.puts "* [[#{art}]] - #{matchesW}/#{goalsW} -> #{matches}/#{goals}"
269
-
270
- pPl.text=~/(kluby\s*=\s*)([^\|]+)(\s*\|)/
271
- kluby=$2
272
- pPl.text=~/(występy\(gole\)\s*=\s*)([^\|]+)(\s*\|)/
273
- wystepygole=$2
274
-
275
- resolve={}
276
- kluby=kluby.split(/<\/?br[^>]*>/).map do |i|
277
- short=i.strip.gsub(/\[\[(?:[^\]\|]+\||)([^\]\|]+)\]\]/,'\1').gsub(/→|\(wyp\.\)/,'').strip
278
- resolve[short]=i.strip
279
- short
280
- end
281
- wystepygole=wystepygole.split(/<\/?br[^>]*?>/).map{|i| i.strip}
282
- wystepygole.delete_if{|i| i==''}
283
- kluby.delete_if{|i| i==''}
284
-
285
- wystepygole.pop while wystepygole.length>kluby.length
286
- wystepygole.push [0,0] while wystepygole.length<kluby.length
287
-
288
- wikidata=OrderedHash.new
289
- kluby.each_index do |i|
290
- wystepygole[i]=~/(\d+)\s*\((\d+)\)/
291
- wikidata[kluby[i]]=[$1.to_i, $2.to_i]
292
- end
293
-
294
- # puts data.inspect
295
- # puts wikidata.inspect
296
-
297
- data.each_pair do |scbclub, scb, teamid|
298
- min=[999, 'null']
299
- wikidata.each_pair do |wikiclub, wiki|
300
- if wikiclub.index scbclub || scbclub.index wikiclub
301
- min=[0, wikiclub]
302
- break
303
- end
304
- if wikiclub.index id2team[teamid] || id2team[teamid].index wikiclub
305
- min=[0, wikiclub]
306
- break
307
- end
308
-
309
- d=Levenshtein.distance(scbclub, wikiclub)
310
- min=[d, wikiclub] if d<min[0]
311
-
312
- d=Levenshtein.distance(id2team[teamid], wikiclub)
313
- min=[d, wikiclub] if d<min[0]
314
- end
315
- club=min[1]
316
-
317
- wikidata[club]=data[scbclub]
318
- end
319
-
320
- infoboxwystepygole=[]
321
- infoboxkluby=[]
322
-
323
- wikidata.each do |club, info|
324
- infoboxkluby<<resolve[club]
325
- infoboxwystepygole<<"#{info[0]} (#{info[1]})"
326
- end
327
-
328
- infoboxkluby=infoboxkluby.join('<br />')
329
- infoboxwystepygole=infoboxwystepygole.join('<br />')
330
-
331
- pPl.text=pPl.text.sub(/(występy\(gole\)\s*=\s*)([^\|]+?)(\s*\|)/){$1+infoboxwystepygole+$3}
332
- pPl.text=pPl.text.sub(/(kluby\s*=\s*)([^\|]+?)(\s*\|)/){$1+infoboxkluby+$3}
333
- pPl.text=pPl.text.sub(/(data1\s*=\s*)([^\|]+?)(\s*\|)/, '\1{{subst:CURRENTDAY}} {{subst:CURRENTMONTHNAMEGEN}} {{subst:CURRENTYEAR}}\3')
334
-
335
- $edits+=1
336
- pPl.save
337
- end
338
- end
339
-
@@ -1,36 +0,0 @@
1
- #!/usr/bin/ruby
2
- print "Content-type: text/html; charset=utf8\n\r\n"
3
- $stderr=$stdout
4
-
5
- require 'sunflower-core.rb'
6
-
7
- s=Sunflower.new('pl.wikipedia.org')
8
- s.log=false
9
- s.login
10
- cgi=CGI.new
11
-
12
-
13
- puts ''
14
- puts '<p>Get list for: <form action="author-list.rb" method="GET"><input name="title"> <input type="submit" value="Go!"></form></p>'
15
-
16
- if cgi['title'] && cgi['title']!=''
17
- puts '<p>List of authors of '+cgi['title']+':</p>'
18
-
19
- users=[]
20
- hash=s.API("action=query&prop=revisions&titles=#{CGI.escape(cgi['title'])}&rvprop=user&rvlimit=5000")
21
- hash['query']['pages'].values[0]['revisions'].each do |r|
22
- users<<r['user']
23
- end
24
- while hash['query-continue']
25
- hash=s.API("action=query&prop=revisions&titles=#{CGI.escape(cgi['title'])}&rvprop=user&rvlimit=5000&rvstartid=#{hash['query-continue']['revisions']['rvstartid']}")
26
- hash['query']['pages'].values[0]['revisions'].each do |r|
27
- users<<r['user']
28
- end
29
- end
30
-
31
- users.uniq!
32
-
33
-
34
- puts '<ul><li>'+users.join('</li><li>')+'</li></ul>'
35
- end
36
-
@@ -1,42 +0,0 @@
1
- require 'sunflower-commontasks.rb'
2
- require 'sunflower-listmaker.rb'
3
-
4
- image='Plik:Obiekt zabytkowy znak.svg'
5
-
6
- # EDIT WIKI URL BELOW
7
- s=Sunflower.new('pl.wikipedia.org')
8
-
9
- print "Logging in to #{s.wikiURL}... "
10
- # EDIT USERNAME AND PASSWORD BELOW
11
- s.login
12
- print "done!\n"
13
-
14
- print "Reading articles list... "
15
- # EDIT FILENAME BELOW
16
- list=s.make_list('image', image).sort
17
- print "done!\n\n"
18
-
19
- # EDIT SUMMARY BELOW
20
- $summary='podmiana grafiki, [[WP:SK]]'
21
-
22
- list.each do |title|
23
- print "Reading page #{title}... "
24
- page=Page.get(title)
25
- print "done.\n"
26
- print "Modifying... "
27
-
28
- page.codeCleanup
29
-
30
- page.text.gsub!(/\[\[#{Regexp.escape image} *\|(?:left\||)[1-6]\dpx(?:\|left|)(\|[^\]\|]+|)\]\]( *(?:\r?\n|) *|)/) do
31
- next if $~[0].index('thumb') || $~[0].index('right')
32
- "[[Plik:Obiekt zabytkowy.svg|20px#{$1}]] "
33
- end
34
-
35
- print "done.\n"
36
- print "Saving... "
37
- page.save unless page.orig_text.downcase==page.text.downcase
38
- print "done!\n\n"
39
- end
40
-
41
- print 'Finished! Press any key to close.'
42
- gets
@@ -1,102 +0,0 @@
1
- require 'sunflower-commontasks.rb'
2
- require 'sunflower-listmaker.rb'
3
-
4
- # EDIT WIKI URL BELOW
5
- s=Sunflower.new
6
-
7
- print "Logging in to #{s.wikiURL}... "
8
- # EDIT USERNAME AND PASSWORD BELOW
9
- s.login
10
- print "done!\n"
11
-
12
- print "Reading articles list... "
13
- # EDIT FILENAME BELOW
14
- list=s.make_list('file', 'multirefs.txt')
15
- print "done (#{list.length} to do)!\n\n"
16
-
17
- # EDIT SUMMARY BELOW
18
- $summary='poprawa powtarzających się przypisów, [[WP:SK]]'
19
-
20
- list.each do |title|
21
- $refcount=0
22
-
23
- print "Reading page #{title}... "
24
- #page=Page.get(title)
25
- page=Page.new
26
- page.text=<<EOF
27
- '''Abraham von Dohna''' (ur. [[11 grudnia]] [[1561]]r., zm. [[1 maja]] [[1613]] r. we [[Wrocław]]iu) – władca [[Syców|sycowskiego]] [[wolne państwo stanowe|wolnego państwa stanowego]] od [[1592]]<ref>A. i A. Galasowie, ''Dzieje Śląska w datach'', wyd. Rzeka, Wrocław 2001, s. 353.</ref>
28
-
29
- ==Rodzina i pochodzenie==
30
- Pochodził z [[Prusy|pruskiego]] [[Ród Dohnów|rodu von Dohna]], osiadłego na [[Śląsk]]u w [[XIII]] w. Był synem Abrahama von Dohna seniora, który był [[starosta|starostą]] [[Księstwo głogowskie|głogowskim]]. W [[1587]] r. poślubił Eleonorę von Saurma-Jeltsch.<ref>T. Kulak, W. Mrozowicz, ''Syców i okolice od czasów najdawniejszych po współczesność'', s. 47.</ref>
31
-
32
- ==Kariera polityczna==
33
- Był aktywny politycznie. Wcześnie rozpoczął karierę na [[dwór|dworze cesarskim]] uczestnicząc w licznych misjach dyplomatycznych na terenie [[Polska|Polski]] i [[Rosja|Rosji]], gdzie zabiegał o pogodzenie obu zwaśnionych państw w obliczu zagrożenia ze strony [[Imperium Osmańskie]]go oraz do [[Hiszpania|Hiszpanii]]. W [[1596]] r. został mianowany [[wójt|wójtem krajowym]] [[Łużyce|Łużyc Górnych]].<ref>''Ibidem'', s. 47.</ref>
34
-
35
- ==Wolny pan stanowy Sycowa==
36
- Ożenek z bogatą Eleonorą von Saurma-Jeltsch zapewnił mu znaczne fundusze na zakup sycowskiego wolnego państwa stanowego od zadłużonego [[Georg Wilhelm von Braun|Jerzego Wilhelma von Braun]] w [[1592]] r.<ref>''Ibidem'', s. 47.</ref>
37
-
38
- Udało mu się zakończyć wieloletni spór o [[Międzybórz]] i okolice, który zakończył się jego utrata na rzecz [[Księstwo oleśnickie|księstwa oleśnickiego]]. W latach [[1604]]-[[1605|05]] za kwotę 50 tys. talarów nabył majątek [[Goszcz]]. Uregulował kwestie następstwa tronu w sycowskim wolnym państwie stanowym po swojej śmierci poprzez ustanowienie zasady [[primogenitura|primogenitury]], która została zatwierdzona przez [[cesarz]]a [[Rudolf II Habsburg|Rudolfa II]] w [[1600]] r.<ref>''Ibidem'', s. 48.</ref>
39
-
40
- W [[1594]] r. rozpoczął budowę nowego [[Zamek w Sycowie|zamku]] w [[Syców|Sycowie]] razem z parkiem, która zastąpiła dotychczasowy zamek, który częściowo znajdował się w ruinie po oblężeniu za panowania [[Joachim I von Maltzan|Joachima von Maltzana]]. Ukończoną ją w [[1608]] r.
41
-
42
- ===Sprawy religijne===
43
- W [[1592]] r. wydał przywilej gwarantujący na terenie swojego państwa wolność religijna i uprawnienie dla [[Protestantyzm|protestantów]]. Chociaż wychował się w duchu protestantyzmu wyraźnie sprzyjał [[Katolicyzm|katolikom]], odbierając w [[1601]] r. sycowskim protestantom [[Kościół św. Piotra i Pawła w Sycowie|kościół św. Piotra i Pawła]], pozostawiając w ich rękach mniejszy kościół p.w. św. Michała.<ref>''Ibidem'', s. 47.</ref>
44
-
45
- ===Sprawy gospodarcze i poszerzenie granic władztwa===
46
- Podczas swoich rządów wykazał się dużą dbałością o zarządzanie swoimi dobrami. W [[1592]] r. dokupił [[Dziadowa Kłoda|Dziadową Kłodę]], a cztery lata później przyłączył dwie części [[Trębaczów|Trębaczowa]], sprzedając przy okazji [[Komorów]].<ref>''Ibidem'', s. 47.</ref> Od miasta [[Syców|Sycowa]] odkupił prawo wyszynku piwa i wina oraz kilka stawów rybnych. Na terenie swoich włości zakładał nowe [[folwark]]i oraz bażanciarnię. Zaradził uprawę [[winorośl]]i, [[chmiel]]u, owoców i warzyw. Rozwijała się gospodarka leśna i rybno-stawowa.<ref>''Ibidem'', s. 48.</ref>
47
-
48
- ==Ostatnie lata życia i śmierć==
49
- Pod koniec życia z powodu rozwijającego się [[artretyzm]]u zrezygnował z urzędu wójta Górnych Łużyc ([[1612]] r.) Niedługo potem,[[1 maja]] [[1613]] r. zmarł we [[Wrocław]]iu, zaś jego ciało zostało przewiezione do Sycowa, gdzie został pochowany [[28 czerwca]] w zbudowanej na jego prośbę nowej krypcie rodzinnej, która stanęła pod północna kaplicą boczną kościoła parafialnego św. Piotra i św. Pawła.<ref>''Ibidem'', s. 48.</ref>
50
-
51
- == Bibliografia ==
52
- * [[Teresa Kulak|T. Kulak]], [[Wojciech Mrozowicz|W. Mrozowicz]], ''Syców i okolice od czasów najdawniejszych po współczesność'', wyd. Oficyna wydawnicza ''Atut'', Wrocław-Syców 2000.
53
- * J. Franzkowski, ''Geschichte der freien Standesherrschaft, der Stadt und des landrätlichen Kreises Gross Wartenberg'', Gross Wartenberg 1912.
54
-
55
- == Przypisy==
56
- <references/>
57
-
58
- {{Poprzednik Następca|urząd=[[Plik:POL Syców COA.svg|40px]] [[Syców|Wolny pan stanowy Sycowa]] [[Plik:POL Syców COA.svg|40px]]|lata=[[1592]]- [[1613]]|pop=[[Georg Wilhelm von Braun]]|nast=[[Karl Hannibal von Dohna]]}}
59
-
60
-
61
- [[Kategoria:Urodzeni w 1561]]
62
- [[Kategoria:Zmarli w 1613]]
63
-
64
- [[de:Abraham von Dohna]]
65
- EOF
66
- print "done.\n"
67
- print "Modifying... "
68
-
69
- page.replace("\r\n", "\n")
70
-
71
- 30.times do
72
- page.text=page.text.sub( # that's ugly, but simpliest
73
- /<ref(?: name="([^"]+|)"|)>(.+?)<\/ref>([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?(?:([\s\S]+?)<ref(?: name="[^"]+"|)>\2<\/ref>)?/
74
- ) do
75
- # $1 = name pierwszego refa; $2 = tekst refów; $3..n = teksty między refami
76
- name=($1.to_s!='' ? $1.to_s : 'auto-'+($refcount=$refcount+1).to_s)
77
- res='<ref name="'+name+'">'+$2+'</ref>'+$3+'<ref name="'+name+'" />'
78
-
79
- i=4
80
- while(! eval("$#{i}").nil?)
81
- res+=eval("$#{i}")+'<ref name="'+name+'" />'
82
- i=i+1
83
- end
84
-
85
- res
86
- end
87
- end
88
-
89
- page.codeCleanup
90
-
91
-
92
-
93
- print "done.\n"
94
- print "Saving... "
95
- #page.save
96
- page.dumpto 'reftest.txt'
97
- gets
98
- print "done!\n\n"
99
- end
100
-
101
- print 'Finished! Press any key to close.'
102
- gets
data/scripts/insight.rb DELETED
@@ -1,133 +0,0 @@
1
- require 'net/http'
2
- require 'uri'
3
- require 'cgi'
4
- include Net
5
-
6
- require 'sunflower-core.rb'
7
- s=Sunflower.new
8
- s.login
9
-
10
- przejrzane=Page.new 'Wikipedysta:PMG/przejrzane'
11
- t=przejrzane.read
12
-
13
-
14
- begin
15
- f=File.open('puredata.txt','r')
16
- pd1=f.read.split(/\r?\n/)
17
- f.close
18
- rescue
19
- pd1=[]
20
- end
21
-
22
- pdv=[]
23
- pdn=[]
24
- pd1.each do |i|
25
- n=i.split('|')
26
- n[1]='' if n[1]==nil
27
-
28
- pdn<<n[0]
29
- pdv<<n[1]
30
- end
31
-
32
- f=File.open('puredata.txt','w')
33
-
34
- $counter=0
35
- nt=t.sub(/(\{\| class="wikitable sortable"(?:\s*!.+)+)\s*\|-([\s\S]+?)(\|\})/){
36
- nl="\n" #shorten
37
- before=$1
38
- after=$3
39
-
40
- data=$2.split("|-\n|")
41
- data=data.map{|i|
42
- i.strip.split(/\s*\|\s*/)
43
- }
44
-
45
- data2=[]
46
- for d in data
47
- d.shift if d[0].strip==''
48
-
49
- # load puredata, if possible, and skip the rest
50
- # if pd[d[-1]]!=nil #&& pd[d[-1]]!=''
51
- i=pdn.index(d[-1])
52
- if i!=nil && pdv[pdn.index(d[-1])]!=nil
53
- puts d[-1]+': (datafile)'
54
- puts ' '+pdv[i]
55
-
56
- last=d[-1]
57
- d[-1]=pdv[i]
58
- d<<last
59
-
60
- data2<<d
61
- $counter=0
62
-
63
- #rewrite puredata
64
- f.write(d[-1]+'|'+pdv[i]+nl)
65
- f.flush
66
-
67
- next #skip the rest of loop
68
- end
69
-
70
- url=d[0].sub(/^\*+ \[(http:[^ ]+) [^\]]+\]$/,'\1')
71
-
72
- #puts url
73
- puts d[-1]+':' if $counter==0
74
-
75
- begin
76
- res=HTTP.get(URI.parse(url.sub(/&category=([^&]+)/){'&category='+CGI.escape($1)}))
77
-
78
- f2=File.open('last.txt','w')
79
- f2.write(res)
80
- f2.close
81
-
82
- res=~/Znaleziono (\d+) nieprzejrza/
83
- num=$1
84
- rescue Timeout::Error
85
- num=nil
86
- $counter+=3 #repeat only once
87
- end
88
-
89
- if num==nil
90
- $counter+=1
91
- if $counter<5
92
- puts 'Retrying...'
93
- redo
94
- else
95
- num=''
96
- end
97
- end
98
-
99
- puts ' '+num
100
-
101
- last=d[-1]
102
- d[-1]=num
103
- d<<last
104
-
105
- data2<<d
106
- $counter=0
107
-
108
- #write puredata to file
109
- f.write(d[-1]+'|'+num+nl)
110
- f.flush
111
- end
112
-
113
- data3=nl
114
- for d in data2
115
- data3+='|-'+nl+'|'+d.join(nl+'|')+nl
116
- end
117
-
118
- months=%w(zero stycznia lutego marca kwietnia maja czerwca lipca sierpnia września października listopada grudnia)
119
- d=Date.parse(Time.now.to_s)
120
-
121
- before.sub(/(!Link do kategorii)/,'!'+d.day.to_s+' '+months[d.month]+' '+d.year.to_s+nl+'\1')+data3+after #print it out
122
- }
123
-
124
-
125
- f.close #puredata.txt
126
-
127
- f=File.open('data2.txt','w')
128
- f.write(nt)
129
- f.close
130
-
131
- $summary='aktualizacja'
132
- przejrzane.write nt
133
- przejrzane.save
@@ -1,32 +0,0 @@
1
- require 'hpricot'
2
- require 'net/http'
3
- include Net
4
-
5
- def get(url)
6
- return HTTP.get(URI.parse(url))
7
- end
8
-
9
- f=File.open('id2team.txt','w')
10
- f.sync=true
11
-
12
- ((1..4).to_a + (12..15).to_a).each do |i|
13
- page=get("http://www.soccerbase.com/teams.sd?competitionid=#{i}")
14
- h=Hpricot.parse page
15
-
16
- h2=Hpricot.parse h.search('table table table')[2].inner_html
17
-
18
- h2.search('tr').each do |tr|
19
- begin
20
- if tr.at('b').inner_html.strip=='Team'||tr.inner_html.index('<script')||tr.inner_html.index('<img')
21
- next
22
- end
23
- rescue Exception
24
- end
25
- id=tr.at('a')['href'].sub(/\A.+?(\d+)\Z/, '\1')
26
- team=tr.at('a').inner_html.strip
27
-
28
- f.puts "#{id}\t#{team}"
29
- end
30
-
31
-
32
- end