Modül:template link

Merhaba, buraya Modül:template link kelimesinin anlamını aramaya geldiniz. DICTIOUS'da Modül:template link kelimesinin tüm sözlük anlamlarını bulmakla kalmayacak, aynı zamanda etimolojisini, özelliklerini ve Modül:template link kelimesinin tekil ve çoğul olarak nasıl söylendiğini de öğreneceksiniz. Modül:template link kelimesi hakkında bilmeniz gereken her şey burada. Modül:template link kelimesinin tanımı, konuşurken veya metinlerinizi yazarken daha kesin ve doğru olmanıza yardımcı olacaktır. XXX'in ve diğer kelimelerin tanımını bilmek, kelime dağarcığınızı zenginleştirir ve size daha fazla ve daha iyi dilsel kaynaklar sağlar.
Modül belgelemesi


local export = {}

local date_and_time				= "mw:Help:Magic words#Date and time"
local technical_metadata		= "mw:Help:Magic words#Technical metadata"
local tech_meta_another_page	= "mw:Help:Magic words#Technical metadata of another page"
local page_names				= "mw:Help:Magic words#Page names"
local namespaces				= "mw:Help:Magic words#Namespaces"
local formatting				= "mw:Help:Magic words#Formatting"
local URL_data					= "mw:Help:Magic words#URL data"
local localization				= "mw:Help:Magic words#Localization"
local miscellaneous				= "mw:Help:Magic words#Miscellaneous"
local parser_functions_link		= "mw:Help:Extension:ParserFunctions"
local LST						= "mw:Extension:Labeled Section Transclusion"

local variables_nullary = {
	 = date_and_time;
	 = date_and_time;
	 = date_and_time; -- undocumented
	 = date_and_time; -- undocumented
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;

	 = date_and_time;
	 = date_and_time;
	 = date_and_time; -- undocumented
	 = date_and_time; -- undocumented
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;
	 = date_and_time;

	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata; -- undocumented
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;

	 = technical_metadata;
	 = technical_metadata;
	
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;
	
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names; -- undocumented

	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names; -- undocumented

	 = namespaces;
	 = namespaces;
	 = namespaces;
	 = namespaces;
	 = namespaces;

	 = namespaces;
	 = namespaces;
	 = namespaces;

	 = "mw:Help:Magic words#Other";
}

local variables_nonnullary = {
	 = technical_metadata;

	 = technical_metadata;
	 = technical_metadata;

	 = technical_metadata;
	 = technical_metadata;
	
	 = technical_metadata;
	 = technical_metadata;
	 = technical_metadata;

	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names; -- undocumented

	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names;
	 = page_names; -- undocumented

	 = namespaces;
	 = namespaces;
	 = namespaces;
	 = namespaces;
	 = namespaces;

	 = namespaces;
	 = namespaces;
	 = namespaces;

	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
	 = tech_meta_another_page;
}

local parser_functions = {
	-- built-ins
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	 = URL_data;
	
	 = namespaces;
	 = namespaces;

	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;
	 = formatting;

	 = localization;
	 = localization;
	 = localization;
	 = localization;
	
	 = miscellaneous;
	 = miscellaneous;
	 = miscellaneous;
	 = miscellaneous;
	
	-- ]
	 = parser_functions_link .. "##expr";
	 = parser_functions_link .. "##if";
	 = parser_functions_link .. "##ifeq";
	 = parser_functions_link .. "##iferror";
	 = parser_functions_link .. "##ifexpr";
	 = parser_functions_link .. "##ifexist";
	 = parser_functions_link .. "##rel2abs";
	 = parser_functions_link .. "##switch";
	 = parser_functions_link .. "##time";
	 = parser_functions_link .. "##timel";
	 = parser_functions_link .. "##titleparts";
	
	-- other extensions
	 = "mw:Extension:Scribunto";
 	 = "mw:Extension:Babel";
 	 = "mw:Extension:CategoryTree#The {{#categorytree}} parser function";
 	 = LST;
 	 = LST;
 	 = LST; -- not available, it seems
 	 = "mw:Extension:LiquidThreads";
	 = "mw:Extension:LiquidThreads";
	 = "mw:Extension:MassMessage"; -- not documented yet
}

-- rudimentary
local function is_valid_pagename(pagename)
	if (pagename == "") or pagename:match("%|%{%}#\127<>]") then
		return false
	end
	return true
end

local function hook_special(page)
	if is_valid_pagename(page) then
		return "]"
	else
		return page
	end
end

