Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F34588770
multiedit-T288275.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
Aug 9 2021, 6:47 PM
2021-08-09 18:47:04 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
multiedit-T288275.rb
View Options
# coding: utf-8
require
'sunflower'
require
'io/console'
username
=
'Matma Rex'
print
'Password: '
password
=
STDIN
.
noecho
{
gets
.
strip
}
print
"
\n
"
items
=
{
'Q4592157'
=>
'MediaWiki:Discussiontools-emptystate-link-talkpages'
,
'Q4592334'
=>
'MediaWiki:Discussiontools-emptystate-link-userpage'
,
}
wikidata
=
Sunflower
.
new
'https://www.wikidata.org'
res
=
wikidata
.
API
'action=sitematrix&smlimit=5000&format=json&formatversion=2'
res_lang
=
res
[
'sitematrix'
]
.
select
{
|
k
,
v
|
k
=~
/^\d+$/
}
.
values
.
map
{
|
a
|
a
[
'site'
]
}
.
flatten
res_site
=
res
[
'sitematrix'
][
'specials'
]
dbname_to_url
=
(
res_lang
+
res_site
)
.
reject
{
|
a
|
a
[
'private'
]
||
a
[
'closed'
]
}
.
map
{
|
a
|
[
a
[
'dbname'
]
,
a
[
'url'
]
]
}
.
to_h
items
.
each
do
|
qid
,
pagetitle
|
resp
=
wikidata
.
API
"action=wbgetentities&ids=
#{
qid
}
&props=sitelinks&format=json&formatversion=2"
sitelinks
=
resp
[
'entities'
][
qid
][
'sitelinks'
]
# sitelinks.select!{|k, v| k == 'enwiki' }
sitelinks
.
each
do
|
dbname
,
data
|
puts
">>
#{
dbname
}
(
#{
dbname_to_url
[
dbname
]
}
)
#{
pagetitle
}
#{
data
[
'title'
]
}
"
s
=
Sunflower
.
new
dbname_to_url
[
dbname
]
s
.
login
username
,
password
page
=
s
.
page
pagetitle
page
.
text
=
data
[
'title'
]
s
.
summary
=
"Link to a local help page instead of mediawiki.org, based on [[wikidata:
#{
qid
}
]] ([[phab:T288275]])"
p
page
.
save
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9149009
Default Alt Text
multiedit-T288275.rb (1 KB)
Attached To
Mode
T288275: Create local overrides for talk page "Learn more" links in the new topic tool empty state
Attached
Detach File
Event Timeline
Log In to Comment