<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.caricature.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_Q</id>
	<title>Module:Cite Q - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.caricature.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_Q"/>
	<link rel="alternate" type="text/html" href="http://wiki.caricature.org/wiki/index.php?title=Module:Cite_Q&amp;action=history"/>
	<updated>2026-06-02T00:05:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>http://wiki.caricature.org/wiki/index.php?title=Module:Cite_Q&amp;diff=2333&amp;oldid=prev</id>
		<title>TheChairman: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://wiki.caricature.org/wiki/index.php?title=Module:Cite_Q&amp;diff=2333&amp;oldid=prev"/>
		<updated>2020-05-16T20:38:05Z</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:38, 16 May 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>TheChairman</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.caricature.org/wiki/index.php?title=Module:Cite_Q&amp;diff=2332&amp;oldid=prev</id>
		<title>en&gt;DannyS712: DannyS712 moved page Module:Citeq to Module:Cite Q without leaving a redirect: requested move; consensus at Module talk:Cite Q</title>
		<link rel="alternate" type="text/html" href="http://wiki.caricature.org/wiki/index.php?title=Module:Cite_Q&amp;diff=2332&amp;oldid=prev"/>
		<updated>2019-10-01T03:52:19Z</updated>

		<summary type="html">&lt;p&gt;DannyS712 moved page &lt;a href=&quot;/wiki/index.php?title=Module:Citeq&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:Citeq (page does not exist)&quot;&gt;Module:Citeq&lt;/a&gt; to &lt;a href=&quot;/wiki/index.php/Module:Cite_Q&quot; title=&quot;Module:Cite Q&quot;&gt;Module:Cite Q&lt;/a&gt; without leaving a redirect: &lt;a href=&quot;https://en.wikipedia.org/wiki/Requested_moves&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Requested moves&quot;&gt;requested move&lt;/a&gt;; consensus at &lt;a href=&quot;/wiki/index.php?title=Module_talk:Cite_Q&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module talk:Cite Q (page does not exist)&quot;&gt;Module talk:Cite Q&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require('Module:No globals')&lt;br /&gt;
&lt;br /&gt;
local citeq = {}&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S E T &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
local function is_set( var )&lt;br /&gt;
	return not (var == nil or var == '');&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; G E T _ N A M E _ L I S T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
get_name_list -- adapted from getAuthors code taken from [[Module:RexxS]]&lt;br /&gt;
arguments:&lt;br /&gt;
	nl_type - type of name list to fetch: nl_type = 'author' for authors; 'editor' for editors&lt;br /&gt;
	args - pointer to the parameter arguments table from the template call&lt;br /&gt;
	qid - value from |qid= parameter; the Q-id of the source (book, etc.) in qid&lt;br /&gt;
	wdl - value from the |wdlinks= parameter; a boolean passed to enable links to Wikidata when no article exists&lt;br /&gt;
