blankogmbh/kirby-git-commit-and-push-content

此包已被弃用且不再维护。作者建议使用thathoff/kirby-git-content包代替。

插件用于跟踪git仓库中内容的更改。

安装次数: 4,791

依赖项: 0

建议者: 0

安全性: 0

星标: 130

关注者: 7

分支: 19

开放性问题: 7

类型:kirby-plugin

5.2.0 2023-12-09 15:53 UTC

README

这是一个Kirby插件,可以将通过面板做出的内容更改提交和推送到git仓库。

Screnshot of Panel Area

需求

此插件支持从版本3.6(包括Kirby 4)的Kirby,并要求git版本 > 2.24。

用法

您可以使用此插件将通过面板做出的更改提交和推送到git仓库。可以通过设置commit选项为true自动提交,或者通过访问面板视图并添加提交手动提交。

设置

下载并配置插件

通过composer安装(推荐)

composer require thathoff/kirby-git-content

通过git子模块安装

git submodule add https://github.com/thathoff/kirby-git-content.git site/plugins/git-content

手动安装

为您的内容创建新的git仓库

创建一个新的git仓库,将内容推送到那里以初始化内容仓库并推送内容。

cd content

# include .lock files in .gitignore
echo ".lock" >> .gitignore

# init repo
git init
git add .
git commit -m "Initial Commit"

从当前git仓库中删除content/文件夹

cd ..
git rm --cached -r content
git add -A
git commit -m "Move Content Folder to separate repository"

配置

默认情况下,此插件仅将更改提交到内容仓库。建议设置一个cron作业,调用yourdomain.com/git-content/push。这将更改推送到远程仓库。使用cron作业比启用push选项更快地保存页面,后者将在每次提交后推送更改。

此插件可通过Kirby选项进行配置。将以下条目添加到您的config.php

return [
  // other configuration options
  'thathoff.git-content.commit' => true,
];

配置选项

  • path (字符串): 仓库路径,(默认: kirby()->root("content"))
  • pull (布尔值): 首先拉取远程更改?(默认: false)
  • commit (布尔值): 提交您的更改?(默认: true)
  • push (布尔值): 将您的更改推送到远程?(默认: false)
  • commitMessage (字符串): 配置提交信息的模板(默认: :action:(:item:): :url:
  • cronHooksEnabled (布尔值): 是否启用/git-content/push/git-content/pull端点。(默认: true
  • cronHooksSecret (字符串): 设置时,必须通过get参数发送此密钥。注意:如果设置密钥,则仅通过GET方法在webhooks上工作。/git-content/(pull|push)?secret=S0up3rS3c3t
  • displayErrors (布尔值): 保存页面时显示git错误(默认: true
  • gitBin (字符串): git二进制文件的路径
  • disable (布尔值): 如果设置为true,则插件不会初始化。(默认: false
  • disableBranchManagement (布尔值): 如果设置为true,则创建和切换分支的选项将被隐藏。(默认: false
  • helpText (字符串): 提供在面板UI中显示的自定义帮助文本。(默认: null
  • menuIcon (字符串): 为面板菜单项提供自定义图标。(默认: sitemap
  • menuLabel (字符串): 为面板菜单项提供自定义标签。(默认: Git Content

自定义提交信息

默认情况下,提交信息由模板 :action:(:item:): :url: 组成。例如,对页面 example 的修改将以消息 update(page): example 提交。如果您想更改该消息,可以使用 thathoff.git-content.commitMessage 选项覆盖模板。

钩子

插件在通过界面或Web端点拉取或推送内容前后触发钩子。您可以使用这些钩子触发其他操作,例如在推送后部署您的站点或在拉取后清除缓存。

// site/config/config.php

return [
  // other configuration options
  'hooks' => [
    'thathoff.git-content.push:before' => function () {
      // do something before a push
    },
    'thathoff.git-content.push:after' => function ($response) {
      // do something after a push
    },
    'thathoff.git-content.pull:before' => function () {
      // do something before a pull
    },
    'thathoff.git-content.pull:after' => function ($response) {
      // do something after a pull
    },
  ],
];

Git LFS

随着时间的推移,您的存储库可能会增加,例如通过添加图片、音频、视频、二进制文件等。克隆和更新内容存储库可能需要很长时间。如果您能够使用 Git LFS,那么您可能应该使用它。以下是 .gitattributes 文件可能的样子

*.zip filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text

作者

Markus Denhoff贡献者 维护和开发。初始版本由 Pascal Küsgen 创建。

reinorange GmbH 支持。