Module:Songtable:修订间差异
(// Edit via Wikiplus) |
无编辑摘要 |
||
第62行: | 第62行: | ||
end | end | ||
box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") | if args["ID"] | ||
then | |||
box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") | |||
:done():tag("td"):wikitext("[[File:Songs_"..args["ID"]..".png|256px]]"):attr("rowspan", imageRowspan) | |||
:css("height", "256px"):css("width", "256px") | |||
else | |||
if query("id") | |||
then | |||
box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") | |||
:done():tag("td"):wikitext("[[File:Songs_"..query("id")..".png|256px]]"):attr("rowspan", imageRowspan) | |||
:css("height", "256px"):css("width", "256px") | |||
else | |||
box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") | |||
:done():tag("td"):wikitext("未指定图片"):attr("rowspan", imageRowspan) | |||
:css("height", "256px"):css("width", "256px") | |||
end | |||
end | |||
if args["曲包"] | if args["曲包"] |
2022年7月31日 (日) 16:56的版本
可在Module:Songtable/doc创建此模块的帮助文档
local p = {} local data = require("模块:Rotaeno Data") local getArgs = require('Module:Arguments').getArgs function toInteger(num) return num - num % 0.1 ^ 0 end function packName(name) if string.find(name, "%[") then return name else return "[["..name.."]]" end end function makeInvokeFunc(funcName) return function(frame) local args = getArgs(frame) return p[funcName](args) end end p.main = makeInvokeFunc('_main') function p._main(args) --生成HTML的主函数 -- 从参数或者页面名称读取曲目名称 local songName if args['曲名'] then songName = args['曲名'] else songName = mw.getCurrentFrame():preprocess("{{FULLPAGENAME}}") end -- 如果是从页面名读取的,那可能因为mediawiki限制导致页面名和曲名不符。如果有这个转换规则的话,使用转换JSON进行转换。 local covList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Transition.json' })["displayNameToSongName"] if covList[songName] then songName = covList[songName] end -- 生成查找函数。 local query = data.singleSongInformation(songName, "name") -- 如果没有来源一栏的话,图片合并行的数量减少 local imageRowspan if query("source") then imageRowspan = 13 else imageRowspan = 12 end -- 分类表 local cat = {} -- 拼html,因为内容比较简单,就不像arcaeawiki一样写数据table了。 local box = mw.html.create("table"):addClass("rotable") box:tag("tr"):tag("th"):wikitext(query("title")):attr("colspan", "6") if query("title-list") then box:tag("tr"):tag("th"):wikitext(query("title-list")):attr("colspan", "6") end if args["ID"] then box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") :done():tag("td"):wikitext("[[File:Songs_"..args["ID"]..".png|256px]]"):attr("rowspan", imageRowspan) :css("height", "256px"):css("width", "256px") else if query("id") then box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") :done():tag("td"):wikitext("[[File:Songs_"..query("id")..".png|256px]]"):attr("rowspan", imageRowspan) :css("height", "256px"):css("width", "256px") else box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("曲目信息"):attr("colspan", "5") :done():tag("td"):wikitext("未指定图片"):attr("rowspan", imageRowspan) :css("height", "256px"):css("width", "256px") end end if args["曲包"] then box:tag("tr"):tag("td"):wikitext("曲包"):done():tag("td"):wikitext(packName(args["曲包"])):attr("colspan", "4") table.insert(cat, "[[分类:"..args["曲包"].."曲包曲目]]") else box:tag("tr"):tag("td"):wikitext("曲包"):done():tag("td"):attr("colspan", "4") end if args["曲师"] then box:tag("tr"):tag("td"):wikitext("曲师"):done():tag("td"):wikitext(args["曲师"]):attr("colspan", "4") else box:tag("tr"):tag("td"):wikitext("曲师"):done():tag("td"):wikitext(query("artist")):attr("colspan", "4") end if args["画师"] then box:tag("tr"):tag("td"):wikitext("谱师"):done():tag("td"):wikitext(args["谱师"]):attr("colspan", "4") else box:tag("tr"):tag("td"):wikitext("谱师"):done():tag("td"):wikitext(query("JacketDesigner")):attr("colspan", "4") end -- 来源有可能没有 if args["来源"] or query("source") then if args["来源"] then box:tag("tr"):tag("td"):wikitext("来源"):done():tag("td"):wikitext(args["来源"]):attr("colspan", "4") else box:tag("tr"):tag("td"):wikitext("来源"):done():tag("td"):wikitext(query("source")):attr("colspan", "4") end end box:tag("tr"):tag("td"):wikitext("时长"):done():tag("td"):wikitext(args["时长"]):attr("colspan", "4") box:tag("tr"):addClass("rotable-title"):tag("th"):wikitext("谱面信息"):attr("colspan", "5") if args["谱师"] then box:tag("tr"):tag("td"):wikitext("谱师"):done():tag("td"):wikitext(args["谱师"]):attr("colspan", "4") else box:tag("tr"):tag("td"):wikitext("谱师"):done():tag("td"):wikitext(query("ChartDesigner")):attr("colspan", "4") end box:tag("tr"):tag("td"):wikitext("难度"):done() :tag("td"):wikitext("难度I"):css("color", "#43a047"):done() :tag("td"):wikitext("难度Ⅱ"):css("color", "#1565c0"):done() :tag("td"):wikitext("难度Ⅲ"):css("color", "#e65100"):done() :tag("td"):wikitext("难度Ⅳ"):css("color", "#ab47bc") if args["难度I等级"] and args["难度I等级"] and args["难度III等级"] and args["难度IV等级"] then box:tag("tr"):tag("td"):wikitext("等级"):done() -- 删除小数 :tag("td"):wikitext(args["难度I等级"]):done() :tag("td"):wikitext(args["难度II等级"]):done() :tag("td"):wikitext(args["难度III等级"]):done() :tag("td"):wikitext(args["难度IV等级"]) table.insert(cat, "[[分类:等级I中"..args["难度I等级"].."级曲目]]") table.insert(cat, "[[分类:等级II中"..args["难度II等级"].."级曲目]]") table.insert(cat, "[[分类:等级III中"..args["难度III等级"].."级曲目]]") table.insert(cat, "[[分类:等级IV中"..args["难度IV等级"].."级曲目]]") else box:tag("tr"):tag("td"):wikitext("等级"):done() -- 删除小数 :tag("td"):wikitext(toInteger(query("rating1"))):done() :tag("td"):wikitext(toInteger(query("rating2"))):done() :tag("td"):wikitext(toInteger(query("rating3"))):done() :tag("td"):wikitext(toInteger(query("rating4"))) if query("title") then table.insert(cat, "[[分类:等级I中"..toInteger(query("rating1")).."级曲目]]") table.insert(cat, "[[分类:等级II中"..toInteger(query("rating2")).."级曲目]]") table.insert(cat, "[[分类:等级III中"..toInteger(query("rating3")).."级曲目]]") table.insert(cat, "[[分类:等级IV中"..toInteger(query("rating4")).."级曲目]]") end end box:tag("tr"):tag("td"):wikitext("Note数量"):done() :tag("td"):wikitext(args["等级I物量"]):done() :tag("td"):wikitext(args["等级II物量"]):done() :tag("td"):wikitext(args["等级III物量"]):done() :tag("td"):wikitext(args["等级IV物量"]) box:tag("tr"):tag("td"):wikitext("更新时间"):done():tag("td"):wikitext(args["更新时间"]):attr("colspan", "4") if args["更新时间"] then table.insert(cat, "[[分类:时间"..args["更新时间"].."更新的曲目]]") end box:tag("tr"):tag("td"):wikitext("更新版本"):done():tag("td"):wikitext(args["更新版本"]):attr("colspan", "4") if args["更新版本"] then table.insert(cat, "[[分类:版本"..args["更新版本"].."更新的曲目]]") end return tostring(box)..table.concat(cat) end return p