更改

删除929字节 、 2021年7月4日 (日) 15:25
无编辑摘要
第1行: 第1行: −
local StringUtils = require("Module:StringUtils")
+
local SMWUtils = require("Module:SMWUtils")
local ListUtils = require("Module:ListUtils")
+
local PageName = require("Module:PageName")
 
local p = {}
 
local p = {}
   −
function _missing_maintainer(frame)
+
function renderMaintainers(frame, maintainers, other_creators)
    return frame:expandTemplate{title = "无维护者警告", args = {}}
  −
end
  −
 
  −
function _self_post(frame, creator)
  −
    return frame:expandTemplate{title = "创作者信息/本人发布", args = {['创作者'] = creator}}
  −
end
  −
 
  −
function _proxy_post(frame, creator, maintainer)
  −
    return frame:expandTemplate{title = "创作者信息/委托发布", args = {
  −
        ['创作者'] = creator, ['维护者']=maintainer}}
  −
end
  −
 
  −
function _set_editable_by_user(user)
  −
    local nm = 'User:'..user
  −
    mw.smw.set({
  −
        ['Editable by user'] = nm
  −
    })
  −
end
  −
 
  −
function _other_maintainers(frame, other_maintainers)
   
     local node = mw.html.create(nil)
 
     local node = mw.html.create(nil)
     node:wikitext("合作维护者: ")
+
     node:wikitext("创作者: ")
     for i, m in ipairs(other_maintainers) do
+
     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)
        mw.smw.set({
+
    end
            ['维护者'] = ("User:"..m)
+
    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 = 'Brainstorm.svg', content = mw.dumpObject(res)}
+
     local args = {image = 'Copyright.svg', content = res}
 
     return frame:expandTemplate{title = "LiteInfoBox", args = args}
 
     return frame:expandTemplate{title = "LiteInfoBox", args = args}
 
end
 
end
   −
function _maintainer_only(frame, maintainer)
+
function renderLockedPage(frame)
 
     mw.smw.set({
 
     mw.smw.set({
 
         ['Editable by'] = 'whitelist'
 
         ['Editable by'] = 'whitelist'
第46行: 第28行:  
end
 
end
   −
function p.render(frame)
+
function p.renderCreator(frame)
     local creator = StringUtils.assert_not_empty(frame.args["创作者"])
+
     local title = PageName.getPageName()
     local maintainer_only = StringUtils.assert_not_empty(frame.args["仅允许维护者编辑"])
+
     local prop_names = {"维护者", "创作者", "设定类型", "设定集核心页", "依赖设定集", "仅允许维护者编辑", "创作阶段", "上级概念", "前置条件", "事后效果"}
     local maintainer = StringUtils.assert_not_empty(frame.args["维护者"])
+
     local props = SMWUtils.query_page_properties("[["..title.."]]", prop_names)
     local other_maintainers = StringUtils.split_or_empty(frame.args["合作维护者列表"], ",")
+
     local root = mw.html.create(nil)
 
+
    -- root:wikitext(renderMaintainers(frame, props["维护者"], props["创作者"]))
    local result
+
     -- if props["维护者"]["仅允许维护者编辑"][1] == "t" then
     if not creator and maintainer then
+
     --    renderLockedPage(frame)
        creator = maintainer
+
     -- end
    elseif not maintainer and creator then
+
     -- return root:done()
        maintainer = creator
+
    return mw.text.jsonEncode(props)
    end
  −
    if maintainer then
  −
        if maintainer == creator then
  −
            result = _self_post(frame, creator)
  −
        else
  −
            result = _proxy_post(frame, creator, maintainer)
  −
        end
  −
        if maintainer_only == "" then
  −
            result = result .. _maintainer_only(frame, maintainer)
  −
        end
  −
        _set_editable_by_user(maintainer)
  −
     else
  −
        result = _missing_maintainer(frame)
  −
     end
  −
 
  −
     if other_maintainers[1] then
  −
        local newcode = _other_maintainers(frame, other_maintainers)
  −
        result = result .. newcode
  −
    end
  −
 
  −
    return result
  −
 
   
end
 
end
    
return p
 
return p