&lt;br /&gt;
returns nothing; modifies the args table&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function get_name_list (nl_type, args, qid, wdl)&lt;br /&gt;
	local propertyID = &amp;quot;P50&amp;quot;&lt;br /&gt;
	local fallbackID = &amp;quot;P2093&amp;quot; -- author name string&lt;br /&gt;
	&lt;br /&gt;
	if 'author' == nl_type then&lt;br /&gt;
		propertyID = 'P50';														-- for authors&lt;br /&gt;
		fallbackID = 'P2093';&lt;br /&gt;
	elseif 'editor' == nl_type then&lt;br /&gt;
		propertyID = 'P98';														-- for editors&lt;br /&gt;
		fallbackID = nil;&lt;br /&gt;
	else&lt;br /&gt;
		return;																	-- not specified so return&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- wdlinks is a boolean passed to enable links to Wikidata when no article exists&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or &amp;quot;0&amp;quot; is passed set it false&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	if wdl and (#wdl &amp;gt; 0) then&lt;br /&gt;
		wdl = wdl:lower()&lt;br /&gt;
		wdl = (wdl == &amp;quot;false&amp;quot;) or (wdl == &amp;quot;no&amp;quot;) or (wdl == &amp;quot;0&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		-- wdl is empty, so&lt;br /&gt;
		wdl = false&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local entity = mw.wikibase.getEntity(qid)&lt;br /&gt;
	local props = nil&lt;br /&gt;
	local fallback = nil&lt;br /&gt;
	if entity and entity.claims then&lt;br /&gt;
		props = entity.claims[propertyID]&lt;br /&gt;
		if fallbackID then&lt;br /&gt;
			fallback = entity.claims[fallbackID]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Make sure it actually has at least one of the properties requested&lt;br /&gt;
	if not (props and props[1]) and not (fallback and fallback[1]) then &lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- So now we have something to return:&lt;br /&gt;
	-- table 'out' is going to store the names(s):&lt;br /&gt;
	-- and table 'link' will store any links to the name's article&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local link = {}&lt;br /&gt;
	local maxpos = 0&lt;br /&gt;
	if props and props[1] then&lt;br /&gt;
		for k, v in pairs(props) do&lt;br /&gt;
			local qnumber = &amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
			local sitelink = mw.wikibase.sitelink(qnumber)&lt;br /&gt;
			local label = mw.wikibase.label(qnumber)&lt;br /&gt;
			if label then&lt;br /&gt;
				label = mw.text.nowiki(label)&lt;br /&gt;
			else&lt;br /&gt;
				label = qnumber&lt;br /&gt;
			end&lt;br /&gt;
			local position = maxpos + 1 -- Default to 'next' author.&lt;br /&gt;
			-- use P1545 (series ordinal) instead of default position.&lt;br /&gt;
			if v[&amp;quot;qualifiers&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;][1] then&lt;br /&gt;
				position = tonumber(v.qualifiers[&amp;quot;P1545&amp;quot;][1].datavalue.value)&lt;br /&gt;
			end&lt;br /&gt;
			maxpos = math.max(maxpos, position)&lt;br /&gt;
			if sitelink then&lt;br /&gt;
				-- just the plain name,&lt;br /&gt;
				-- but keep a record of the links, using the same index&lt;br /&gt;
				out[position] = label&lt;br /&gt;
				link[position] = sitelink&lt;br /&gt;
			else&lt;br /&gt;
				-- no sitelink, so check first for a redirect with that label&lt;br /&gt;
				-- this code works, but causes the article to appear in WhatLinksHere for the possible destination, so remove&lt;br /&gt;
				-- local artitle = mw.title.new(label, 0)&lt;br /&gt;
				-- if artitle.id &amp;gt; 0 then&lt;br /&gt;
				--	if artitle.isRedirect then&lt;br /&gt;
						-- no sitelink,&lt;br /&gt;
						-- but there's a redirect with the same title as the label;&lt;br /&gt;
						-- so store the link to that&lt;br /&gt;
				--		out[position] = label&lt;br /&gt;
				--		link[position] = label&lt;br /&gt;
				--	else&lt;br /&gt;
						-- no sitelink and not a redirect but an article exists with the same title as the label&lt;br /&gt;
						-- that's probably a dab page, so output the plain label&lt;br /&gt;
				--		out[position] = label&lt;br /&gt;
				--	end&lt;br /&gt;
				--else&lt;br /&gt;
				-- no article or redirect with the same title as the label&lt;br /&gt;
				if wdl then&lt;br /&gt;
					-- show that there's a Wikidata entry available&lt;br /&gt;
					out[position] = &amp;quot;[[:d:Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;] .. &amp;quot;|&amp;quot; .. label .. &amp;quot;]]&amp;amp;nbsp;&amp;lt;span title='&amp;quot; .. i18n[&amp;quot;errors&amp;quot;][&amp;quot;local-article-not-found&amp;quot;] .. &amp;quot;'&amp;gt;[[File:Wikidata-logo.svg|16px|alt=|link=]]&amp;lt;/span&amp;gt;&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					-- no wikidata links wanted, so just give the plain label&lt;br /&gt;
					out[position] = label&lt;br /&gt;
				end&lt;br /&gt;
				-- end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if fallback and fallback[1] then&lt;br /&gt;
		-- Fallback to name-only authors / editors&lt;br /&gt;
		for k, v in pairs(fallback) do&lt;br /&gt;
			local label = v.mainsnak.datavalue[&amp;quot;value&amp;quot;]&lt;br /&gt;
			local position = maxpos + 1 -- Default to 'next' author.&lt;br /&gt;
			-- use P1545 (series ordinal) instead of default position.&lt;br /&gt;
			if v[&amp;quot;qualifiers&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;][1] then&lt;br /&gt;
				position = tonumber(v.qualifiers[&amp;quot;P1545&amp;quot;][1].datavalue.value)&lt;br /&gt;
			end&lt;br /&gt;
			maxpos = math.max(maxpos, position)&lt;br /&gt;
			out[position] = label&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if there's anything to return, then insert the additions in the template arguments table&lt;br /&gt;
	-- in the form |author1=firstname secondname |author2= ...&lt;br /&gt;
	-- Renumber, in case we have inconsistent numbering&lt;br /&gt;
	local keys = {}&lt;br /&gt;
	for k,v in pairs(out) do&lt;br /&gt;
		keys[#keys+1] = k&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(keys) -- as they might be out of order&lt;br /&gt;
	for i, k in ipairs(keys) do&lt;br /&gt;
		mw.log(i..&amp;quot; &amp;quot;..k..&amp;quot; &amp;quot;..out[k])&lt;br /&gt;
		args[nl_type .. i] = out[k]												-- author-n or editor-n&lt;br /&gt;
		if link[k] then&lt;br /&gt;
			args[nl_type .. '-link' .. i] = link[k]								-- author-linkn or editor-linkn&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; C I T E _ Q &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Takes standard cs1|2 template parameters and passes all to {{citation}}.  If neither of |author= and |author1=&lt;br /&gt;
are set, calls get_authors() to try to get an author name-list from wikidata.  The result is passed to &lt;br /&gt;
{{citation}} for rendering.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
function citeq.cite_q (frame)&lt;br /&gt;
local citeq_args = {};&lt;br /&gt;
local qid;&lt;br /&gt;
local wdl;&lt;br /&gt;
&lt;br /&gt;
local pframe = frame:getParent()&lt;br /&gt;
local args = pframe.args;														-- first get parent frame arguments - these from the template call&lt;br /&gt;
&lt;br /&gt;
	for k, v in pairs (args) do													-- copy named parameters and their values into citeq_args&lt;br /&gt;
		if type( k ) == 'string' then											-- numbered parameters ignored&lt;br /&gt;
			citeq_args[k] = v;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	args = frame.args;															-- now get frame arguments (from the template wikisource) &lt;br /&gt;
&lt;br /&gt;
	for k, v in pairs (args) do													-- copy args into citeq_args&lt;br /&gt;
		if 'qid' == k then														-- don't copy qid&lt;br /&gt;
			qid = v;															-- save its value&lt;br /&gt;
		elseif 'wdlinks' == k then												-- don't copy wdlinks&lt;br /&gt;
			wdl = v;															-- save its value&lt;br /&gt;
		else&lt;br /&gt;
			citeq_args[k] = v													-- but copy everything else&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (qid) then&lt;br /&gt;
		if not is_set (citeq_args.author) and not is_set (citeq_args.author1) then	-- if neither are set, try to get authors from wikidata&lt;br /&gt;
			get_name_list ('author', citeq_args, qid, wdl);						-- modify citeq_args table with authors from wikidata&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if not is_set (citeq_args.editor) and not is_set (citeq_args.editor1) then	-- if neither are set, try to get editors from wikidata&lt;br /&gt;
			get_name_list ('editor', citeq_args, qid, wdl);						-- modify citeq_args table with editors from wikidata&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return frame:expandTemplate{title = 'citation', args = citeq_args};			-- render the citation&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return citeq&lt;/div&gt;</summary>
		<author><name>en&gt;DannyS712</name></author>
		
	</entry>
</feed>