<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_tweet</id>
	<title>Module:Cite tweet - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_tweet"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Cite_tweet&amp;action=history"/>
	<updated>2026-04-05T22:39:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:Cite_tweet&amp;diff=776&amp;oldid=prev</id>
		<title>imported&gt;Trappist the monk at 11:04, 15 March 2026</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Cite_tweet&amp;diff=776&amp;oldid=prev"/>
		<updated>2026-03-15T11:04:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local TwitterSnowflake = require(&amp;#039;Module:TwitterSnowflake&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local err_msgs_t = {															-- a sequence of snowflake date error messages; all must be terminated with a semicolon (;)&lt;br /&gt;
	&amp;#039; &amp;lt;kbd&amp;gt;&amp;amp;#124;date=&amp;lt;/kbd&amp;gt; / &amp;lt;kbd&amp;gt;&amp;amp;#124;number=&amp;lt;/kbd&amp;gt; mismatch;&amp;#039;,				-- [1]&lt;br /&gt;
	&amp;#039; &amp;lt;kbd&amp;gt;&amp;amp;#124;date=&amp;lt;/kbd&amp;gt; required;&amp;#039;,										-- [2]&lt;br /&gt;
	&amp;#039; Invalid &amp;lt;kbd&amp;gt;&amp;amp;#124;number=&amp;lt;/kbd&amp;gt;;&amp;#039;,										-- [3]&lt;br /&gt;
	&amp;#039; Missing or empty &amp;lt;kbd&amp;gt;&amp;amp;#124;number=&amp;lt;/kbd&amp;gt;;&amp;#039;,								-- [4]&lt;br /&gt;
	&amp;#039; Missing or empty &amp;lt;kbd&amp;gt;&amp;amp;#124;user=&amp;lt;/kbd&amp;gt;;&amp;#039;									-- [5]&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S U P P R E S S _ U R L _ I N _ T I T L E &amp;gt;------------------------------------&lt;br /&gt;
&lt;br /&gt;
This function searches for and suppresses urls in |title=, |script-title=, and |trans-title= parameters so that&lt;br /&gt;
{{cite web}} won&amp;#039;t emit &amp;#039;External link in |title=&amp;#039; error messages when rendered In the redering, urls are correctly&lt;br /&gt;
formed as they were in the original tweet.  The function looks for valid schemes and then wraps them in&lt;br /&gt;
&amp;lt;nowiki&amp;gt;..&amp;lt;/nowiki&amp;gt; tags.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function suppress_url_in_title (frame, title)&lt;br /&gt;
	local schemes = {															-- schemes commonly found in tweets&lt;br /&gt;
		&amp;#039;https://&amp;#039;,&lt;br /&gt;
		&amp;#039;http://&amp;#039;,&lt;br /&gt;
		&amp;#039;ftp://&amp;#039;,&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	if title then																-- when there is a title, suppress any urls with known schemes; abandon else&lt;br /&gt;
		for _, scheme in ipairs (schemes) do									-- spin through the list of schemes looking for a match&lt;br /&gt;
			title = title:gsub (scheme, frame:callParserFunction (&amp;#039;#tag&amp;#039;, {&amp;#039;nowiki&amp;#039;, scheme}));	-- replace the scheme with its nowiki&amp;#039;d form (a strip marker)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return title;																-- done; return &amp;lt;title&amp;gt; modified or not&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; D A T E _ N U M B E R _ U R L _ G E T &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
extract |date= and |number= parameter values if present.  Extract date from |number= and compare to |date=.&lt;br /&gt;
&lt;br /&gt;
contruct |url= for {{cite web}} from the base url and |number= and |user=&lt;br /&gt;
&lt;br /&gt;
returns nothing; adds date, number, url to &amp;lt;cite_args_t&amp;gt;; adds error message(s) to &amp;lt;errors_t&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function date_number_url_get (args_t, cite_args_t, errors_t)&lt;br /&gt;
	local err_msg_index;&lt;br /&gt;
&lt;br /&gt;
	cite_args_t.url = &amp;#039;https://x.com/&amp;#039;;									        -- initialize with minimal base url because {{cite web}} requires |url=&lt;br /&gt;
	if not args_t.user then&lt;br /&gt;
		table.insert (errors_t, err_msgs_t[5]);									-- error: missing or empty |user=&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not args_t.date and not args_t.number then&lt;br /&gt;
		err_msg_index = 4;														-- error: missing or empty |number=&lt;br /&gt;
	elseif tonumber (args_t.number) then										-- |number= without |date=? use number&lt;br /&gt;
		if tonumber(args_t.number) then&lt;br /&gt;
			cite_args_t.date = args_t.date or (args_t.number and TwitterSnowflake.snowflakeToDate{ args = {id_str = args_t.number} });	-- prefer |date=; extract date from |number= else&lt;br /&gt;
		else&lt;br /&gt;
			cite_args_t.date = args_t.date;										-- |number= appears to be invalid; use |date= if provided&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		cite_args_t.number = args_t.number;										-- use |number= valid or not&lt;br /&gt;
&lt;br /&gt;
		if args_t.user then														-- |number= appears to have a valid value; if |user= has a value&lt;br /&gt;
			local lang_obj = mw.getContentLanguage();&lt;br /&gt;
			local good, test_date = pcall (lang_obj.formatDate, lang_obj, &amp;#039;Ymd&amp;#039;, cite_args_t.date);&lt;br /&gt;
			if good then&lt;br /&gt;
				if 20240517 &amp;gt; tonumber (test_date) then							-- the switch to x.com was completed 2024-05-17&lt;br /&gt;
					cite_args_t.url = &amp;#039;https://twitter.com/&amp;#039;;&lt;br /&gt;
				end&lt;br /&gt;
				if 20230723 &amp;gt; tonumber (test_date) then							-- rebranded to x on 2023-07-23&lt;br /&gt;
					cite_args_t.via = args_t.link == &amp;#039;no&amp;#039; and &amp;#039;Twitter&amp;#039; or &amp;#039;[[Twitter]]&amp;#039;;&lt;br /&gt;
				else&lt;br /&gt;
					cite_args_t.via = args_t.link == &amp;#039;no&amp;#039; and &amp;#039;X (formerly Twitter)&amp;#039; or &amp;#039;[[X (formerly Twitter)]]&amp;#039;;&lt;br /&gt;
				end&lt;br /&gt;
					&lt;br /&gt;
			end&lt;br /&gt;
			cite_args_t.url = cite_args_t.url .. args_t.user .. &amp;#039;/status/&amp;#039; .. args_t.number;	-- construct |url= for {{cite web}}&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	elseif args_t.number then													-- |number= with a value that can&amp;#039;t be converted to a number; invalid&lt;br /&gt;
		err_msg_index = 3;														-- error: invalid number (couldn&amp;#039;t convert to number)&lt;br /&gt;
	elseif not args_t.number then												-- |date= without |number= use date&lt;br /&gt;
		cite_args_t.date = args_t.date;											-- |date= has a value, use it&lt;br /&gt;
		err_msg_index = 4;														-- error: missing or empty |number=&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if err_msg_index then&lt;br /&gt;
		table.insert (errors_t, err_msgs_t[err_msg_index]);						-- invalid number or missing necessary parameters so abandon&lt;br /&gt;
		return;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	err_msg_index = TwitterSnowflake.datecheck ({ args = {						-- returns error message index number on error; nil else&lt;br /&gt;
		id_str	= args_t.number or &amp;#039;&amp;#039;,&lt;br /&gt;
		date	= args_t.date or &amp;#039;&amp;#039;,&lt;br /&gt;
		error1	= 1,															-- these numbers are indexes into &amp;lt;err_msgs_t&amp;gt; to override snowflake default error messages&lt;br /&gt;
		error2  = 2,															-- done this way to avoid long string comparison looking for&lt;br /&gt;
		error3	= 3																-- the undated-pre-twitter-epoch-post message&lt;br /&gt;
		}});&lt;br /&gt;
&lt;br /&gt;
	if	2 == err_msg_index then													-- when no date and posted before twitter epoch&lt;br /&gt;
		cite_args_t.date = nil;													-- suppress default date because {{cite tweet}} should not claim in its own voice that the undated post was posted 2010-11-04&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.insert (errors_t, err_msgs_t[err_msg_index]);							-- add error message&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A I N &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
construct parameter set for {{cite web}} from {{cite tweet}} parameters;  do some error checking&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function main (frame)&lt;br /&gt;
	local args_t = require (&amp;#039;Module:Arguments&amp;#039;).getArgs (frame);&lt;br /&gt;
&lt;br /&gt;
	local cite_args_t = {&lt;br /&gt;
		title = suppress_url_in_title (frame, args_t.title),&lt;br /&gt;
		[&amp;#039;script-title&amp;#039;] = suppress_url_in_title (frame, args_t[&amp;#039;script-title&amp;#039;]),&lt;br /&gt;
		[&amp;#039;trans-title&amp;#039;] = suppress_url_in_title (frame, args_t[&amp;#039;trans-title&amp;#039;]),&lt;br /&gt;
		language = args_t.language,&lt;br /&gt;
		last1 = args_t.last1 or args_t.last,&lt;br /&gt;
		first1 = args_t.first1 or args_t.first,&lt;br /&gt;
		author1 = args_t.author1 or args_t.author,&lt;br /&gt;
		[&amp;#039;author-link&amp;#039;] = args_t[&amp;#039;author-link&amp;#039;] or args_t.authorlink,&lt;br /&gt;
		others = args_t.retweet and (&amp;#039;Retweeted by &amp;#039; .. args_t.retweet),&lt;br /&gt;
		type = args_t.link == &amp;#039;no&amp;#039; and &amp;#039;Tweet&amp;#039; or &amp;#039;[[Tweet (social media)|Tweet]]&amp;#039;,&lt;br /&gt;
		location = args_t.location,												-- why |location=?  tweets are online; there is no publication place&lt;br /&gt;
		[&amp;#039;access-date&amp;#039;] = args_t[&amp;#039;access-date&amp;#039;] or args_t.accessdate,&lt;br /&gt;
		[&amp;#039;archive-date&amp;#039;] = args_t[&amp;#039;archive-date&amp;#039;] or args_t.archivedate,&lt;br /&gt;
		[&amp;#039;archive-url&amp;#039;] = args_t[&amp;#039;archive-url&amp;#039;] or args_t.archiveurl,&lt;br /&gt;
		[&amp;#039;url-status&amp;#039;] = args_t[&amp;#039;url-status&amp;#039;],&lt;br /&gt;
		[&amp;#039;url-access&amp;#039;] = args_t[&amp;#039;url-access&amp;#039;],&lt;br /&gt;
		quote = args_t.quote,&lt;br /&gt;
		ref = args_t.ref,&lt;br /&gt;
		df = args_t.df,&lt;br /&gt;
		mode = args_t.mode&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	local errors_t = {&amp;#039;&amp;lt;span class=&amp;quot;cs1-visible-error citation-comment&amp;quot;&amp;gt; &amp;lt;kbd&amp;gt;{{[[Template:Cite tweet|Cite tweet]]}}&amp;lt;/kbd&amp;gt;:&amp;#039;};		-- initialize sequence of error messages with style tag&lt;br /&gt;
	date_number_url_get (args_t, cite_args_t, errors_t);						-- add |date=, |number=, |url= to &amp;lt;cite_args_t&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	local author = ((cite_args_t.last1 and cite_args_t.first1) and cite_args_t.last1 .. &amp;#039;, &amp;#039; .. cite_args_t.first1) or	-- concatenate |last= with |first= for |author-mask=&lt;br /&gt;
		(cite_args_t.last1 and cite_args_t.last1) or							-- only |last= for |author-mask=&lt;br /&gt;
		(cite_args_t.author1 and cite_args_t.author1:gsub(&amp;#039;^%(%((.+)%)%)$&amp;#039;, &amp;#039;%1&amp;#039;));	-- |author= or |author1= stripped of accept-as-written markup for |author-mask=&lt;br /&gt;
&lt;br /&gt;
	if author and args_t.user then&lt;br /&gt;
		cite_args_t[&amp;#039;author-mask&amp;#039;] = author .. &amp;#039; [@&amp;#039; .. (args_t.user or &amp;#039;&amp;#039;) .. &amp;#039;]&amp;#039;	-- concatenate &amp;lt;author&amp;gt; and |user= into |author-mask=&lt;br /&gt;
	elseif args_t.user then&lt;br /&gt;
		cite_args_t.author1 = &amp;#039;((&amp;#039; .. args_t.user .. &amp;#039;))&amp;#039;;						-- just the user name for cs1|2 metadata&lt;br /&gt;
		cite_args_t[&amp;#039;author-mask&amp;#039;] = &amp;#039;@&amp;#039; .. args_t.user;						-- make a mask for display&lt;br /&gt;
	else																		-- here when neither &amp;lt;author&amp;gt; nor |user=&lt;br /&gt;
		cite_args_t.author1 = nil;												-- so unset&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local rendering = require (&amp;#039;Module:Citation/CS1&amp;#039;)._citation (nil, cite_args_t, {CitationClass = &amp;#039;web&amp;#039;});&lt;br /&gt;
&lt;br /&gt;
---------- error messaging ----------&lt;br /&gt;
	if errors_t[2] then															-- errors_t[2] nil when no errors&lt;br /&gt;
		if rendering:find (&amp;#039;cs1-visible-error&amp;#039;, 1, true) then					-- rendered {{cite web}} with errors will have this string&lt;br /&gt;
			errors_t[1] = errors_t[1]:gsub (&amp;#039;&amp;gt; &amp;lt;&amp;#039;, &amp;#039;&amp;gt;; &amp;lt;&amp;#039;);						-- insert semicolon to terminate cs1|2 error message string&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		errors_t[#errors_t] = errors_t[#errors_t]:gsub (&amp;#039;;$&amp;#039;,&amp;#039; ([[Template:Cite_tweet#Error_detection|help]])&amp;#039;);	-- replace trailing semicolon with help link&lt;br /&gt;
		table.insert (errors_t, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;);										-- close style span tag&lt;br /&gt;
		if mw.title.getCurrentTitle():inNamespace (0) then						-- mainspace only&lt;br /&gt;
			table.insert (errors_t, &amp;#039;[[Category:Cite tweet templates with errors]]&amp;#039;);	-- add error category&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		rendering = rendering .. table.concat (errors_t);						-- append error messaging, help links and catagories&lt;br /&gt;
	end&lt;br /&gt;
	return rendering;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T S &amp;gt;----------------------------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	main = main,																-- entry points; {{#invoke:cite tweet|main|...}} is preferred&lt;br /&gt;
	[&amp;#039;&amp;#039;] = main,																-- but {{#invoke:cite tweet||...}} is also acceptable&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>imported&gt;Trappist the monk</name></author>
	</entry>
</feed>