Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a panel button to push to remote #85

Closed
gryzzly opened this issue Jan 21, 2022 · 3 comments
Closed

Add a panel button to push to remote #85

gryzzly opened this issue Jan 21, 2022 · 3 comments

Comments

@gryzzly
Copy link

gryzzly commented Jan 21, 2022

Hey!

I am helping a friend with their Kirby website and I’d like to enable them (non-tech person) to get the content backed up on git. I think this plugin is perfect for that (I was doing commits once in a while from SSH), but their hosting plan doesn’t offer cron job integration. The content is a lot of images, so doing commits after each change to /content folder sounds slow. But if the cron job would simply trigger an endpoint, would it be a lot of work for me to add a button in the panel that triggers the push? So the friend could simply run it once a week / once in a month or after they are done with a bunch of changes.

Thanks!

@moddyn6
Copy link
Collaborator

moddyn6 commented Jan 21, 2022

Hey gryzzly,

maybe a cheap solution would be to use the 'push'-route, that is implemented in the plugin already.
You could create a bookmark for your friend that links to <Your-URL>/git-content/push. That should push the content every time it is called.

I am not entirely sure but I think even for a simple button with a custom link you would have to create your own plugin and add a custom section in Vue that implements this button (you may want to take a look at this cookbook recipie: https://getkirby.com/docs/cookbook/extensions/first-panel-section)

In an old version of the plugin there was a button like the one you need, but I think it got removed when the panel was switched to Vue for v3 of kirby.
Maybe it will get implemented again - should not be too hard.

@gryzzly
Copy link
Author

gryzzly commented Jan 22, 2022

Very helpful, thanks for the kind advice!

I found this plugin called "Janitor" (https://github.com/bnomei/kirby3-janitor) that allows adding a button via fields in the blueprints, and I think adding a button to do an API call to /git-content/push should work!

I’ll update the issue once it’s working

@gryzzly
Copy link
Author

gryzzly commented Jan 23, 2022

@moddyn6

Hey, so 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
    ],
  ]

where contentPush is a function that Janitor calls from a button in the panel. But pressing the button is always showing a dialogue 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!

thathoff added a commit that referenced this issue Mar 18, 2022
- Display last 10 commits
- Add buttons to push and pull

Closes #85

BREAKING CHANGES:

This version breaks compatibility with Kirby < 3.6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants