Modul:vikipediya
Bu modul uchun Modul:vikipediya/doc nomli hujjat sahifasini yaratishingiz mumkin
local export = {}
local function process_links(linkdata, prefix, name, wmlang, sc)
prefix = prefix .. ":" .. (wmlang:getCode() == "uz" and "" or wmlang:getCode() .. ":")
local links = {}
local iplinks = {}
local m_links = require("Module:links")
local tili = wmlang:getWiktionaryLanguage()
local ipalt = name .. " " .. (wmlang:getCode() == "uz" and "" or "<sup>" .. wmlang:getCode() .. "</sup>")
for i, link in ipairs(linkdata) do
link.tili = tili
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.vikipediya_box(rama)
local params = {
[1] = {},
[2] = {},
["cat"] = {},
["turkum"] = {alias_of = "cat"},
["dab"] = {},
["disambiguation"] = {alias_of = "dab"},
["i"] = {type = "boolean"},
["tili"] = {default = "uz"},
["mul"] = {},
["mullabel"] = {},
["mulcat"] = {},
["mulcatlabel"] = {},
["portal"] = {},
["sc"] = {},
}
local args = require("Module:parameters").process(rama:getParent().args, params)
local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args["tili"]) or error("The Wikimedia language code \"" .. args["tili"] .. "\" 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 = "Turkum:" .. 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 = "Turkum:" .. 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, "v", "Vikipediya", wmlang, sc)
if rama.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: 2px; text-align: left;\">" ..
"<div style=\"float: left;\">[[File:Wikipedia-logo.png|14px|none| ]]</div>" ..
"<div style=\"margin-left: 15px;\">" ..
" " ..
table.concat(links, " va ") ..
" on " ..
(wmlang:getCode() == "uz" and "" or wmlang:getCanonicalName() .. " ") ..
"Vikipediya" ..
"</div>" ..
"</div>"
else
local linktype
if args["cat"] then
linktype = "a turkum"
elseif args["mul"] or args["dab"] then
linktype = "articles"
elseif args["mulcat"] then
linktype = "turkumlar"
elseif args["portal"] then
linktype = "a portal"
else
linktype = "an article"
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.png|44px|none|link=|alt=]]</div>" ..
"<div style=\"margin-left: 60px;\">" ..
(wmlang:getCode() == "uz" and "" or wmlang:getCanonicalName() .. " ") .. "[[Vikipediya]] has " .. linktype .. " on:" ..
"<div style=\"margin-left: 10px;\">" .. table.concat(links, " va ") .. "</div>" ..
"</div>" ..
table.concat(iplinks) .. ((args[1] == mw.title.getCurrentTitle().text and not (args[2] or args["dab"])) and "[[Turkum:Ortiqcha birinchi parametr bilan Vikipediya]]" or "") ..
"</div>"
end
end
function export.projectlink(rama)
local params = {
[1] = {},
[2] = {},
["dab"] = {},
["i"] = {type = "boolean"},
["tili"] = {default = "uz"},
["nodot"] = {},
["sc"] = {},
}
local args = require("Module:parameters").process(rama:getParent().args, params)
local wmlang = require("Module:wikimedia languages").getByCodeWithFallback(args["tili"]) or error("The Wikimedia language code \"" .. args["tili"] .. "\" 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}, rama.args["prefix"], rama.args["name"], wmlang, sc)
return
"[[Fayl:" .. rama.args["fayl"] .. "|15px|link=" .. linkdata.term .. "]] " ..
table.concat(links, " va ") ..
" on " ..
(wmlang:getCode() == "uz" and "" or "bu " .. wmlang:getCanonicalName() .. " ") ..
" " .. rama.args["name"] .. (args["nodot"] and "" or ".") ..
table.concat(iplinks)
end
return export