Closed gryzzly closed 2 years ago
Hey, got a little bit more further, I‘m trying to call the git endpoint like this:
in config.php:
'bnomei.janitor.jobs' => [
'contentPush' => function (Kirby\Cms\Page $page = null, string $data = null) {
// $page => page object where the button as pressed
$kirby->call('/git-content/push?secret=foobar');
return [
'status' => 200,
'label' => $page->title() . ' ' . $data,
];
},
],
'thathoff' => [
'git-content' => [
'commit' => true,
'cronHooksEnabled' => true,
'cronHooksSecret' => 'foobar',
'displayErrors' => true
],
]
But pressing the button is always showing a dialog saying: No route found for path: "git-content/push" and request method: "GET"
.
However, I can see that the route is indeed installed at http://localhost:8000/git-content/push
– if I visit it I receive the appropriate error message in JSON like this:
{"status":"forbidden","message":"Invalid secret passed"}
Do you see something obviously wrong with what I am doing?
Thanks!
Since the lib you are using is exposing simple helper calls to routes you could just call them manually.
'bnomei.janitor.jobs' => [
'contentPush' => function (Kirby\Cms\Page $page = null, string $data = null) {
// $page => page object where the button as pressed
$git = new \Thathoff\GitContent\KirbyGitHelper();
$status = $git->push(); // does not work yet
$status = true;
return [
'status' => status ? 200 : 204,
'label' => 'Pushed content',
];
},
],
];
maybe @thathoff could add some return status values to the helpers push
and pull
methods.
Great idea, thanks @bnomei. That seems like a good Idea, i’ve just created an issue for this.
PS: @gryzzly we’ve started working on a Panel Area (supported since kirby 3.6) with push and pull buttons. You can try this by using the panel branch (or dev-panel version if you use composer).
Hey, I’m using this plugin: https://github.com/thathoff/kirby-git-content which creates an endpoint like
/git-content/push
and I’d like to add a button insite.yml
that calls that endpoint.This example https://github.com/bnomei/kirby3-janitor/wiki/Example:-Trigger-jons-with-JS-and-Panel-Vue shows how to call endpoints but I am not sure where would I place this code. Can you advice?
Thanks!