marionnewlevant/snitch
Composer 安装命令:
composer require marionnewlevant/snitch
包简介
Report when two people might be editing the same element (eg entry, category, or global) or field
README 文档
README
Snitch watches element editors (entry, category, global set, user, etc.) and field editors, and lets you know when someone else may also be editing the same thing at the same time.
Installation
To install Snitch, follow these steps:
- Install with Composer via
composer require marionnewlevant/snitchfrom your project directory - Install plugin in the Craft Control Panel under Settings > Plugins
or
- Install via the Plugin Store
Snitch works on Craft 3.x.
Snitch Overview
Snitch works by injecting a javascript file into backend pages. That javascript looks for an element edit window or a modal element edit window, and when it detects one, asks the server to report any collisions.
A warning banner appears at the top of the editor pane when someone else may be editing the same element:
A warning banner also appears at the top of editor modals:
Clicking the X will dismiss the banner.
Configuring Snitch
The default configuration can be overridden with a config file in craft/config/snitch.php. This is a standard Craft config file, with the usual multienvironment support. The configurable values are:
serverPollInterval: interval (in seconds) for polling server to look for newly arrived conflicts. Default value:2. Minimum value 1, maximum value 5.messageTemplate: text for the warning banner. This is parsed as twig, withuserthe user who may be in conflict. Default value is:May also be edited by: <a href="mailto:{{user.email}}">{{user.username}}</a>.. This will generate amailtolink to the user. You can change this to enable Slack messaging, or what-have-you.elementInputIdSelector: the css selector for identifying the hidden inputs which indicate an element edit window or modal element edit window.fieldInputIdSelector: css selector for identifying the hidden inputs which indicate a field edit window.
The visual look of the warning banners can be modifed with the cpcss plugin.
How it works.
Javascript (and css) is added to every backend page. That javascript fetches the configuration values, and then starts polling. Every 2 seconds, it looks for any edit forms on the page, and if it finds such a form, reports via ajax the type and the id of the element that the edit form is editing. In return, it is passed a list of possible collisions.
On the server, a database table (snitch_collisions) records
- the user
- the type of the element being edited
- the id of the element being edited
- when the element was last reported being edited by this user.
When the ajax call arrives reporting that an element is being edited, these things happen:
- Any report that has not been updated in 10 poll intervals is removed from the snitch_collisions table. It is no longer being edited.
- Either create a new report for this user/element type/element id, or update the time on the existing one
- Look for any edit reports of this element by other users.
- Return the user data from these reports. These will be other people who may be editing the element.
Issues
Snitch will fail to notice when one person is editing a Commerce product, and another is editing a variant of that product through a modal.
Brought to you by Marion Newlevant
marionnewlevant/snitch 适用场景与选型建议
marionnewlevant/snitch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85.23k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2017 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「Craft」 「craftcms」 「craft-plugin」 「snitch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 marionnewlevant/snitch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marionnewlevant/snitch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 marionnewlevant/snitch 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
Restrict user registration by domain in Craft CMS, allows you to limit who can register for your site based on their email address.
统计信息
- 总下载量: 85.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 35
- 点击次数: 32
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-14

