Jump to content

Module:wikipedia

Hali sa Wiksyunaryo


An plantilyang ini nagpapahiling nin mga tugang na proyekto na nakalink sa sarong pahina sa Wikipedya.

Dapat an plantilyang ini inilalaag sa seksyon na tinutukoy kaniu pagkatapos kan header. Bilang default, (nakasusog ini sa sarong artikulo sa Bikol Sentral Wikipedya) ikaag ini sa ibaba kan ==Bikol Sentral== header. Kun igwa pa nin imahe o ibang plantilya, dapat ining maenot.

Pwede man gamiton an mga plantilya na: {{projectlink|pedia}} (shortcut: {{pedia}}).

Parametro

Gabos na parametro opsyonal.

lang=
Hinahagad an koda kan lenggwahe (hilingon an Wiktionary:Wikimedia language codes) kan bersyon kan Wikipedya kun sain ini isususog.
1=
Hinahagad an pahina kan Wikipedia kun sain ini konektado. Bilang default, ini pareho kan ngaran sa yaun na pahina sa Wiksyunaryo.
2=
Pig-ooverride an pinapahiling na porma kan link
dab= o disambiguation=
Hinahagad an pagkakaribong kan pahina sa link
cat= o category=
Hinahagad an kategorya kan pahina sa link
portal=
Hinahagad an portal kan pahina sa link
mul=
Nagtatao nin panduwang artikulo kun sain isusugpon
mullabel=
Pig-ooverride an pinapahiling na porma kan panduwang link
mulcat=
Hinahagad an panduwang kategorya kan link
mulcatlabel=

Mga Ehemplo

Mga simpleng porma:

  1. {{wikipedia}}
  2. {{wikipedia|article}}
  3. {{wikipedia|article|link title}}
  4. {{wikipedia|lang=language code}}
  5. {{wikipedia|article|lang=language code}}
  6. {{wikipedia|article|link title|lang=language code}}
  7. {{wikipedia|dab=disambiguation page}}
  8. {{wikipedia|dab=disambiguation page|link title}}
  9. {{wikipedia|article|link title|mul=second article}}
  10. {{wikipedia|article|link title|mul=second article|mullabel=second link title}}
  11. {{wikipedia|cat=category}}
  12. {{wikipedia|cat=category|link title}}
  13. {{wikipedia|cat=category|link title|mulcat=second category}}
  14. {{wikipedia|cat=category|link title|mulcat=second category|mulcatlabel=second link title}}
  15. {{wikipedia|portal=energy}}
{{wikipedia|Domingo}}
Bikol Sentral Wikipedya igwa nin artikulo sa:
{{wikipedia|Trunk (botany)|trunk}}
Bikol Sentral Wikipedya igwa nin artikulo sa:
{{wikipedia|Lunes|lang=it}}
Italyano Wikipedya igwa nin artikulo sa:
it
{{wikipedia|category=mga kulay}}
Bikol Sentral Wikipedya igwa nin kategorya sa:
{{wikipedia|category=mga kulay|mulcat=pambanasang kulay}}
Bikol Sentral Wikipedya igwa nin kategorya sa:
{{wikipedia|lang=es|category=colores |mga kulay|mulcat=pintura|mulcatlabel=mga pinta}}
Espanyol Wikipedya igwa nin kategorya sa:
es es
{{wikipedia|portal=enerhiya}}
Bikol Sentral Wikipedya igwa nin portal sa:


TemplateData

Plantilya:TemplateDataHeader

Links Wikipedia in a box that floats to the right

Template parameters[Edit template data]

This template has custom formatting.

ParameterDescriptionTypeStatus
Article to link1

Article to link to on the Wikipedia

Default
{{subst:BASEPAGENAME}}
Example
color
Linesuggested
Link label2

If provided, overrides the displayed form of the link

Example
colors
Lineoptional
Disambiguation page to linkdab disambiguation

Disambiguation page to link on Wikipedia, instead of linking to an article

Example
wrong (disambiguation)
Lineoptional
Category to linkcat category

Category to link on Wikipedia, instead of an article

Example
colors
Lineoptional
Portal to linkportal

Portal to link on Wikipedia, instead of an article

Example
energy
Lineoptional
Language codelang

Wikipedia language code for the Wikipedia language to link

Default
en
Example
es
Lineoptional
2nd article to linkmul

Provides a second article to link to

Example
painting
Lineoptional
2nd article labelmullabel

Overrides the displayed form of the second link.

Example
paintings
Lineoptional
2nd category to linkmulcat

Second category to link on Wikipedia, replacing the second article link

Lineoptional
2nd category labelmulcatlabel

If provided, overrides the displayed form of the second category

Lineoptional

local export = {}


