github小技巧-github1s

github1s是一个项目,它允许你在1秒内使用在线VS Code打开GitHub上的代码。只需在GitHub项目的URL后面添加'1s',即可在浏览器中启动一个VS Code实例并加载代码。虽然只读,但此功能方便快捷,无需克隆或配置。项目基于VS Code和GitHub REST API,源代码开源,可自行部署或扩展。

github1s – 为 GitHub +1s,使用在线 VS Code 打开 GitHub 上的代码

github1s 是一个非常有趣的项目,它可以让你在 1 秒内(俗称 +1s)通过在线版本的 VS Code 来打开 GitHub 上的代码,只需要在对应项目的 URL 后面加上 1s 即可。@Appinn

这是一个很有创意、很赞的项目,只需要在对应的 GitHub 项目 URL 后面加上 1s,就能用在线版 VS Code 打开 GitHub 上的代码。

安装在云端的 VS Code,随时随地在浏览器使用 IDE

github1s 如何使用?

非常非常非常简单,以 github1s 项目自己的代码为例,第一行为 github1s 在 GitHub 的项目地址,也就是 GitHub 提供的正经网页版,而在 github 后面直接加 1s,然后再访问,就能打开一个在线版本的 VS Code,并在这个 VS Code 中加载了全部的项目代码:

https://github.com/conwnet/github1s

GitHub1s

然后就在熟悉的 VS Code 界面中打开了代码,但注意只读。

+1s 是什么意思

github1s 项目的副标题是:One second to read GitHub code with VS Code.

所以这个 +1s 的意思就是 1 秒钟的意思。

最后,github1s 在 GitHub 开源,你也可以自己部署,比如服务器慢点的可以 +2s、+3s 等等。

下面是原项目和加载1s时的样子和加载后的样子。

原项目

 

加载时

 

加载1s后

 

是的没错就是这么简单,这就在浏览器中打开了一个在线版的 VS Code,并打开了 Scrapy 的源代码,看代码就非常方便了。

无需克隆,无需任何配置,打开飞速,代码高亮!

还打开了几个其他项目测试,均可运行。

 

可惜的是代码并不能修改,代码都是以只读模式打开的,也就是我们只能看,没法改。不过这也合情合理,毕竟任意 Repo 都能打开,改了之后并没有合适的存储地方。

 

原理

 

作者是这样介绍的:

Github1s is based on VS Code 1.52.1 now. VS Code can be built for a browser version officially. I also used the code and got inspired by Code Server. Thanks to the very powerful and flexible extensibility of VS Code, we can easily implement a VS Code extension that provides the custom File IO ability using FileSystemProvider API. There is an official demo named vscode-web-playground which shows how it is used. On the other hand, GitHub provides the powerful REST API that can be used for a variety of tasks which includes reading directories and files for sure. According to the above, obviously, the core concept of GitHub1s is to implement a VS Code Extension (includes FileSystemProvider) using GitHub REST API. We may switch to the GitHub GraphQL API for more friendly user experience in the future, thanks to @xcv58 and @kanhegaonkarsaurabh. See details at Issue 12. GitHub1s is a purely static web app (because it really doesn't need a backend service, does it?). So we just deploy it on GitHub Pages now (the gh-pages branch of this repository), and it is free. The service of GitHub1s could be reliable (GitHub is very reliable) because nobody needs to pay the web hosting bills.

总的来说,GitHub1s 这个仓库是基于 VS Code 构建的,灵感来源于 Code Server 这个 Repo,地址为:https://github.com/coder/code-server,这个就是一个 Online 版的 VS Code。

他基于 VS Code 提供的 FileSystemProvider API 对接了 GitHub 的 REST API 实现了这些功能。其中前者是 VS Code 提供的,可以提供文件读写操作,当然读写在线文件也是没问题的了;而后者是 GitHub 提供的,通过 REST API 可以获取 Repo 的文件夹或者某个文件。

同时我们也可以把 GitHub1s 代码下载下来,改写一下,扩展一些功能:比如解除只读限制,保存的时候直接存储到自己的 Repo 等。

具体的修改和开发流程可以参考:https://github.com/conwnet/github1s/blob/master/docs/guide.md#development

最后祝大家玩的愉快^=^.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五百五。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值