定制 bnomei/kirby3-recently-modified 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bnomei/kirby3-recently-modified

Composer 安装命令:

composer require bnomei/kirby3-recently-modified

包简介

Kirby Section to display recently modified content pages

README 文档

README

Release Discord Buymecoffee

Kirby Plugin to view recently modified pages by current User

Installation

  • unzip master.zip as folder site/plugins/kirby3-recently-modified or
  • git submodule add https://github.com/bnomei/kirby3-recently-modified.git site/plugins/kirby3-recently-modified or
  • composer require bnomei/kirby3-recently-modified

Screenshot

Section

recently-modified

Field

recently-modified

Usage

Add the section to your site or page blueprint to display a list of the most recently modified pages by the currently logged in user. The sections is not able to list the site itself since the section depends on a collection of pages for the query.

site/blueprints/site.yml

sections:
  listPagesModifiedByUser:
    type: recentlymodified
    headline: Your Recently Modified Pages
    # query

Optionally you can add the field to the site or any page blueprint to show the time and user that modified given content most recently. In contrast to the section the field is able to show most recent modified information for the site (content/site.txt).

site/blueprints/pages/default.yml

fields:
  showWhichUserModifiedPage:
    type: recentlymodified
    label: Recently Modified By
    # interval: 60

Warning

This plugin has, by default, a 1 minute cache.

Query for the Section (not Field)

The plugins section comes with a default query that shows the most recent changes made by the currently logged in user. But you can define any other query you like.

Default Query

site.index(true).sortBy('modified', 'desc').onlyModifiedByUser

onlyModifiedByUser is a PagesMethod added by this plugin that filters the page collection to only those pages that were modified by the currently logged-in user. The plugin uses hooks to track what pages each user did edit.

Example 1

sections:
  recentarticles:
    type: recentlymodified
    headline: Recently Modified Articles
    query: site.find('articles').children.listed.sortBy('modified', 'desc')

Example 2

sections:
  mycollection:
    type: recentlymodified
    headline: My Collection
    query: kirby.collection('my-collection')
return [
    'bnomei.recently-modified.limit' => 25, // default: 7
    'bnomei.recently-modified.info' => function ($page) {
        return $page->id();
    },
    // other options...
];

TIP: You could use the query property, info and limit settings to show any list of pages you want, just like a simplified version of the page table plugin.

Adjusting the Date formats

You can adjust the date formats based on the date.handler option. The default is date. The plugin bnomei.recently-modified.format is a callback that takes the $datetime string to format and ideally provides a format for all possible date handlers, returning the formatted string.

site/config/config.php

<?php

return [
    // ... other values

    'date'  => [
        'handler' => 'date', // <!-- you could adjust the date handler here
    ],

    'bnomei.recently-modified.format' => function($datetime): string {
        $handler = kirby()->option('date.handler') ?? 'date';
        $formats = [
            'date' => 'Y/m/d H:i:s',          // <!-- the formats here
            'intl' => 'dd. MMMM yyyy, HH:mm', // <!-- and here
            'strftime' => '%Y/%m/%d %H:%M:%S' // <!-- or here
        ];
        $format = $formats[$handler] ?? $formats['date'];

        return Str::date($datetime, $format, $handler);
    },
];

Known Limitations

  • You can not set multiple text/link/info settings. All instances of the recentlymodified section share the same.
  • The limit setting is always applied. If you want some of your instances to have a smaller number of items then call limit inside your custom query.

Settings

bnomei.recently-modified. Default Description
query ... see above
link function($page){...} callback to return the link
text function($page){...} callback to return the text
info function($page){...} callback to return the info
format fn($datetime){...} custom date format callback
hooks true use hooks to track users modified pages
limit 7 limit list and cache items
expire 1 cache will expire n-minutes

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

bnomei/kirby3-recently-modified 适用场景与选型建议

bnomei/kirby3-recently-modified 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.28k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2022 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「page」 「user」 「list」 「pages」 「collection」 「widget」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bnomei/kirby3-recently-modified 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bnomei/kirby3-recently-modified 我们能提供哪些服务?
定制开发 / 二次开发

基于 bnomei/kirby3-recently-modified 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-16