Module:曲目页面:修订间差异
歌词段落缺省文案:「(待补充)」→「纯音乐,请欣赏」(纯音乐曲目不再显示待补充) |
曲师→曲师列表、谱师→谱师列表 自动索引;autoUnlock 支持 教程/剧情模式 |
||
| 第4行: | 第4行: | ||
local DATA_TITLE = '模板:曲目列表.json' | local DATA_TITLE = '模板:曲目列表.json' | ||
local validator = require('模块:数据页校验') | local validator = require('模块:数据页校验') | ||
local parse = require('模块:署名解析') | |||
local ARTIST_MAP = '模板:曲师映射.json' | |||
local CHARTER_MAP = '模板:谱师映射.json' | |||
local function esc(s) | local function esc(s) | ||
| 第27行: | 第30行: | ||
end | end | ||
return v or '' | return v or '' | ||
end | |||
local function loadJson(title) | |||
local t = mw.title.new(title) | |||
if not t or not t.exists then return nil end | |||
local ok, data = pcall(mw.text.jsonDecode, t:getContent()) | |||
if not ok then return nil end | |||
return data | |||
end | |||
-- 署名 → 链到 [[<列表页>#主名义]](马甲/合作名义自动归并) | |||
local function linkedCredits(raw, lk, page) | |||
if not raw or raw == '' then return '' end | |||
local parts = parse.attribute(lk, raw) or parse.parts(raw) | |||
local out = {} | |||
for _, pt in ipairs(parts) do | |||
out[#out + 1] = '[[' .. page .. '#' .. esc(pt.base) .. '|' .. esc(pt.base) .. ']]' | |||
end | |||
return table.concat(out, ' / ') | |||
end | end | ||
| 第72行: | 第94行: | ||
return '(待补充)' | return '(待补充)' | ||
end | end | ||
if pack == '免费单曲' then | if pack == '教程' then | ||
return '游戏内教学关卡,无需解锁' | |||
elseif pack == '剧情模式' then | |||
return '剧情模式内出现' | |||
elseif pack == '免费单曲' then | |||
return '无需解锁' | return '无需解锁' | ||
elseif pack == '免费单曲(商店)' then | elseif pack == '免费单曲(商店)' then | ||
| 第117行: | 第143行: | ||
table.insert(out, '<div class="song-tagline">' .. tagline .. '</div>') | table.insert(out, '<div class="song-tagline">' .. tagline .. '</div>') | ||
end | end | ||
local artistLk = parse.buildLookup(loadJson(ARTIST_MAP)) | |||
local charterLk = parse.buildLookup(loadJson(CHARTER_MAP)) | |||
-- 信息框: 自动填 标题/图片/曲师/曲包/定数/谱师/时长/BPM, 手工传参可覆盖 | -- 信息框: 自动填 标题/图片/曲师/曲包/定数/谱师/时长/BPM, 手工传参可覆盖 | ||
| 第127行: | 第156行: | ||
table.insert(out, '|图片= [[文件:曲绘-' .. esc(art) .. '.png|256px]]') | table.insert(out, '|图片= [[文件:曲绘-' .. esc(art) .. '.png|256px]]') | ||
end | end | ||
table.insert(out, '|曲师= ' .. | table.insert(out, '|曲师= ' .. arg(frame, '曲师', linkedCredits(song['曲师'], artistLk, '曲师列表'))) | ||
-- 曲包: 手工传参优先; 否则自动生成指向 曲包列表#<曲包名> 的链接 | -- 曲包: 手工传参优先; 否则自动生成指向 曲包列表#<曲包名> 的链接 | ||
local packArg = frame.args['曲包'] | local packArg = frame.args['曲包'] | ||
| 第142行: | 第171行: | ||
for _, d in ipairs({ 'CASUAL', 'TOUGH', 'INSANE', 'PRO' }) do | for _, d in ipairs({ 'CASUAL', 'TOUGH', 'INSANE', 'PRO' }) do | ||
table.insert(out, '|' .. d .. '定数= ' .. fmt(consts[d])) | table.insert(out, '|' .. d .. '定数= ' .. fmt(consts[d])) | ||
table.insert(out, '|' .. d .. '谱师= ' .. | table.insert(out, '|' .. d .. '谱师= ' .. arg(frame, d .. '谱师', linkedCredits(charters[d], charterLk, '谱师列表'))) | ||
table.insert(out, '|' .. d .. '连击= ' .. esc(arg(frame, d .. '连击', ''))) | table.insert(out, '|' .. d .. '连击= ' .. esc(arg(frame, d .. '连击', ''))) | ||
end | end | ||