从静态站点中托管的javascript运行git push [英] Run git push from javascript hosted in static site

查看:65
本文介绍了从静态站点中托管的javascript运行git push的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下一个用jekyll编译并托管在github页面上的静态网站.此页面上是否可能有一些javascript询问用户一些输入,然后将此输入"git push"到某个github存储库中?

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 ?

换句话说,如何用javascript编写以下程序:

In other words, how to write in javascript the following program:

  • 询问用户的姓名,将姓名放入变量s
  • 从给定的github库下载(或提取)文本文件"allnames.txt"
  • 在allnames.txt的末尾添加s
  • 提交文件"allnames.txt"并将其推回github

当然,我了解潜在的安全风险,因为javascript代码将需要嵌入私密ssh密钥.但这是将动态性添加到静态网站的一种有趣的方法,并且可能有人知道一些使此安全性解决方案的方法吗?

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 ?

谢谢!

推荐答案

如果您知道git的内部知识(斑点,树,提交),那么您应该能够使用GitHub REST API实现解决方案.这将不会在5分钟内完成.至于安全性,您应该可以使用OAuth,因此不需要私用ssh密钥.

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.

看看: https://developer.github.com/v3/git/

这篇关于从静态站点中托管的javascript运行git push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