local function process_links(linkdata, prefix, name, wmlang, sc)
	prefix = prefix .. ":" .. (wmlang:getCode() == "bcl" and "" or wmlang:getCode() .. ":")
	
	local links = {}
	local iplinks = {}
	
	local m_links = require("Module:links")
	local lang = wmlang:getWiktionaryLanguage()
	local ipalt = name .. " " .. (wmlang:getCode() == "bcl" and "" or "" .. wmlang:getCode() .. "</sup>")
	
	for i, link in ipairs(linkdata) do
		link.lang = lang
		link.sc = sc
		link.term = prefix .. link.term
		link.tr = "-"
		table.insert(iplinks, "<span class=\"interProject\">[[" .. link.term .. "|" .. ipalt .. "]]</span>")
		table.insert(links, m_links.full_link(link, "bold"))
	end
	
	return links, iplinks
end


function export.wikipedia_box(frame)
	local params = {
		[1] = {},
		[2] = {},
		
		["cat"] = {},
		["category"] = {alias_of = "cat"},
		["dab"] = {},
		["disambiguation"] = {alias_of = "dab"},
		["i"] = {type = "boolean"},
		["lang"] = {default = "bcl"},
		["mul"] = {},
		["mullabel"] = {},
		["mulcat"] = {},
		["mulcatlabel"] = {},
		["portal"] = {},
		["sc"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args["lang"]) or error("The Wikimedia language code \"" .. args["lang"] .. "\" is not valid.")
	local sc = args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. sc .. "\" is not valid.")) or nil
	
	local linkdata = {}
	
	if args["cat"] then
		table.insert(linkdata, {term = "Category:" .. args["cat"], alt = args[1] or args["cat"]})
	elseif args["portal"] then
		table.insert(linkdata, {term = "Portal:" .. args["portal"], alt = args[1] or args["portal"]})
	else
		table.insert(linkdata, {term = args["dab"] or args[1] or mw.title.getCurrentTitle().text, alt = args[2] or args[1] or args["dab"] or mw.title.getCurrentTitle().text})
	end
	
	if args["mul"] or args["mulcat"] then
		if args["mulcat"] then
			table.insert(linkdata, {term = "Category:" .. args["mulcat"], alt = args["mulcatlabel"] or args["mulcat"]})
		else
			table.insert(linkdata, {term = args["mul"], alt = args["mullabel"] or args["mul"]})
		end
	end
	
	local links, iplinks = process_links(linkdata, "w", "", wmlang, sc)
	
	if frame.args["slim"] then
		return
			"<div class=\"sister-wikipedia sister-project noprint floatright\" style=\"border: solid #aaa 1px; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; text-align: left;\">" ..
			"<div style=\"float: left;\">[[File:Wikipedia-logo-v2.svg|14px|none| ]]</div>" ..
			"<div style=\"margin-left: 15px;\">" ..
			" &nbsp;" ..
			table.concat(links, " and ") ..
			" on " ..
			(wmlang:getCode() == "bcl" and "en" or wmlang:getCanonicalName() .. "&nbsp;") ..
			"Hilingon" ..
			"</div>" ..
			"</div>"
	else
		local linktype
		
		if args["cat"] then
			linktype = "kategorya"
		elseif args["mul"] or args["dab"] then
			linktype = "mga artikulo"
		elseif args["mulcat"] then
			linktype = "mga kategorya"
		elseif args["portal"] then
			linktype = "portal"
		else
			linktype = "artikulo"
		end
		
		return
			"<div class=\"sister-wikipedia sister-project noprint floatright\" style=\"border: 1px solid #aaa; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; text-align: left;\">" ..
			"<div style=\"float: left;\">[[File:Wikipedia-logo-v2.svg|44px|none|link=|alt=]]</div>" ..
			"<div style=\"margin-left: 60px;\">" ..
			wmlang:getCanonicalName() .. " Wikipedya igwa nin " .. linktype .. " sa:" ..
			"<div style=\"margin-left: 10px;\">" .. table.concat(links, " asin ") .. "</div>" ..
			"</div>" ..
			table.concat(iplinks) .. ((args[1] == mw.title.getCurrentTitle().text and not (args[2] or args["dab"])) and "[[Category:wikipedia with redundant first parameter]]" or "") ..
			"</div>"
	end
end


function export.projectlink(frame)
	local params = {
		[1] = {},
		[2] = {},
		
		["dab"] = {},
		["i"] = {type = "boolean"},
		["lang"] = {default = "bcl"},
		["nodot"] = {},
		["sc"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args["lang"]) or error("The Wikimedia language code \"" .. args["lang"] .. "\" is not valid.")
	local sc = args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. sc .. "\" is not valid.")) or nil
	
	local linkdata = {term = args[1] or args["dab"] or mw.title.getCurrentTitle().text, alt = args[2] or args[1] or args["dab"] or mw.title.getCurrentTitle().text}
	
	if args["i"] then
		linkdata.alt = "''" .. linkdata.alt .. "''"
	end
	
	local links, iplinks = process_links({linkdata}, frame.args["prefix"], frame.args["name"], wmlang, sc)
	
	return
		"[[Image:" .. frame.args["image"] .. "|15px|link=" .. linkdata.term .. "]] " ..
		table.concat(links, " and ") ..
		" on " ..
		(wmlang:getCode() == "" and "" or "the " .. wmlang:getCanonicalName() .. " ") ..
		" " .. frame.args["name"] .. (args["nodot"] and "" or ".") ..
		table.concat(iplinks)
end

return export