<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hant-TW">
	<id>https://tnfshwiki.tfcis.org/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E7%B5%84%3ARedirect_template</id>
	<title>模組:Redirect template - 修訂歷史</title>
	<link rel="self" type="application/atom+xml" href="https://tnfshwiki.tfcis.org/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E7%B5%84%3ARedirect_template"/>
	<link rel="alternate" type="text/html" href="https://tnfshwiki.tfcis.org/index.php?title=%E6%A8%A1%E7%B5%84:Redirect_template&amp;action=history"/>
	<updated>2026-05-06T22:33:18Z</updated>
	<subtitle>本 Wiki 上此頁面的修訂歷史</subtitle>
	<generator>MediaWiki 1.39.2</generator>
	<entry>
		<id>https://tnfshwiki.tfcis.org/index.php?title=%E6%A8%A1%E7%B5%84:Redirect_template&amp;diff=4491&amp;oldid=prev</id>
		<title>Xiplus：​新頁面: require(&#039;Module:No globals&#039;)  local p = {}  -- key is beginning of arg name. value is table with namespace number and link -- alternatively, a function taking the namespace number and...</title>
		<link rel="alternate" type="text/html" href="https://tnfshwiki.tfcis.org/index.php?title=%E6%A8%A1%E7%B5%84:Redirect_template&amp;diff=4491&amp;oldid=prev"/>
		<updated>2016-04-10T09:31:34Z</updated>

		<summary type="html">&lt;p&gt;新頁面: require(&amp;#039;Module:No globals&amp;#039;)  local p = {}  -- key is beginning of arg name. value is table with namespace number and link -- alternatively, a function taking the namespace number and...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新頁面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;Module:No globals&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- key is beginning of arg name. value is table with namespace number and link&lt;br /&gt;
-- alternatively, a function taking the namespace number and returning a validity&lt;br /&gt;
-- can be used&lt;br /&gt;
local namespaceCategories = {&lt;br /&gt;
	all = { function() return true end },&lt;br /&gt;
	main = { 0, &amp;#039;[[Wikipedia:條目|條目]]&amp;#039; },&lt;br /&gt;
	help = { 12, &amp;#039;[[wp:幫助頁面|幫助]]&amp;#039; },&lt;br /&gt;
	portal = { 100, &amp;#039;[[wp:主題|主題]]&amp;#039; },&lt;br /&gt;
	talk = { function(n) return n &amp;gt; 0 and n%2 == 1 end, &amp;#039;[[Help:使用討論頁|討論]]&amp;#039; },&lt;br /&gt;
	template = { 10, &amp;#039;[[wp:模板空間|模板]]&amp;#039; },&lt;br /&gt;
	wikipedia = { 4, &amp;#039;[[wp:項目空間|竹園Wiki項目]]&amp;#039; },&lt;br /&gt;
	category = { 14, &amp;#039;[[wp:分類|分類]]&amp;#039; },&lt;br /&gt;
	user = { 2, &amp;#039;[[wp:用戶頁|用戶]]&amp;#039; },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Don&amp;#039;t convert blank category to nil&lt;br /&gt;
local function valueFunc(key, val)&lt;br /&gt;
	if type(val) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		val = val:match(&amp;#039;^%s*(.-)%s*$&amp;#039;)&lt;br /&gt;
		if val == &amp;#039;&amp;#039; and key ~= &amp;#039;category&amp;#039; and key ~= &amp;#039;embed&amp;#039; then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getPrettyName(args)&lt;br /&gt;
	for k in pairs(namespaceCategories) do&lt;br /&gt;
		if args[k .. &amp;#039; category&amp;#039;] then&lt;br /&gt;
			return  &amp;quot;&amp;#039;&amp;#039;&amp;#039;[[:Category:&amp;quot; .. args[k .. &amp;#039; category&amp;#039;] .. &amp;quot;|&amp;quot; .. args.name .. &amp;quot;]]&amp;#039;&amp;#039;&amp;#039;：&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;quot;&amp;#039;&amp;#039;&amp;#039;&amp;quot; .. args.name .. &amp;quot;&amp;#039;&amp;#039;&amp;#039;：&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.core(frame, args)&lt;br /&gt;
	if not args then&lt;br /&gt;
		args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {wrappers = &amp;#039;Template:Redirect template/core&amp;#039;, valueFunc = valueFunc})&lt;br /&gt;
	end&lt;br /&gt;
	local namespace = mw.title.getCurrentTitle().namespace&lt;br /&gt;
	local otherCategory = args[&amp;#039;other category&amp;#039;] and (args.category or string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[&amp;#039;other category&amp;#039;]))&lt;br /&gt;
	local embedPossible = args.embed == nil or args.embed == &amp;#039;yes&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	--- XXX: this is a HORRIBLE HACK. kill it with fire as soon as https://bugzilla.wikimedia.org/show_bug.cgi?id=12974 is fixed&lt;br /&gt;
	local beCompatibleWithBug12974 = args.info and (args.info:find(&amp;#039;^[:;#*]&amp;#039;, 1) == 1 or args.info:find(&amp;#039;{|&amp;#039;, 1, true) == 1) and &amp;#039;\n&amp;#039; or &amp;#039;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local retval = string.format(&amp;#039;&amp;lt;hr /&amp;gt;%s這是%s%s重定向。%s%s\n&amp;#039;,&lt;br /&gt;
		embedPossible and args.name and getPrettyName(args) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.from and ( ( args.to and &amp;#039;由&amp;#039; or &amp;#039;&amp;#039;) .. args.from .. (args.to and &amp;#039;&amp;#039; or &amp;#039;的&amp;#039; ) ) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.to and ( ( args.from and &amp;#039;，&amp;#039; or &amp;#039;&amp;#039;) .. &amp;#039;指向&amp;#039;   .. args.to .. &amp;#039;的&amp;#039;) or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.info and beCompatibleWithBug12974 or &amp;#039;&amp;#039;,&lt;br /&gt;
		args.info or &amp;#039;&amp;#039;&lt;br /&gt;
	)&lt;br /&gt;
	for k,v in pairs(namespaceCategories) do&lt;br /&gt;
		if args[k .. &amp;#039; category&amp;#039;] then&lt;br /&gt;
			if type(v[1]) == &amp;#039;function&amp;#039; and v[1](namespace) or v[1] == namespace then&lt;br /&gt;
				retval = retval .. (args.category or string.format(&amp;#039;[[Category:%s]]&amp;#039;, args[k .. &amp;#039; category&amp;#039;]))&lt;br /&gt;
			elseif args[&amp;#039;other category&amp;#039;] then&lt;br /&gt;
				retval = retval .. otherCategory&lt;br /&gt;
			else&lt;br /&gt;
				retval = retval .. frame:expandTemplate{title = &amp;#039;不正確的重定向模板&amp;#039;, args = {v[2]}}&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {wrappers = &amp;#039;Template:Redirect template&amp;#039;, valueFunc = valueFunc})&lt;br /&gt;
	local retval = p.core(frame, args)&lt;br /&gt;
	if mw.title.getCurrentTitle().namespace == 0 then&lt;br /&gt;
		if args.printworthy == &amp;#039;yes&amp;#039; then&lt;br /&gt;
			return retval .. (args.category or &amp;#039;[[Category:值得列印的重定向]]&amp;#039;)&lt;br /&gt;
		elseif args.printworthy == &amp;#039;no&amp;#039; then&lt;br /&gt;
			return retval .. (args.category or &amp;#039;[[Category:不需列印的重定向]]&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Xiplus</name></author>
	</entry>
</feed>