Skip to content

Commit

Permalink
Merge pull request #101 from thathoff/enhanced-git-features
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
thathoff committed Oct 16, 2023
2 parents e718906 + b0877c1 commit 443223a
Show file tree
Hide file tree
Showing 34 changed files with 4,319 additions and 62 deletions.
27 changes: 24 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
node_modules/
.DS_Store
.idea/
vendor/
composer.lock
yarn.lock
vendor
kirby

# files of Composer dependencies that are not needed for the plugin
# See https://getkirby.com/docs/guide/plugins/plugin-setup-composer
/vendor/**/.*
/vendor/**/*.json
/vendor/**/*.txt
/vendor/**/*.md
/vendor/**/*.yml
/vendor/**/*.yaml
/vendor/**/*.xml
/vendor/**/*.dist
/vendor/**/readme.php
/vendor/**/LICENSE
/vendor/**/COPYING
/vendor/**/VERSION
/vendor/**/Makefile
/vendor/**/phpstan.neon
/vendor/**/docs/*
/vendor/**/example/*
/vendor/**/examples/*
/vendor/**/test/*
/vendor/**/tests/*
/vendor/**/php4/*
/vendor/getkirby/composer-installer
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<a name="5.1.0"></a>
# [5.1.0](https://github.com/thathoff/kirby-git-content/compare/v5.0.2...v5.1.0) (2023-10-16)

### Features
- Support git submodule installation (see #74, thanks to @CHE1RON)
- Enhanced panel UI with support to switch and create branches, manual commits and resets
- Add before and after hooks for push and pull
- Add optional help text in the UI

<a name="5.0.2"></a>
# [5.0.2](https://github.com/thathoff/kirby-git-content/compare/v5.0.1...v5.0.2) (2023-06-13)

Expand Down
108 changes: 65 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kirby - Git Content
# Kirby Git Content

This is a plugin for [Kirby 3](http://getkirby.com/) that commits and pushes content changes made via the Panel to your git repository.

Expand All @@ -10,75 +10,67 @@ This plugin supports **Kirby from version 3.6** and requires **git version > 2.2

## Usage

Just keep using the Panel as you are used to and watch the commits appear in your git repository!
You can use this plugin to commit and push changes made via the Panel to your git repository. Either automatically
by setting the `commit` option to `true` or manually by visiting the panel view and adding a commit.

## Installation
## Setup

### Create a new git repository for your content
### Download and configure the Plugin

Create a new git repository where you push your content to, name it `your-project_content`.
#### Installation via composer (recommended)

Init the content repo and push it
`composer require thathoff/kirby-git-content`

Remove the `content/` folder from your current git repository
```bash
git rm --cached -r content
git add -A
git commit -m "Move Content Folder to separate repository"
```
#### Installation via git submodule

Add the `content/` folder to new git repository
`git submodule add https://github.com/thathoff/kirby-git-content.git site/plugins/git-content`

```bash
cd content
git init
git remote add origin https://github.com/your-project/your-project_content.git
git add -A
git commit -m "Initial Content Commit"
git push origin master
```
#### Manual Installation
- [download the source code](https://github.com/thathoff/kirby-git-content/archive/master.zip)
- copy the folder to `site/plugins/git-content`.

Optional step: We advise you to include `.lock` files into the .gitignore of your newly created content repository.

```bash
echo ".lock" >> .gitignore
```
### Create a new git repository for your content

That's it! The plugin should work as of now.
Create a new git repository where you push your content to init the content repo and push it.

### Download and configure the Plugin
```bash
cd content

`composer require thathoff/kirby-git-content`
# include .lock files in .gitignore
echo ".lock" >> .gitignore

To install this plugin without composer (not recommended):
# init repo
git init
git add .
git commit -m "Initial Commit"
```

- [download the source code](https://github.com/thathoff/kirby-git-content/archive/master.zip)
- run `composer install` locally
- copy the folder to your site/plugins folder.
Remove the `content/` folder from your current git repository

We might create downloadable releases in the future which will make the above steps unnecessary.
```bash
cd ..
git rm --cached -r content
git add -A
git commit -m "Move Content Folder to separate repository"
```

### Options
## Configuration

By default this plugin just commits changes to the content repository. It’s recommended to setup a cron job
which calls `yourdomain.com/git-content/push`. This will push changes to the remote repository. By using a cron job
saving pages in panel is a lot faster then enabling the `push` option which will push changes after every commit.

This plugin is configurable via [Kirby Options](https://getkirby.com/docs/guide/configuration). Add the
following entires to your `config.php`.
This plugin is configurable via [Kirby Options](https://getkirby.com/docs/guide/configuration). Add the following entires to your `config.php`.

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

#### Configuration Options
### Configuration Options

- `path` (String): Path to the repository, (default: `kirby()->root("content")`)
- `pull` (Boolean): Pull remote changes first? (default: `false`)
Expand All @@ -91,13 +83,43 @@ return [
- `displayErrors` (Boolean): Display git errors when saving pages (default: `true`)
- `gitBin` (String): Path to the `git` binary
- `disable` (Boolean): If set to `true`, the plugin won't initialize. (default: `false`)
- `disableBranchManagement` (Boolean): If set to `true`, the options to create and switch branches are hidden. (default: `false`)
- `helpText` (String): Supply a custom help text shown in the panel UI. (default: `null`)

#### Custom Commit Message
### Custom Commit Message

By default the commit message is composed from the template `:action:(:item:): :url:`. So for example a change to
the page `example` will be committed with the message `update(page): example`. If you would like to change that
message you can use the `thathoff.git-content.commitMessage` option to overwrite the template.

## Hooks

The plugin triggers hooks before and after content is pulled or pushed via the interface or the web endpoints.
You can use these hooks to trigger other actions, for example to deploy your site after a push or clear caches
after a pull.

```php
// 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
Your repository might increase over time, by adding Images, Audio, Video, Binaries, etc.
cloning and updating your content repository can take a lot of time. If you are able to use
Expand Down
18 changes: 16 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
"description": "Plugin to track changes to content in a git repository.",
"type": "kirby-plugin",
"license": "MIT",
"version": "5.1.0",
"authors": [
{
"name": "Markus Denhoff",
"email": "markus@denhoff.com"
},
{
"name": "reinorange GmbH",
"email": "info@reinorange.com"
}
],
"support": {
Expand All @@ -15,15 +20,24 @@
},
"require": {
"czproject/git-php": "^4.0.1",
"getkirby/cms": "^3.6.0",
"getkirby/composer-installer": "^1.1"
},
"require-dev": {
"getkirby/cms": "^3.6.0"
},
"autoload": {
"psr-4": {
"Thathoff\\GitContent\\": "src/"
}
},
"extra": {
"installer-name": "git-content"
"installer-name": "git-content",
"kirby-cms-path": false
},
"config": {
"optimize-autoloader": true,
"allow-plugins": {
"getkirby/composer-installer": true
}
}
}
Loading

0 comments on commit 443223a

Please sign in to comment.