Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F110493
find-gadgets-on-wikis.rb
matmarex (Bartosz Dziewoński)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
matmarex
Apr 9 2015, 3:16 PM
2015-04-09 15:16:02 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
find-gadgets-on-wikis.rb
View Options
# coding: utf-8
require
'sunflower'
require
'rest-client'
def
dbname_to_url
dbname
@data
||=
begin
data
=
File
.
readlines
(
'operations/mediawiki-config/wmf-config/InitialiseSettings.php'
)
.
drop_while
{
|
ln
|
ln
.
strip
!=
"'wgServer' => array("
}
.
drop
(
1
)
.
take_while
{
|
ln
|
ln
[
0
]
==
"
\t
"
||
ln
.
strip
==
''
}
.
select
{
|
ln
|
ln
.
include?
'=>'
}
.
map
{
|
ln
|
ln
.
sub
(
'//'
,
''
)
.
sub
(
%r~(//|#).+~
,
''
)
}
# strip comments and leading // in URLs
# meh
eval
"{
#{
data
.
join
"
\n
"
}
}"
end
if
@data
[
dbname
]
@data
[
dbname
]
else
family_dbname
=
@data
.
keys
.
find
{
|
k
|
dbname
.
end_with?
k
}
||
'default'
family_dbname_suffix
=
family_dbname
==
'default'
?
'wiki'
:
family_dbname
@data
[
family_dbname
].
sub
'$lang'
,
dbname
.
sub
(
/
#{
family_dbname_suffix
}
$/
,
''
)
.
sub
(
'_'
,
'-'
)
end
end
list
=
File
.
read
(
ARGV
[
0
]
)
.
force_encoding
(
'utf-8'
)
list
=
list
.
split
(
/\r?\n/
)
.
select
{
|
ln
|
ln
=~
/^\w+\s+MediaWiki:.+$/
}
list
=
list
.
map
{
|
ln
|
ln
.
split
(
/\s+/
,
2
)
}
list
.
uniq!
list
.
sort!
$stdout
.
sync
=
true
list
.
select!
{
|
(
_
,
pagetitle
)
|
pagetitle
=~
/^MediaWiki:Gadget-/
}
list
.
each
do
|
(
dbname
,
pagetitle
)
|
s
=
Sunflower
.
new
dbname_to_url
dbname
page
=
s
.
page
'MediaWiki:Gadgets-definition'
name
=
pagetitle
[
/^MediaWiki:Gadget-(.+)\.js$/
,
1
]
if
name
and
line
=
page
.
text
.
each_line
.
to_a
.
find
{
|
ln
|
ln
.
include?
name
}
puts
"
#{
dbname
}#{
line
.
include?
(
'default'
)
?
' (DEFAULT)'
:
''
}
"
puts
"https://
#{
dbname_to_url
dbname
}
/wiki/
#{
pagetitle
.
sub
' '
,
'_'
}
"
puts
""
end
sleep
3
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
107232
Default Alt Text
find-gadgets-on-wikis.rb (1 KB)
Attached To
Mode
T72499: Deploy SandboxLink extension to cluster and enable on wikis where it currently is a gadget
Attached
Detach File
Event Timeline
Log In to Comment