WikiBuilder
329
个编辑
小 (修复+优化) |
小无编辑摘要 |
||
第38行: | 第38行: | ||
end | end | ||
local function summonTalkShow(tag,txt) | local function summonTalkShow(tag,txt,CName) | ||
CName = CName or {} | |||
local tableHTML = tag:tag("table"):addClass("talkShow") | local tableHTML = tag:tag("table"):addClass("talkShow") | ||
local l = getTextList(txt,'\n',"(.-)%c"); | local l = getTextList(txt,'\n',"(.-)%c"); | ||
第55行: | 第56行: | ||
_type = getParam(a,"type") or 'talk' | _type = getParam(a,"type") or 'talk' | ||
node = tableHTML:tag('tr') | node = tableHTML:tag('tr') | ||
:tag('th'):wikitext(n):done() | :tag('th'):wikitext(CName[n] or n):done() | ||
:tag('td') | :tag('td') | ||
else | else | ||
第66行: | 第67行: | ||
else node:tag('span'):addClass('thought'):wikitext(b):done() | else node:tag('span'):addClass('thought'):wikitext(b):done() | ||
end | end | ||
else node:tag("span"):addClass("storyError"):wikitext(string.format("警告:无法识别类型名!(line=%d)",i)):done(); | else (node or tableHTML:tag('tr') | ||
:tag('th'):wikitext('[Warning]'):done() | |||
:tag('td')):tag("span"):addClass("storyError"):wikitext(string.format("警告:无法识别类型名!(line=%d)",i)):done(); | |||
end | end | ||
if not isEmpty then node:wikitext('<br>') end | if not isEmpty then (node or tableHTML:tag('tr') | ||
:tag('th'):wikitext('[Warning]'):done() | |||
:tag('td')):wikitext('<br>') end | |||
end | end | ||
end | end | ||
第82行: | 第87行: | ||
p.main = makeInvokeFunc('_main') | p.main = makeInvokeFunc('_main') | ||
function p._main(args)-- 生成HTML的主函数 部分代码来源:[[Module:Songtable]] | function p._main(args)-- 生成HTML的主函数 部分代码来源:[[Module:Songtable]] | ||
--- 构建HTML --- | --- 构建HTML --- | ||
local box = mw.html.create("table"):addClass("rotable mw-collapsible mw-collapsed storyTable"); | local box = mw.html.create("table"):addClass("rotable mw-collapsible mw-collapsed storyTable"); | ||
box:tag('tr'):tag('th'):wikitext(args['title'] or "标题"); | box:tag('tr'):tag('th'):wikitext(args['title'] or "标题"); | ||
if args['autoUpload']then | |||
local rawTxt = mw.getCurrentFrame():expandTemplate{ title = 'Stories/' .. args['fName'] }; | |||
local CNameTxt = mw.getCurrentFrame():expandTemplate{ title = 'Stories/CName' }; | |||
local CName = {}; ---@type table | |||
for n,t in string.gmatch(CNameTxt .. '\n','([%a%d%-]*): (.-)\n')do | |||
CName[n] = t; | |||
end | |||
local tag = box:tag("tr"):tag("td"):addClass("storySim"); | |||
tag:tag('span'):addClass("storyWarning"):wikitext('该文本为自动生成,如有错误请及时指出。'):done() | |||
summonTalkShow(tag,rawTxt,CName); | |||
return tostring(box); | |||
end | |||
for index, arg in ipairs(args) do | for index, arg in ipairs(args) do | ||
local tag = box:tag("tr"):tag("td"):addClass("storySim"); | local tag = box:tag("tr"):tag("td"):addClass("storySim"); |