local p = {}
local getArgs = require('Module:Arguments').getArgs
function p._main(args, frame)
-- Parameters
local bgcolor = args.bgcolor or 'rgba(236,248,255,0.8)'
local rawWidth = tonumber(args.width) or 68
local width = rawWidth % 100 -- mirrors {{#expr:{{{width|68}}} mod 100}}
local image = args.image or ''
local border = args.border or ''
local color = args.color or '#098BDE'
local vr = args.vr or ''
local article = args.article or ''
local exclamation = args.exclamation or 'Kira~'
local linkcolor = args.linkcolor or ''
local watchword = args.watchword or ''
-- ── Icon block ───────────────────────────────────────────────────────────
-- Circular image (optional)
local imageHtml = ''
if image ~= '' then
local borderStyle = ''
local imgSize = width
if border ~= '' then
borderStyle = string.format('border:3px solid %s;', color)
imgSize = width - 6
end
imageHtml = string.format(
'<div style="width:%dpx; height:%dpx; border-radius:50%%;'
.. ' overflow:hidden; box-sizing:border-box; %s">[[File:%s|%dpx]]</div>',
width, width, borderStyle, image, imgSize
)
end
-- Logo overlay (VirtuaReal or Nijisanji)
local logoHtml
if vr ~= '' then
local logoSize = math.floor(width / 68 * 76)
logoHtml = string.format(
'<div style="position:absolute; left:calc(20px - %s/68*2px);'
.. ' top:calc(50%% - %s/68*25px); border-radius:50%%;">'
.. '[[File:Virtua real.png|%dpx|link=VirtuaReal]]</div>',
width, width, logoSize
)
else
local logoSize = math.floor(width / 68 * 66)
logoHtml = string.format(
'<div style="position:absolute; left:calc(20px + %s/68*1px);'
.. ' top:calc(50%% - %s/68*33px); border-radius:50%%;">'
.. '[[File:Nijisanji Logo2c.png|%dpx|link=彩虹社]]</div>',
width, width, logoSize
)
end
local iconHtml = string.format(
'<div class="infoBoxIcon" style="position:relative; min-width:%dpx; height:%dpx;'
.. ' padding:calc(%d/68*12px) 20px; perspective:calc(%d/68*150px);'
.. ' box-sizing:content-box;">%s%s</div>',
width, width, width, width, imageHtml, logoHtml
)
-- ── Text block ───────────────────────────────────────────────────────────
-- Resolve |article= default (coloredlink to VirtuaReal or 彩虹社)
local articleText
if article ~= '' then
articleText = article
else
local target = (vr ~= '') and 'VirtuaReal' or '彩虹社'
-- Replicate {{coloredlink|color|target}}
articleText = string.format('[[%s|<span style="color:%s;">%s</span>]]', target, color, target)
end
-- Optional improvement list (|1=, |2=, …)
local improveLine = ''
local ulItems = {}
local i = 1
while args[i] do
local v = mw.text.trim(args[i])
if v ~= '' then
table.insert(ulItems, '<li>' .. frame:preprocess(v) .. '</li>')
end
i = i + 1
end
if #ulItems > 0 then
improveLine = '可以从以下几个方面加以改进:<br><ul>'
.. table.concat(ulItems)
.. '</ul>'
end
-- Helper: coloured hyperlink using fullurl
local function colorLink(display, pageName, lc)
local url = tostring(mw.uri.fullUrl(pageName))
if lc and lc ~= '' then
return string.format('[%s <span style="color:%s;">%s</span>]', url, lc, display)
else
return string.format('[%s %s]', url, display)
end
end
-- "编辑本条目" uses ColoredEdit – replicate with a simple edit link
local editUrl = tostring(mw.uri.fullUrl(mw.title.getCurrentTitle().fullText, { action = 'edit' }))
local editLink
if linkcolor ~= '' then
editLink = string.format('[%s <span style="color:%s;">编辑本条目</span>]', editUrl, linkcolor)
else
editLink = string.format('[%s 编辑本条目]', editUrl)
end
local qq1 = (linkcolor ~= '' and linkcolor ~= nil)
and string.format('[https://qm.qq.com/q/kcFEEuZIeQ <span style="color:%s;">273049699</span>]', linkcolor)
or '[https://qm.qq.com/q/kcFEEuZIeQ 273049699]'
local qq2 = (linkcolor ~= '' and linkcolor ~= nil)
and string.format('[https://jq.qq.com/?k=HsHGK3Eh <span style="color:%s;">759974951</span>]', linkcolor)
or '[https://jq.qq.com/?k=HsHGK3Eh 759974951]'
local textContent = string.format(
"'''萌娘百科欢迎您参与完善%s☆%s'''<br>%s"
.. '协助%s前,请先阅读%s及%s,同时欢迎加入%s(QQ群:%s)与%s(QQ群:%s)与更多同好编辑者交流。'
.. '祝您在萌娘百科度过愉快的时光。',
articleText,
exclamation,
improveLine,
editLink,
colorLink('条目编辑规范', '萌娘百科:编辑规范', linkcolor),
colorLink('虚拟UP主编辑指引', '萌娘百科:虚拟UP主专题编辑指引', linkcolor),
colorLink('萌娘百科虚拟UP主编辑组', 'Template:萌娘百科虚拟UP主编辑组', linkcolor),
qq1,
colorLink('萌娘百科彩虹社编辑组', 'Template:萌娘百科彩虹社编辑组', linkcolor),
qq2
)
-- Optional watchword overlay
local watchwordHtml = ''
if watchword ~= '' then
watchwordHtml = string.format(
'<div style="display:flex; position:absolute; top:0; bottom:0; left:0; right:0;'
.. ' align-items:center; justify-content:center; white-space:nowrap;'
.. ' font-weight:bold; font-size:0.8vw;">%s</div>',
watchword
)
end
local textHtml = string.format(
'<div class="infoBoxText plainlinks"'
.. ' style="position:relative; padding-left:0; color:%s; overflow:hidden;">'
.. '<div>%s</div>%s</div>',
color, textContent, watchwordHtml
)
-- ── Outer wrapper ────────────────────────────────────────────────────────
return string.format(
--'<templatestyles src="彩虹社TOP/styles.css" />'
'<div class="infoBox NijiTop" style="max-width:100%%;">'
.. '<div class="infoBoxContent" style="background:%s;">'
.. '%s%s'
.. '</div></div>',
bgcolor, iconHtml, textHtml
)
end
function p.main(frame)
local args = getArgs(frame, { parentFirst = true })
return p._main(args, frame)
end
return p