“模块:创作者信息”的版本间的差异
跳到导航
跳到搜索
第1行: | 第1行: | ||
− | local | + | local SMWUtils = require("Module:SMWUtils") |
− | local | + | local PageName = require("Module:PageName") |
local p = {} | local p = {} | ||
− | function | + | function renderMaintainers(frame, maintainers, other_creators) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local node = mw.html.create(nil) | local node = mw.html.create(nil) | ||
− | node:wikitext(" | + | node:wikitext("创作者: ") |
− | for i, m in ipairs( | + | for i, m in ipairs(maintainers) do |
node:wikitext("[[User:"..m.."|"..m.."]]") | node:wikitext("[[User:"..m.."|"..m.."]]") | ||
node:wikitext("[[Category:由"..m.."维护的条目]]") | node:wikitext("[[Category:由"..m.."维护的条目]]") | ||
+ | node:wikitext("[[Category:由"..m.."创作的条目]]") | ||
_set_editable_by_user(m) | _set_editable_by_user(m) | ||
− | + | end | |
− | + | for i, m in ipairs(other_creators) do | |
− | + | node:wikitext("[[创作者:"..m.."|"..m.."]]") | |
+ | node:wikitext("[[Category:由"..m.."创作的条目]]") | ||
end | end | ||
local res = node:done() | local res = node:done() | ||
− | local args = {image = ' | + | local args = {image = 'Copyright.svg', content = res} |
return frame:expandTemplate{title = "LiteInfoBox", args = args} | return frame:expandTemplate{title = "LiteInfoBox", args = args} | ||
end | end | ||
− | function | + | function renderLockedPage(frame) |
mw.smw.set({ | mw.smw.set({ | ||
['Editable by'] = 'whitelist' | ['Editable by'] = 'whitelist' | ||
第46行: | 第28行: | ||
end | end | ||
− | function p. | + | function p.renderCreator(frame) |
− | local | + | local title = PageName.getPageName() |
− | local | + | local prop_names = {"维护者", "创作者", "设定类型", "设定集核心页", "依赖设定集", "仅允许维护者编辑", "创作阶段", "上级概念", "前置条件", "事后效果"} |
− | local | + | local props = SMWUtils.query_page_properties("[["..title.."]]", prop_names) |
− | local | + | local root = mw.html.create(nil) |
− | + | -- root:wikitext(renderMaintainers(frame, props["维护者"], props["创作者"])) | |
− | + | -- if props["维护者"]["仅允许维护者编辑"][1] == "t" then | |
− | if | + | -- renderLockedPage(frame) |
− | + | -- end | |
− | + | -- return root:done() | |
− | + | return mw.text.jsonEncode(props) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
return p | return p |
2021年7月4日 (日) 15:25的版本
此模块的文档可以在模块:创作者信息/doc创建
local SMWUtils = require("Module:SMWUtils") local PageName = require("Module:PageName") local p = {} function renderMaintainers(frame, maintainers, other_creators) local node = mw.html.create(nil) node:wikitext("创作者: ") for i, m in ipairs(maintainers) do node:wikitext("[[User:"..m.."|"..m.."]]") node:wikitext("[[Category:由"..m.."维护的条目]]") node:wikitext("[[Category:由"..m.."创作的条目]]") _set_editable_by_user(m) end for i, m in ipairs(other_creators) do node:wikitext("[[创作者:"..m.."|"..m.."]]") node:wikitext("[[Category:由"..m.."创作的条目]]") end local res = node:done() local args = {image = 'Copyright.svg', content = res} return frame:expandTemplate{title = "LiteInfoBox", args = args} end function renderLockedPage(frame) mw.smw.set({ ['Editable by'] = 'whitelist' }) return frame:expandTemplate{title = "本页面仅允许维护者编辑", args = {}} end function p.renderCreator(frame) local title = PageName.getPageName() local prop_names = {"维护者", "创作者", "设定类型", "设定集核心页", "依赖设定集", "仅允许维护者编辑", "创作阶段", "上级概念", "前置条件", "事后效果"} local props = SMWUtils.query_page_properties("[["..title.."]]", prop_names) local root = mw.html.create(nil) -- root:wikitext(renderMaintainers(frame, props["维护者"], props["创作者"])) -- if props["维护者"]["仅允许维护者编辑"][1] == "t" then -- renderLockedPage(frame) -- end -- return root:done() return mw.text.jsonEncode(props) end return p