Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 

















Module:Interwiki extra/data






العربية
Aragonés
Беларуская
Беларуская (тарашкевіца)
Dansk
Español
فارسی
Français
/Hak-kâ-ngî
Ирон
 / Mìng-dĕ̤ng-nḡ


Português
Русский
کوردی
Українська
Tiếng Vit
 

Edit links
 









Module
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 

< Module:Interwiki extra

-- This module processes data from mw.site.interwikiMap for use with
-- [[Module:Interwiki extra]]. By loading the data with mw.loadData we ensure that
-- this is only done once per page parse.

local prefixes, urls, hosts = {}, {}, {}

local function makeCountedData(t, storeKey, counterKey, itemKey, item)
 t = t or {}
 t[storeKey] = t[storeKey] or {}
 t[storeKey][itemKey] = item
 t[counterKey] = t[counterKey] and t[counterKey] + 1 or 1
 return t
end

for prefix, data in pairs(mw.site.interwikiMap()) do
 local prefixData = {}
 for k, v in pairs(data) do
  prefixData[k] = v
 end
 prefixes[prefix] = prefixData

 local urlData = makeCountedData(
  urls[urlText],
  'prefixes',
  'nPrefixes',
  prefix,
  prefixData
 )
 urlData.url = prefixData.url
 urls[urlData.url] = urlData
end

for url, urlData in pairs(urls) do
 local urlObj = mw.uri.new(url) -- We can't output URI objects as they have metatables
 if not urlObj or not urlObj.host then
  error(string.format(
   "could not find a host in URL '%s'; " ..
   "please check your wiki's interwiki data",
   tostring(url)
  ))
 end
 local hostData = makeCountedData(
  hosts[urlObj.host],
  'urls',
  'nUrls',
  url,
  urlData
 )
 hostData.host = urlObj.host
 hosts[urlObj.host] = hostData
end

return {
 prefixes = prefixes,
 urls = urls,
 hosts = hosts
}

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Interwiki_extra/data&oldid=941913141"





This page was last edited on 21 February 2020, at 12:15 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki