<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AInterwiki_extra</id>
	<title>Module:Interwiki extra - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AInterwiki_extra"/>
	<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Interwiki_extra&amp;action=history"/>
	<updated>2026-04-12T21:39:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://moasspedia.org/w/index.php?title=Module:Interwiki_extra&amp;diff=2114&amp;oldid=prev</id>
		<title>Wikipedia&gt;Tamzin: add support for numbered arg. checked with search of ```hastemplate:&quot;Interwiki extra&quot; insource:/\{\{[Ii]nterwiki[_ ]extra\s*\|[^=|]+\}\}/```, will not break anything, and indeed will save one page where someone used a numbered arg</title>
		<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Interwiki_extra&amp;diff=2114&amp;oldid=prev"/>
		<updated>2022-03-19T17:05:10Z</updated>

		<summary type="html">&lt;p&gt;add support for numbered arg. checked with search of ```hastemplate:&amp;quot;Interwiki extra&amp;quot; insource:/\{\{[Ii]nterwiki[_ ]extra\s*\|[^=|]+\}\}/```, will not break anything, and indeed will save one page where someone used a numbered arg&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module provides functions and objects for dealing with interwiki links.&lt;br /&gt;
&lt;br /&gt;
local checkType = require(&amp;#039;libraryUtil&amp;#039;).checkType&lt;br /&gt;
local interwikiData = mw.loadData(&amp;#039;Module:Interwiki extra/data&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Prefix class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local Prefix = {}&lt;br /&gt;
Prefix.__index = Prefix&lt;br /&gt;
&lt;br /&gt;
function Prefix.new(code)&lt;br /&gt;
	checkType(&amp;#039;Prefix.new&amp;#039;, 1, code, &amp;#039;string&amp;#039;)&lt;br /&gt;
	local obj = setmetatable({}, Prefix)&lt;br /&gt;
	local data = interwikiData.prefixes[code]&lt;br /&gt;
	if not data then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(data) do&lt;br /&gt;
		obj[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	return obj&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Prefix:makeUrl(page)&lt;br /&gt;
	checkType(&amp;#039;makeUrl&amp;#039;, 1, page, &amp;#039;string&amp;#039;)&lt;br /&gt;
	-- In MediaWiki, interlanguage links are wiki-encoded (spaces are encoded&lt;br /&gt;
	-- as underscores), even if the site is not a wiki and underscores don&amp;#039;t&lt;br /&gt;
	-- make sense. So we do the same here.&lt;br /&gt;
	page = mw.uri.encode(page, &amp;#039;WIKI&amp;#039;)&lt;br /&gt;
	return mw.message.newRawMessage(self.url, page):plain()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Prefix:isValidUrl(url)&lt;br /&gt;
	checkType(&amp;#039;isValidUrl&amp;#039;, 1, url, &amp;#039;string&amp;#039;)&lt;br /&gt;
	local obj1 = mw.uri.new(self.url)&lt;br /&gt;
	local obj2 = mw.uri.new(url)&lt;br /&gt;
	if not obj2 then&lt;br /&gt;
		return false&lt;br /&gt;
	elseif obj1.protocol and obj1.protocol ~= obj2.protocol then&lt;br /&gt;
		-- Protocols only have to match if the prefix URL isn&amp;#039;t protocol-relative&lt;br /&gt;
		return false&lt;br /&gt;
	elseif obj1.host ~= obj2.host then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	local function makePathQuery(obj)&lt;br /&gt;
		return obj.path .. (obj.queryString or &amp;#039;&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local pathQuery1 = makePathQuery(obj1)&lt;br /&gt;
	local pathQuery2 = makePathQuery(obj2)&lt;br /&gt;
	-- Turn pathQuery1 into a string pattern by escaping all punctuation, then&lt;br /&gt;
	-- replacing the &amp;quot;$1&amp;quot; parameter (which will have become &amp;quot;%$1&amp;quot;) with &amp;quot;.*&amp;quot;&lt;br /&gt;
	local pattern = pathQuery1:gsub(&amp;#039;%p&amp;#039;, &amp;#039;%%%0&amp;#039;):gsub(&amp;#039;%%$1&amp;#039;, &amp;#039;.*&amp;#039;)&lt;br /&gt;
	pattern = &amp;#039;^&amp;#039; .. pattern .. &amp;#039;$&amp;#039;&lt;br /&gt;
	return pathQuery2:find(pattern) ~= nil&lt;br /&gt;
end&lt;br /&gt;
local langcode = {&lt;br /&gt;
	[&amp;#039;bat_smg&amp;#039;]      = &amp;#039;bat-smg&amp;#039;,&lt;br /&gt;
	[&amp;#039;be_x_old&amp;#039;]     = &amp;#039;be-x-old&amp;#039;,&lt;br /&gt;
	[&amp;#039;cbk_zam&amp;#039;]      = &amp;#039;cbk-zam&amp;#039;,&lt;br /&gt;
	[&amp;#039;fiu_vro&amp;#039;]      = &amp;#039;fiu-vro&amp;#039;,&lt;br /&gt;
	[&amp;#039;map_bms&amp;#039;]      = &amp;#039;map-bms&amp;#039;,&lt;br /&gt;
	[&amp;#039;nds_nl&amp;#039;]       = &amp;#039;nds-nl&amp;#039;,&lt;br /&gt;
	[&amp;#039;roa_rup&amp;#039;]      = &amp;#039;roa-rup&amp;#039;,&lt;br /&gt;
	[&amp;#039;roa_tara&amp;#039;]     = &amp;#039;roa-tara&amp;#039;,&lt;br /&gt;
	[&amp;#039;zh_classical&amp;#039;] = &amp;#039;zh-classical&amp;#039;,&lt;br /&gt;
	[&amp;#039;zh_min_nan&amp;#039;]   = &amp;#039;zh-min-nan&amp;#039;, -- a comma have to be added when new lines are added&lt;br /&gt;
	[&amp;#039;zh_yue&amp;#039;]       = &amp;#039;zh-yue&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
local siteexcludes = {&lt;br /&gt;
	[&amp;#039;metawiki&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;mediawikiwiki&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;commonswiki&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;wikidatawiki&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;specieswiki&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;enwiki&amp;#039;] = true&lt;br /&gt;
}&lt;br /&gt;
function Prefix.interwiki(frame)&lt;br /&gt;
	local s = setmetatable({}, {__index = table})&lt;br /&gt;
	local entity = mw.wikibase.getEntity()&lt;br /&gt;
	-- use qid parameter if provided, otherwise follow P460&lt;br /&gt;
	local qid = frame.args.qid or frame:getParent().args.qid or frame.args[1] or frame:getParent().args[1] or &amp;#039;&amp;#039;&lt;br /&gt;
	if not mw.wikibase.isValidEntityId(qid) then&lt;br /&gt;
		qid = nil&lt;br /&gt;
		-- access the first valid value of P460&lt;br /&gt;
		for i, statement in pairs(entity:getBestStatements[[P460]]) do&lt;br /&gt;
			if statement.mainsnak.snaktype == &amp;#039;value&amp;#039; then&lt;br /&gt;
				qid = statement.mainsnak.datavalue.value[&amp;#039;id&amp;#039;]&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if qid then&lt;br /&gt;
		local entity2 = mw.wikibase.getEntity(qid)&lt;br /&gt;
		if entity2 and entity2.sitelinks then&lt;br /&gt;
			for i, j in pairs(entity2.sitelinks) do&lt;br /&gt;
				-- exclude the own wiki and some wikiprojects that are not Wikipedia, even if their code ends with &amp;#039;wiki&amp;#039;&lt;br /&gt;
				if not siteexcludes[j.site] then&lt;br /&gt;
					-- exclude Wikisource, Wikiquote, Wikivoyage etc&lt;br /&gt;
					if mw.ustring.sub( j.site, mw.ustring.len(j.site) - 3 ) == &amp;#039;wiki&amp;#039; then&lt;br /&gt;
						local lang = langcode[mw.ustring.sub( j.site, 1, mw.ustring.len(j.site) - 4 )] or mw.ustring.sub( j.site, 1, mw.ustring.len(j.site) - 4 )&lt;br /&gt;
						-- exclude interwiki to projects that already have sitelinks in the present page&lt;br /&gt;
						if (entity and not entity.sitelinks[j.site]) or not entity then&lt;br /&gt;
							-- put together a interwiki-link to other projects&lt;br /&gt;
							s:insert( &amp;#039;[[&amp;#039; .. lang .. &amp;#039;:&amp;#039; .. j.title .. &amp;#039;]]&amp;#039; )&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #s &amp;gt; 0 then &lt;br /&gt;
		s:insert(&amp;quot;[[Category:Module:Interwiki extra: additional interwiki links]]&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return s:concat(&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return Prefix&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;Tamzin</name></author>
	</entry>
</feed>