简体   繁体   English

是否可以为 KeystoneJS 编写插件?

[英]Is it possible to write plugins for KeystoneJS?

I'm on a project where we are thinking of using KeystoneJS for our CMS.我正在考虑在我们的 CMS 中使用 KeystoneJS 的项目。 One of the points I've been tasked with answering is whether KeystoneJS allows one to write custom plugins.我的任务之一是回答 KeystoneJS 是否允许编写自定义插件。 I've googled and can't seem to find an answer, which would indicate that perhaps there is no way to do so.我用谷歌搜索,似乎找不到答案,这表明也许没有办法这样做。

I see that KeystoneJS has two plugins listed in their documentation, but I'm unclear whether they have a way for us to write our own.我看到 KeystoneJS 在他们的文档中列出了两个插件,但我不清楚他们是否有办法让我们自己编写。

Any info, or links to documentation or examples, would be most welcome!任何信息,或文档或示例的链接,将是最受欢迎的!

KeystoneJs has only list plugins support which you saw on documentation page KeystoneJs 仅列出您在文档页面上看到的插件支持

atTracking and byTracking . atTrackingbyTracking

at this time these only support to extend the list config before creating the list object internally.目前这些只支持在内部创建列表对象之前扩展列表配置。 List plugins can be used to have reusable template fields and validation logic列表插件可用于具有可重用的模板字段和验证逻辑

above two plugin only adds two fields each.以上两个插件只添加了两个字段。 atTracking adds fields for tracking created and updated timestamp whereas byTracking adds user info for creation and updation of item. atTracking添加用于跟踪创建和更新时间戳的字段,而byTracking添加用于创建和更新项目的用户信息。

keystone passes on full list of createlist listconfig parameter to the plugin, this plugin must return the full config for keystone to continue creating list. keystone 将完整的 createlist listconfig 参数列表传递给插件,此插件必须返回完整的配置以便 keystone 继续创建列表。

EDIT编辑

I found some examples which cane be used, will be adding to keystonejs-contrib packages.我发现了一些使用甘蔗的例子,将添加到 keystonejs-contrib 包中。

IpTracking plugin which adds ip of person creating or updating the list - https://github.com/MadeByMike/keystone-ip-tracking-plugin/blob/master/index.js IpTracking插件,它添加了创建或更新列表的人的 ip - https://github.com/MadeByMike/keystone-ip-tracking-plugin/blob/master/index.js

Access Control plugin, which helps define roles based access control - https://github.com/MadeByMike/keystone-access-control-demo/blob/master/plugin-access-control.js访问控制插件,有助于定义基于角色的访问控制 - https://github.com/MadeByMike/keystone-access-control-demo/blob/master/plugin-access-control.js

both are made by core team member Mike Riethmuller - https://github.com/MadeByMike两者均由核心团队成员 Mike Riethmuller 制作 - https://github.com/MadeByMike

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM