<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://130.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite</id>
	<title>Module:Cite - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://130.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite"/>
	<link rel="alternate" type="text/html" href="https://130.wiki/index.php?title=Module:Cite&amp;action=history"/>
	<updated>2026-10-23T09:47:57Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://130.wiki/index.php?title=Module:Cite&amp;diff=7579&amp;oldid=prev</id>
		<title>zhwiki&gt;Srapoj：​补充注释</title>
		<link rel="alternate" type="text/html" href="https://130.wiki/index.php?title=Module:Cite&amp;diff=7579&amp;oldid=prev"/>
		<updated>2025-07-20T13:45:45Z</updated>

		<summary type="html">&lt;p&gt;补充注释&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- 源自[[:en:Module:Cite]]的本地化版本。当前基于 https://en.wikipedia.org/w/index.php?title=Module:Cite&amp;amp;oldid=1290436560&lt;br /&gt;
&lt;br /&gt;
-- 本地[[Module:Citation/CS1]]的入口函数citation为全局变量，因此不兼容strict&lt;br /&gt;
-- require (&amp;#039;strict&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local cfg = mw.loadData (&amp;#039;Module:Cite/config&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S U B S T I T U T E &amp;gt;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Substitutes $1, $2, etc in &amp;lt;message&amp;gt; with data from &amp;lt;data_t&amp;gt;. Returns plain-text substituted string when&lt;br /&gt;
&amp;lt;data_t&amp;gt; not nil; returns &amp;lt;message&amp;gt; else.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function substitute (message, data_t)&lt;br /&gt;
	return data_t and mw.message.newRawMessage (message, data_t):plain() or message;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ E R R O R _ M S G &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Assembles an error message from module name, message text, help link, and error category.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_error_msg (frame, msg)&lt;br /&gt;
	local module_name = frame:getTitle();										-- get the module name for prefix and help-link label&lt;br /&gt;
	local namespace = mw.title.getCurrentTitle().namespace;						-- used for categorization&lt;br /&gt;
&lt;br /&gt;
	local category_link = (0 == namespace) and substitute (&amp;#039;[[Category:$1]]&amp;#039;, {cfg.settings_t.err_category}) or &amp;#039;&amp;#039;;&lt;br /&gt;
	return substitute (&amp;#039;&amp;lt;span style=&amp;quot;color:#d33&amp;quot;&amp;gt;&amp;amp;#x7B;{[[$1|#invoke:$2]]}}错误：$3 ([[:$4|$5]])&amp;lt;/span&amp;gt;$6&amp;#039;,&lt;br /&gt;
		{&lt;br /&gt;
		module_name,															-- the module name with namespace&lt;br /&gt;
		module_name:gsub (&amp;#039;Module:&amp;#039;, &amp;#039;&amp;#039;),										-- the module name without namespace&lt;br /&gt;
		msg,																	-- the error message&lt;br /&gt;
		cfg.settings_t.help_text_link,											-- help wikilink to text at help page&lt;br /&gt;
		cfg.settings_t.help,													-- help wikilink display text&lt;br /&gt;
		category_link															-- link to error category (for main namespace errors only)&lt;br /&gt;
		})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- 本地化改动。方法来自[[Module:Cite web]]&lt;br /&gt;
&lt;br /&gt;
local function patch_frame (original_frame, new_args)&lt;br /&gt;
	local proxyFrame = {&lt;br /&gt;
		getParent = function(self)&lt;br /&gt;
			return original_frame&lt;br /&gt;
		end,&lt;br /&gt;
		getTitle = function(self)&lt;br /&gt;
			return &amp;#039;Module:Citation/CS1&amp;#039;&lt;br /&gt;
		end,&lt;br /&gt;
		args = new_args&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	setmetatable(proxyFrame, {&lt;br /&gt;
		__index = function(t, k)&lt;br /&gt;
			if type(original_frame[k]) == &amp;#039;function&amp;#039; then&lt;br /&gt;
				return function(...)&lt;br /&gt;
					return original_frame[k](original_frame, select(2, ...))&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				return original_frame[k]&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	})&lt;br /&gt;
&lt;br /&gt;
	return proxyFrame&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C I T E &amp;gt;---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Function to call Module:Citation/CS1/sandbox with appropriate parameters.  For use when an article exceeds the&lt;br /&gt;
post-expand include size limit.&lt;br /&gt;
&lt;br /&gt;
	{{#invoke:cite|book|title=Title}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cite (frame, template)&lt;br /&gt;
	-- 目前类别参数为英语。若含有非ASCII字符则需改用mw.ustring.lower()&lt;br /&gt;
	template = template:lower();												-- lowercase for table indexes&lt;br /&gt;
	&lt;br /&gt;
	if not cfg.known_templates_t[template] then									-- do we recognize this template name?&lt;br /&gt;
		return make_error_msg (frame, substitute (cfg.settings_t.unknown_name, {template}));	-- nope; abandon with error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local config_t = {[&amp;#039;CitationClass&amp;#039;] = cfg.citation_classes_t[template] or template};	-- set CitationClass value&lt;br /&gt;
&lt;br /&gt;
	-- 本地[[Module:Citation/CS1]]与英文维基百科结构不同，只有citation一个入口，且要求传入frame。&lt;br /&gt;
	-- 它的citation函数会将本层frame的args参数表当作已解析的参数，直接存入内部的config和args变量；&lt;br /&gt;
	-- 随后再解析并校验parent frame的args参数表（即条目页传给{{cite web}}模板的参数），结果将并入内部的args变量。&lt;br /&gt;
	-- 考虑到本模块会被用户直接在条目中调用，参数不规范的机会远多于模板作者在模板中预设CS1参数的情形，&lt;br /&gt;
	-- 因此应当使用Module:Citation/CS1对于{{cite web}}的校验逻辑。&lt;br /&gt;
	-- 故选择修改frame变量，将本模块的传入参数伪装成parent frame的参数，以复用相关逻辑。&lt;br /&gt;
	local newFrame = patch_frame(frame, config_t)&lt;br /&gt;
	return require (&amp;#039;Module:Citation/CS1&amp;#039;).citation (newFrame);	-- go render the citation&lt;br /&gt;
end&lt;br /&gt;
&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 setmetatable({}, {__index =												-- returns an empty TABLE whose metatable has the __index set so that, for any given KEY, it returns&lt;br /&gt;
	function(_, template)														-- this anonymous function called as function(TABLE, KEY)&lt;br /&gt;
		return function (frame) return cite (frame, template) end;				-- which in turn returns a function that calls cite() with the KEY name&lt;br /&gt;
	end&lt;br /&gt;
})&lt;/div&gt;</summary>
		<author><name>zhwiki&gt;Srapoj</name></author>
	</entry>
</feed>