local parser_function_hooks = {
	 = hook_special;
	 = hook_special;
	
	 = function (mesg)
		if is_valid_pagename(mesg) then
			return ("]")
		else
			return mesg
		end
	end;
	
	 = function (cat)
		if is_valid_pagename(cat) and not (mw.title.getCurrentTitle().fullText == ("Category:" .. cat)) then
			return ("]")
		else
			return cat
		end
	end;
	
	 = function (mod)
		if is_valid_pagename(mod) and not (mw.title.getCurrentTitle().fullText == ("Module:" .. mod)) then
			return ("]"):format(mod, mod)
		else
			return mod
		end
	end;
	
	 = function (tag)
		local doc_table = require('Module:wikitag link').doc_table
		if doc_table then
			return ("]"):format(doc_table, tag)
		else
			return tag
		end
	end;
}

function export.format_link(frame)
	if mw.isSubsting() then
		return require('Module:unsubst').unsubst_template("format_link")
	end

	local args = (frame.getParent and frame:getParent().args) or frame -- Allows function to be called from other modules.
	local output = { (frame.args and frame.args.nested) and "&#123;&#123;" or "<code>&#123;&#123;" }
	
	local templ = (frame.args and frame.args.annotate) or args
	local noargs = (frame.args and not frame.args.annotate) and next(args) == nil
	
	if not templ then
		if mw.title.getCurrentTitle().fullText == frame:getParent():getTitle() then
			-- demo mode
			return "<code>{{<var>{{{1}}}</var>|<var>{{{2}}}</var>|...}}</code>"
		else
			error("The template name must be given.")
		end
	end

	local function render_title(templ)
		local marker, rest

		marker, rest = templ:match("^():(.*)")
		if not marker then
			marker, rest = templ:match("^():(.*)")
		end
		if marker then
			templ = rest
			table.insert(output, ("]:"):format(marker))
		end
	
		if noargs and variables_nullary then
			table.insert(output, ("]"):format(variables_nullary, templ))
			return
		end
		
		marker, rest = templ:match("^():(.*)")
		if marker then
			templ = rest
			-- not the most accurate documentation ever
			table.insert(output, ("]:"):format(marker))
		else
			marker, rest = templ:match("^():(.*)")
			if marker then
				templ = rest	
				table.insert(output, ("]:"):format(marker)) -- ditto
			end
		end
	
		marker, rest = templ:match("^():(.*)")
		if marker then
			table.insert(output, ("]:"):format(marker)) -- missingno.
			templ = rest	
		end
		
		if templ:match("^%s*/") then
			table.insert(output, ("]"):format(templ))
			return	
		end
		
		marker, rest = templ:match("^(.-):(.*)")
		if marker then
			local lcmarker = marker:lower()
			if parser_functions then
				if parser_function_hooks then
					rest = parser_function_hooks(rest)
				end
				table.insert(output, ("]:%s"):format(mw.uri.encode(parser_functions, "WIKI"), marker, rest))
				return
			elseif variables_nonnullary then
				table.insert(output, ("]:%s"):format(variables_nonnullary, marker, rest))
				return
			end
		end
	
		if not is_valid_pagename(templ) then
			table.insert(output, templ)
			return
		end

		if marker then
			if mw.site.namespaces then
				if (title == "") or (mw.title.getCurrentTitle().fullText == templ) then -- ?? no such variable "title"
					table.insert(output, templ)
				elseif marker == "" and templ:find("^:") then
					-- for cases such as {{temp|:entry}}; MediaWiki displays ] without a colon, like ], but colon should be shown
					table.insert(output, ("]"):format(templ, templ))
				else
					table.insert(output, ("]"):format(templ, templ))
				end
				return
			elseif mw.site.interwikiMap() then
				-- XXX: not sure what to do now…
				table.insert(output, ("]:%s"):format(marker, marker, rest))
				return
			end
		end

		if (templ == "") or (mw.title.getCurrentTitle().fullText == ("Template:" .. templ)) then
			table.insert(output, templ)
		else
			table.insert(output, ("]"):format(templ, templ))
		end
	end

	render_title(templ)

	local i = (frame.args and frame.args.annotate) and 1 or 2
	while args do
		table.insert(output, "&#124;" .. args)
		i = i + 1
	end
	
	for key, value in require("Module:tablo").sortedPairs(args) do
		if type(key) == "string" then
			table.insert(output, "&#124;" .. key .. "=" .. value)
		end
	end
	
	table.insert(output, (frame.args and frame.args.nested) and "&#125;&#125;" or "&#125;&#125;</code>")
	return table.concat(output)
end

return export