Imagine a static web site compiled with jekyll and hosted on github pages. Is it possible to have some javascript on this page that asks the user some input, and then "git push" this input into some github repository ?
In other words, how to write in javascript the following program:
Of course, I understand the potential security risks, because the javascript code would need to embed private ssh keys. But this would be a fun way to add dynamicity to a static web site, and may be someone knows of some solution to make this secure ?
Thank you !
If you know the internals of git (blobs, trees, commits), then you should be able to implement a solution with the GitHub REST API. This is not going to be done in 5 minutes. As for security, you should be able to use OAuth, so no need for private ssh key.
Have a look at: https://developer.github.com/v3/git/
Alternative to using GitHub APIs, you can use one of the git clients written in JavaScript to do the actions you described above within the browser.
Here are a few examples:
https://github.com/creationix/js-git
https://github.com/danlucraft/git.js
Check out Staticman
From the Staticman site:
Staticman handles user-generated content for you and transforms it into data files that sit in your GitHub repository, along with the rest of your content.
Staticman works perfectly with Jekyll sites hosted on GitHub Pages, as a push to your main branch will regenerate the site automatically. If you want to moderate entries before they are published, a pull request will be created for your approval; otherwise, files will be pushed to your main branch straight away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With