Skip to content

Commit f1732b3

Browse files
committed
Fix panel routes
Closes #42
1 parent 4e3ec51 commit f1732b3

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

autogit.php

100644100755
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Kirby Auto Git Plugin
55
*
6-
* @version 0.6.0
6+
* @version 0.6.1
77
* @author Pedro Borges <[email protected]>
88
* @copyright Pedro Borges <[email protected]>
99
* @link https://github.com/pedroborges/kirby-autogit
@@ -21,9 +21,7 @@ function autogit() {
2121
}
2222

2323
// Load routes
24-
if (c::get('autogit.webhook.secret', false)) {
25-
require_once(__DIR__.DS.'lib'.DS.'routes.php');
26-
}
24+
require_once(__DIR__.DS.'lib'.DS.'routes.php');
2725

2826
// Only load hooks, routes and widgets when
2927
// the content directory is a Git repo

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [0.6.1] - 2018-03-01
5+
### Fixed
6+
- Bug where panel routes where not being registered.
7+
48
## [0.6.0] - 2018-02-13
59
### Added
610
- `autogit` option: disables the plugin.

lib/autogit.php

100644100755
File mode changed.

lib/hooks.php

100644100755
File mode changed.

lib/routes.php

100644100755
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function autogitRoute($action, $source = null) {
1717
}
1818

1919
// Add widget route
20-
if (class_exists('Panel')) {
20+
if (function_exists('panel')) {
2121
panel()->routes([
2222
[
2323
'pattern' => 'autogit/(:any)',
@@ -36,19 +36,23 @@ function autogitRoute($action, $source = null) {
3636
}
3737

3838
// Add webhook route
39-
kirby()->routes([
40-
[
41-
'pattern' => c::get('autogit.webhook.url', 'autogit').'/(:any)',
42-
'method' => 'GET|POST',
43-
'action' => function($action) {
44-
$secretMatches = r::get('secret') === c::get('autogit.webhook.secret');
45-
$validActions = ['pull', 'push'];
46-
47-
if (! autogit()->hasRemote() or ! $secretMatches or ! in_array($action, $validActions)) {
48-
return go(site()->errorPage());
49-
}
39+
if (c::get('autogit.webhook.secret', false)) {
40+
kirby()->routes([
41+
[
42+
'pattern' => c::get('autogit.webhook.url', 'autogit').'/(:any)',
43+
'method' => 'GET|POST',
44+
'action' => function($action) {
45+
$secretMatches = r::get('secret') === c::get('autogit.webhook.secret');
46+
$validActions = ['pull', 'push'];
47+
48+
if (! autogit()->hasRemote() or
49+
! $secretMatches or
50+
! in_array($action, $validActions)) {
51+
return go(site()->errorPage());
52+
}
5053

51-
return autogitRoute($action, 'webhook');
52-
}
53-
]
54-
]);
54+
return autogitRoute($action, 'webhook');
55+
}
56+
]
57+
]);
58+
}

lib/translations.php

100644100755
File mode changed.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "autogit",
33
"author": "Pedro Borges <[email protected]>",
4-
"version": "0.6.0",
4+
"version": "0.6.1",
55
"description": "Kirby Auto Git",
66
"type": "kirby-plugin",
77
"license": "MIT"

widgets/autogit/template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949

5050
<div class="autogit-widget">
5151
<?php if (autogit()->hasRemote()) : ?>
52-
<button href="/panel/autogit/push" data-action="push" class="btn btn-rounded btn-positive autogit-action">
52+
<button data-action="push" class="btn btn-rounded btn-positive autogit-action">
5353
<i class="icon icon-left fa fa-cloud-upload"></i>
5454
Publish changes
5555
</button>
56-
<button href="/panel/autogit/pull" data-action="pull" class="btn btn-rounded btn-positive autogit-action">
56+
<button data-action="pull" class="btn btn-rounded btn-positive autogit-action">
5757
<i class="icon icon-left fa fa-cloud-download"></i>
5858
Get latest changes
5959
</button>
@@ -67,7 +67,7 @@
6767
</div>
6868

6969
<script>
70-
var panelURL = '<?php echo panel()->urls->index ?>'
70+
var panelURL = '<?= panel()->urls->index ?>'
7171
var $widget = $('#autogit-widget')
7272
var $loadingIcon = $('<i class="icon icon-left fa fa-spinner" />')
7373
var $successIcon = $('<i class="icon icon-left fa fa-check" />')

0 commit comments

Comments
 (0)