<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.digitalcellulose.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AInterwiki</id>
	<title>Module:Interwiki - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.digitalcellulose.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AInterwiki"/>
	<link rel="alternate" type="text/html" href="http://www.digitalcellulose.com/wiki/index.php?title=Module:Interwiki&amp;action=history"/>
	<updated>2026-05-23T07:25:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://www.digitalcellulose.com/wiki/index.php?title=Module:Interwiki&amp;diff=152267&amp;oldid=prev</id>
		<title>Adminsuzy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.digitalcellulose.com/wiki/index.php?title=Module:Interwiki&amp;diff=152267&amp;oldid=prev"/>
		<updated>2020-09-13T20:46:17Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 20:46, 13 September 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Adminsuzy</name></author>
		
	</entry>
	<entry>
		<id>http://www.digitalcellulose.com/wiki/index.php?title=Module:Interwiki&amp;diff=152266&amp;oldid=prev</id>
		<title>Imported&gt;Mike Peel: + P1420</title>
		<link rel="alternate" type="text/html" href="http://www.digitalcellulose.com/wiki/index.php?title=Module:Interwiki&amp;diff=152266&amp;oldid=prev"/>
		<updated>2020-05-15T18:08:25Z</updated>

		<summary type="html">&lt;p&gt;+ P1420&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
  __  __           _       _        ___       _                     _ _    _  &lt;br /&gt;
 |  \/  | ___   __| |_   _| | ___ _|_ _|_ __ | |_ ___ _ ____      _(_) | _(_) &lt;br /&gt;
 | |\/| |/ _ \ / _` | | | | |/ _ (_)| || '_ \| __/ _ \ '__\ \ /\ / / | |/ / | &lt;br /&gt;
 | |  | | (_) | (_| | |_| | |  __/_ | || | | | ||  __/ |   \ V  V /| |   &amp;lt;| | &lt;br /&gt;
 |_|  |_|\___/ \__,_|\__,_|_|\___(_)___|_| |_|\__\___|_|    \_/\_/ |_|_|\_\_| &lt;br /&gt;
                                                                              &lt;br /&gt;
History:&lt;br /&gt;
 * Originally written by user:Innocent_bystander ( https://sv.wikipedia.org/wiki/Modul:Interwiki )&lt;br /&gt;
 * Forked and modified by user:Jarekt&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Properties to use as redirects &lt;br /&gt;
local redirectProperties = { &lt;br /&gt;
	'P301', -- &amp;quot;category's main topic&amp;quot;&lt;br /&gt;
	'P460', -- &amp;quot;said to be the same as&amp;quot;&lt;br /&gt;
	'P1420', -- &amp;quot;taxon synonym&amp;quot;&lt;br /&gt;
	'P1753' -- &amp;quot;list related to category&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- =======================================&lt;br /&gt;
-- === Local Functions ===================&lt;br /&gt;
-- =======================================&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------------&lt;br /&gt;
-- Based on frame structure create &amp;quot;args&amp;quot; table with all the input parameters.&lt;br /&gt;
-- All inputs are non case-sensitive. Input values are trimmed and empty string a &lt;br /&gt;
-- re converted to nils. &lt;br /&gt;
local function getArgs(frame)&lt;br /&gt;
	local function normalize_input_args(input_args, output_args)&lt;br /&gt;
		for name, value in pairs( input_args ) do &lt;br /&gt;
			if type(name)=='string' and value ~= '' then &lt;br /&gt;
				output_args[string.lower(name)] = value&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return output_args&lt;br /&gt;
	end&lt;br /&gt;
	local args = {}&lt;br /&gt;
	args = normalize_input_args(frame:getParent().args, args)&lt;br /&gt;
	args = normalize_input_args(frame.args, args)&lt;br /&gt;
	return args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- convert from a list to a set&lt;br /&gt;
local function list2set(list, set) &lt;br /&gt;
	set = set or {}&lt;br /&gt;
	for _, v in ipairs(list) do set[v]=true end&lt;br /&gt;
	return set&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------&lt;br /&gt;
-- Collect one or more item ID from a property&lt;br /&gt;
local function getProperty(entity, prop) &lt;br /&gt;
	propVal = {}&lt;br /&gt;
	if entity and entity.claims then&lt;br /&gt;
		for _, statement in pairs(entity:getBestStatements( prop )) do&lt;br /&gt;
			if statement.mainsnak.snaktype == 'value' then&lt;br /&gt;
				table.insert(propVal, statement.mainsnak.datavalue.value.id)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return propVal&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === External functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------&lt;br /&gt;
-- Purpose: create old wikitext stype interwiki links (links shown on the left &lt;br /&gt;
-- side of the page) to add or replace interwiki links based on Wikidata &lt;br /&gt;
-- sitelinks&lt;br /&gt;
-- Use as follows:&lt;br /&gt;
--  * {{#invoke:Interwiki|interwiki}} will examine wikidata item and see if &lt;br /&gt;
--       any &amp;quot;redirectProperties&amp;quot; are present if any are than the first item &lt;br /&gt;
--       ID will be used. We will than proceed to add to interwiki links in&lt;br /&gt;
--       addition to the ones based on Wikidata sitelinks &lt;br /&gt;
--  * {{#invoke:Interwiki|interwiki|qid=Q5}} specify an item to draw interwikis from&lt;br /&gt;
--  * {{#invoke:Interwiki|interwiki|test=1}} will display interwikilinks as bullet list &lt;br /&gt;
--        to allow debuging&lt;br /&gt;
function p.interwiki(frame)&lt;br /&gt;
	-- process inputs&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local qid  = args.qid         -- get uses parameter &amp;quot;qid&amp;quot;  if provided&lt;br /&gt;
	local test = args.test or '0' -- get uses parameter &amp;quot;test&amp;quot; if provided&lt;br /&gt;
	test = (test=='yes' or test=='y' or test=='true'  or test=='1')    -- convert to boolean&lt;br /&gt;
	local fStr = (test and '*[[w:%s:%s]]') or '[[%s:%s]]'              -- link format: in normal or in test mode&lt;br /&gt;
	&lt;br /&gt;
	-- Excludes some wikiprojects that are not Wikipedia, even if their code ends with 'wiki'&lt;br /&gt;
	-- The last one is the name of the current project&lt;br /&gt;
	local excludedProjects = {'wikidatawiki', 'commonswiki', 'specieswiki', 'metawiki', 'simplewiki',&lt;br /&gt;
			'mediawikiwiki', 'sourceswiki', 'wikimaniawiki', mw.wikibase.getGlobalSiteId()}	&lt;br /&gt;
	excludedProjects = list2set(excludedProjects)  -- convert from a list to a set&lt;br /&gt;
&lt;br /&gt;
	-- current page is connected through a sitelink to an wikidata entity&lt;br /&gt;
	local entity = mw.wikibase.getEntity()&lt;br /&gt;
	if entity then &lt;br /&gt;
		-- find wikidata item from which to copy interwiki links&lt;br /&gt;
		if (not qid or qid == '') then&lt;br /&gt;
			for _, prop in ipairs(redirectProperties) do&lt;br /&gt;
				qid = getProperty(entity, prop)[1] -- follow wikidata's item redirect-like properties&lt;br /&gt;
				if qid then break end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		-- check if we are at category item&lt;br /&gt;
		local instanceOf = list2set(getProperty(entity, 'P31')) -- place item's instances-of in a set&lt;br /&gt;
		local isCat      = instanceOf['Q4167836']               -- this entity is a instance of Wikimedia category&lt;br /&gt;
		-- build a list of sites we will not link to,  so we do not overwrite existing interwiki links&lt;br /&gt;
		-- we will overwrite category sitelinks with article sitelinks if both are present&lt;br /&gt;
		if qid and (not isCat) then -- in case &amp;quot;entity&amp;quot; already has some sitelinks than exclude them&lt;br /&gt;
			excludedProjects = list2set(entity.sitelinks, excludedProjects)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- build interwiki table based on wikidata page with item ID 'qid'&lt;br /&gt;
	local intWikiTable = {}&lt;br /&gt;
	if qid then&lt;br /&gt;
		entity = mw.wikibase.getEntity(qid)&lt;br /&gt;
		if entity and entity.sitelinks then&lt;br /&gt;
			for _, sitelink in pairs(entity.sitelinks) do&lt;br /&gt;
				local site = sitelink.site -- site names usually have language+&amp;quot;wiki&amp;quot; like &amp;quot;enwiki&amp;quot;, etc&lt;br /&gt;
				local lang = mw.ustring.sub( site, 1, -5) -- split site into language and project parts&lt;br /&gt;
				local proj = mw.ustring.sub( site, -4)&lt;br /&gt;
				if not excludedProjects[site] and proj=='wiki' then -- excludes sites on the list as well as Wikisource, Wikiquote, Wikivoyage etc&lt;br /&gt;
					lang = mw.ustring.gsub(lang, '_','-') -- if extracted language has any underscores replace it with a minus&lt;br /&gt;
					table.insert(intWikiTable, mw.ustring.format(fStr, lang, sitelink.title) ) -- put together a interwiki-link to other projects&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(intWikiTable, '\n') -- change table of strings to a single string: one row per line&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Imported&gt;Mike Peel</name></author>
		
	</entry>
</feed>