Module:Variable arguments: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(35 intermediate revisions by 2 users not shown)
Line 28: Line 28:
end
end
result = "<div id=\"contentSub\">\n"
result = "<div class=\"mw-content-subtitle2\">"
.. "<div id=\"mw-content-subtitle\">\n"
.. "<div class=\"breadcrumb-article\">"
.. "<div style=\"margin: 0.5em;\"></div>\n"
.. string.format("<div class=\"subpages\">&lt; <bdi dir=\"ltr\">%s</bdi></div>", result)
.. "<div class=\"nomobile\" style=\"margin: -0.8em;\"></div>\n"
.. "</div></div>"
.. string.format("<div class=\"subpages\" style=\"margin-top: -0.1em;\">&lt; <bdi dir=\"ltr\">%s</bdi></div>\n", result)
.. "</div>\n</div>"
.. "{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}"
.. "{{#if: {{ARTICLESPACE}}||[[Category:Article subpages]]}}"
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
.. mw.getCurrentFrame():extensionTag("templatestyles", "", {
src = "Template:Breadcrumb/styles.css"
})
if yesno(debugg) == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


Line 43: Line 49:
     })
     })
     local debugg = frame.args.debug_mode or args.debug_mode
     local debugg = frame.args.debug_mode or args.debug_mode
     local fmt = "* [[Module:{{ucfirst:%s}}]]\n"
     local fmt = "* [[Module: %s]]\n"
     local namespace = string.lower(frame:preprocess("{{NAMESPACE}}"))
     local namespace = string.lower(frame:preprocess("{{NAMESPACE}}"))
local result = ""
local result = ""
local i = 0
local i = 1
for k, v in pairs(args) do
for k, v in pairs(args) do
result = result .. (v == debugg and "" or string.format(fmt, v))
result = result .. (v == debugg and "" or string.format(fmt, frame:preprocess(string.format("{{ucfirst: %s}}", v))))
i = i + 1
i = i + 1
end
end
Line 60: Line 66:
end
end
result = "<div style=\"border-collapse: collapse; border: 1px solid #a2a9b1;"
result = "{{sidebox\n| image = Lua-Logo.svg\n| image size = 30px\n| text = "
.. " background-color: #f8f9fa; box-sizing: border-box; clear: right; color: #202122; "
.. string.format("%s:\n%s\n",
.. string.format("float: right; font-size: 16px; margin: 0 0 4px 4px; width: %ipx;\">\n",
(namespace == "module" and 255 or 238))
.. "{|\n"
.. "|-\n"
.. "| <span style=\"line-height: 110%; display: inline-block; "
.. "margin: 0.125em 0em 0.125em 0.792em;\">[[File:Lua-Logo.svg|30px]]</span>"
.. " || <span style=\"display: inline-block; font-size: 0.88em; "
.. "line-height: 110%; padding: 0.22em 0.22em 0.22em 0.792em;\">"
.. string.format("%s:\n%s</span>\n",
(namespace == "module"
(namespace == "module"
and "This module depends on the following other modules"
and "This module depends on the following other modules"
or "This template uses [[wikipedia:wp:Lua|Lua]]"),
or "This template uses {{wlink|Lua|s=wp}}"),
result)
result)
.. "|}\n</div>"
.. "}}"
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
 
if yesno(debugg) == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


Line 96: Line 98:
if result == nil or utils.trim(result) == "" then
if result == nil or utils.trim(result) == "" then
result = ""
return ""
end
if yesno(debugg) == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
end
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
return frame:preprocess(result)
end
end


Line 107: Line 113:
     })
     })
     local debugg = frame.args.debug_mode or args.debug_mode
     local debugg = frame.args.debug_mode or args.debug_mode
    local fmt = "<div>'''{{wlink|%s}}'''</div>\n"
local result = ""
local result = ""
local i = 0
local i = 0
Line 114: Line 121:
if string.lower(v) ~= "false" and string.lower(v) ~= "true" then
if string.lower(v) ~= "false" and string.lower(v) ~= "true" then
result = result .. (v == debugg and "" or string.format("{{wlink|%s}}", v))
result = result .. (v == debugg and "" or string.format(fmt, v))
end
end
i = i + 1
i = i + 1
Line 121: Line 128:
if result == nil or utils.trim(result) == "" then
if result == nil or utils.trim(result) == "" then
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
result = string.format("{{wlink|%s}}", arpn)
result = string.format(fmt, arpn)
end
end
result = "<div style=\"background: #f9f9f9; border: 1px solid #aaa; clear: right; float: right; "
result = "<div class=\"wikibanner\">\n"
.. "font-size: 90%; width: 300px; margin: 0 0 4px 4px; padding: 4px 4px 4px 4px; text-align: left;\">\n"
    .. "<div class=\"wikibanner-image\">[[File:Wikipedia-logo.png|44px|none|link=|alt=]]</div>\n"
    .. "<div style=\"float: left;\">[[File:Wikipedia-logo.png|44px|none|link=|alt=]]</div>\n"
    .. "<div class=\"wikibanner-text\">"
    .. "<div style=\"margin-left: 60px;\">"
    .. string.format("English [[Wikipedia:Main Page|Wikipedia]] has %s on:\n%s</div>", (i > 1 and "articles" or "an article"), result)
    .. string.format("English [[Wikipedia:Main Page|Wikipedia]] has %s on:\n%s</div>", (i > 1 and "articles" or "an article"), result)
    .. "{{clear}}</div>"
    .. "{{clear}}</div>"
return frame:preprocess(yesno(debugg) == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
    .. mw.getCurrentFrame():extensionTag("templatestyles", "", {
src = "Template:Wikipedia/styles.css"
})
if yesno(debugg) == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p