Modul:wikipedia
Megjelenés
A modult a Modul:wikipedia/doc lapon tudod dokumentálni
local export = {}
local function process_links(linkdata, prefix, name, wmlang, sc)
prefix = prefix .. ":" .. (wmlang:getCode() == "hu" and "" or wmlang:getCode() .. ":")
local links = {}
local iplinks = {}
local m_links = require("Module:links")
local lang = wmlang:getWiktionaryLanguage()
local ipalt = name .. " " .. (wmlang:getCode() == "hu" and "" or "<sup>" .. wmlang:getCode() .. "</sup>")
for i, link in ipairs(linkdata) do
link.lang = lang
link.sc = sc
link.term = prefix .. link.term
link.tr = "-"
-- used by [[:en:MediaWiki:Gadget-AggregateInterprojectLinks.js]], not on huwiktionary
-- 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 = "hu"},
["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("A(z) „" .. args["lang"] .. "” Wikimédia-nyelvkód érvénytelen.")
local sc = args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("A(z) „" .. args["sc"] .. "” ábécékód érvénytelen.")) 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", "Wikipédia", wmlang, sc)
local langname
if wmlang:getCode() == "hu" then
langname = "A " -- Wikipédia
elseif wmlang:getCode() == "en" then
langname = "Az angol"
else
langname = "A " .. wmlang:getCanonicalName()
end
if frame.args["slim"] then
langname = langname:gsub('^A', 'a')
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|Wikipédia]]</div>" ..
"<div style=\"margin-left: 15px;\">" ..
" " ..
mw.text.listToText(links) .. " " ..
langname ..
" Wikipédián" ..
"</div>" ..
"</div>"
else
local linktype
if args["cat"] then
linktype = "van ilyen témájú kategóriája"
elseif args["mul"] or args["dab"] then
linktype = "vannak ilyen témájú szócikkei"
elseif args["mulcat"] then
linktype = "vannak ilyen témájú kategóriái"
elseif args["portal"] then
linktype = "van ilyen témájú portálja"
else
linktype = "van ilyen témájú szócikke"
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;\">[[Fájl:Wikipedia-logo-v2.svg|44px|Wikipédia]]</div>" ..
"<div style=\"margin-left: 60px;\">" .. langname .. " [[Wikipédia|Wikipédiának]] " .. linktype .. ":" ..
"<div style=\"margin-left: 10px;\">" .. mw.text.listToText( links ) .. "</div>" ..
"</div>" ..
table.concat(iplinks) .. ((args[1] == mw.title.getCurrentTitle().text and not (args[2] or args["dab"])) and "[[Kategória:Wikipédia-sablon redundáns első paraméterrel]]" or "") ..
"</div>"
end
end
function export.projectlink(frame)
local params = {
[1] = {},
[2] = {},
["dab"] = {},
["i"] = {type = "boolean"},
["lang"] = {default = "hu"},
["nodot"] = {},
["sc"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args["lang"]) or error("A(z) „" .. args["lang"] .. "” Wikimédia-nyelvkód érvénytelen.")
local sc = args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("A(z) „" .. args["sc"] .. "” ábécékód érvénytelen.")) 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)
local langname
if wmlang:getCode() == "hu" then
langname = "magyar"
elseif wmlang:getCode() == "en" then
langname = "angol"
else
langname = wmlang:getCanonicalName()
end
return
"[[Image:" .. frame.args["image"] .. "|15px|link=" .. linkdata.term .. "]] " ..
mw.text.listToText( links ) .. " - Wikipédia (" .. langname .. ")" .. (args["nodot"] and "" or "") ..
table.concat(iplinks)
end
return export