| 第23行: |
第23行: |
| | local content = "" | | local content = "" |
| | content = content .. "创作者: " | | content = content .. "创作者: " |
| | + | local l = {} |
| | + | local il = 1 |
| | for i, m in ipairs(maintainers) do | | for i, m in ipairs(maintainers) do |
| − | content = content .. "[[User:"..m.."|"..m.."]]" | + | local n = m:match("^用户:(.+)$") |
| − | content = content .. "[[Category:由"..m.."维护的条目]]" | + | local s = "" |
| − | content = content .. "[[Category:由"..m.."创作的条目]]" | + | s = s .. "[[用户:"..n.."|"..n.."]]" |
| | + | s = s .. "[[Category:由"..n.."维护的条目]]" |
| | + | s = s .. "[[Category:由"..n.."创作的条目]]" |
| | + | l[il] = s |
| | + | il = il + 1 |
| | mw.smw.set({ | | mw.smw.set({ |
| − | ['Editable by user'] = 'User:'..m | + | ['Editable by user'] = 'User:'..n |
| | }) | | }) |
| | end | | end |
| | for i, m in ipairs(other_creators) do | | for i, m in ipairs(other_creators) do |
| − | content = content .. "[[创作者:"..m.."|"..m.."]]" | + | local n = m:match("^创作者:(.+)$") |
| − | content = content .. "[[Category:由"..m.."创作的条目]]" | + | local s = "" |
| | + | s = s .. "[[创作者:"..n.."|"..n.."]]" |
| | + | s = s .. "[[Category:由"..n.."创作的条目]]" |
| | + | l[il] = s |
| | + | il = il + 1 |
| | end | | end |
| | + | content = content .. mw.text.listToText(l) |
| | local args = {image = 'Copyright.svg', content = content} | | local args = {image = 'Copyright.svg', content = content} |
| | return frame:expandTemplate{title = "LiteInfoBox", args = args} | | return frame:expandTemplate{title = "LiteInfoBox", args = args} |
| 第80行: |
第91行: |
| | out = out .. "[[Category:联动介绍页]]" | | out = out .. "[[Category:联动介绍页]]" |
| | out = out .. "[[Category:联动设定]]" | | out = out .. "[[Category:联动设定]]" |
| − | else -- 公共设定 | + | elseif type == "公共设定" then |
| | out = out .. (renderLiteInfoBox(frame, "SharedItem.svg", "公共设定页")) | | out = out .. (renderLiteInfoBox(frame, "SharedItem.svg", "公共设定页")) |
| | mw.smw.set({['设定类型'] = "公共设定"}) | | mw.smw.set({['设定类型'] = "公共设定"}) |
| | out = out .. "[[Category:公共设定]]" | | out = out .. "[[Category:公共设定]]" |
| | + | else -- 共享文档页 |
| | + | out = out .. (renderLiteInfoBox(frame, "SharedItem.svg", "共享资源页")) |
| | + | mw.smw.set({['设定类型'] = "共享资源"}) |
| | + | out = out .. "[[Category:共享资源]]" |
| | end | | end |
| | else -- base must exist | | else -- base must exist |
| | local parent = getParentProps(base, {"设定集", "设定类型"}) | | local parent = getParentProps(base, {"设定集", "设定类型"}) |
| − | if parent["设定集"] then | + | local parentGroup = parent["设定集"][1] |
| − | mw.smw.set({['设定集'] = parent["设定集"]}) | + | if parentGroup then |
| | + | mw.smw.set({['设定集'] = parentGroup}) |
| | end | | end |
| − | local parentType = parent["设定类型"] or "公共设定" | + | local parentType = parent["设定类型"][1] or "公共设定" |
| | mw.smw.set({['设定类型'] = parentType}) | | mw.smw.set({['设定类型'] = parentType}) |
| | if parentType == "世界观设定" then | | if parentType == "世界观设定" then |
| 第97行: |
第113行: |
| | elseif parentType == "联动设定" then | | elseif parentType == "联动设定" then |
| | local text = "" | | local text = "" |
| − | out = out .. (renderLiteInfoBox(frame, "联动.svg", "本页面属于联动: [["..base.."]")) | + | out = out .. (renderLiteInfoBox(frame, "联动.svg", "本页面属于联动: [["..base.."]]")) |
| | out = out .. "[[Category:联动设定]]" | | out = out .. "[[Category:联动设定]]" |
| | else -- 公共设定 | | else -- 公共设定 |
| 第105行: |
第121行: |
| | end | | end |
| | return out | | return out |
| | + | end |
| | + | |
| | + | -- function p.test() |
| | + | -- mw.logObject(getParentProps("测试设定", {"设定集", "设定类型"})) |
| | + | -- end |
| | + | |
| | + | function renderEditButton(frame) |
| | + | local title = PageName.getPageName() |
| | + | local args = { |
| | + | image = 'Settings.svg', |
| | + | link = 'https://wiki.ifworlds.org/wiki/特殊:编辑表格/设定页v2/'..title |
| | + | } |
| | + | return frame:expandTemplate{title = "LinkButtonBox", args = args} |
| | end | | end |
| | | | |
| | function p.renderCreator(frame) | | function p.renderCreator(frame) |
| | + | local root = mw.html.create("div") |
| | local title = PageName.getPageName() | | local title = PageName.getPageName() |
| | local prop_names = {"维护者", "创作者", "输入设定类型", "设定集核心页", "依赖设定集", "仅允许维护者编辑", "创作阶段", "上级概念", "前置条件", "事后效果"} | | local prop_names = {"维护者", "创作者", "输入设定类型", "设定集核心页", "依赖设定集", "仅允许维护者编辑", "创作阶段", "上级概念", "前置条件", "事后效果"} |
| − | local props = SMWUtils.query_page_properties("[["..title.."]]", prop_names)[1]["properties"] | + | local page = SMWUtils.query_page_properties("[["..title.."]]", prop_names)[1] |
| − | local root = mw.html.create("div") | + | if page == nil then |
| | + | return root:done() |
| | + | end |
| | + | local props = page["properties"] |
| | root:attr("style", "display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, auto)); width: 100%") | | root:attr("style", "display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, auto)); width: 100%") |
| | local maintainerTemp = renderMaintainers(frame, props["维护者"], props["创作者"]) | | local maintainerTemp = renderMaintainers(frame, props["维护者"], props["创作者"]) |
| 第122行: |
第155行: |
| | local typeNode = renderType(frame, isIndexPage, props["输入设定类型"][1] or "公共设定", props["依赖设定集"]) | | local typeNode = renderType(frame, isIndexPage, props["输入设定类型"][1] or "公共设定", props["依赖设定集"]) |
| | root:wikitext(typeNode) | | root:wikitext(typeNode) |
| − | root:wikitext(renderStage(frame, props["创作阶段"][1] or "空白")) | + | local stage = frame.args["创作阶段"] or "空白" |
| | + | root:wikitext(renderStage(frame, stage)) |
| | + | |
| | + | |
| | + | root:wikitext(renderEditButton(frame)) |
| | return root:done() | | return root:done() |
| | end | | end |