如果我在GitHub存储库中有一个。html文件,例如运行一组JavaScript测试,有什么方法可以直接查看该页面,从而运行测试?
例如,我是否可以看到jQuery测试套件生成的测试结果,而不需要下载或将repo复制到本地驱动器并在那里运行?
我知道这基本上会把GitHub放在静态内容托管业务中,但话又说回来,他们只需要改变他们的mime类型从文本/纯文本/html。
如果我在GitHub存储库中有一个。html文件,例如运行一组JavaScript测试,有什么方法可以直接查看该页面,从而运行测试?
例如,我是否可以看到jQuery测试套件生成的测试结果,而不需要下载或将repo复制到本地驱动器并在那里运行?
我知道这基本上会把GitHub放在静态内容托管业务中,但话又说回来,他们只需要改变他们的mime类型从文本/纯文本/html。
当前回答
你可以很容易地通过修改响应头,这可以用Chrome和Firefox扩展像Requestly完成。
在Chrome和Firefox中:
Chrome和Firefox的请求式安装 添加以下头部修改规则: 一)内容类型: 修改 响应 标题:内容类型 价值:text / html 源Url匹配:/raw\.githubusercontent\.com/.*\.html/ b) Content-Security-Policy: 修改 响应 标题:Content-Security-Policy 取值:default-src 'none';Style-src 'self' '不安全的内联';Img-src 'self'数据:;Script-src * '不安全的eval'; 源Url匹配:/raw\.githubusercontent\.com/.*\.html/
其他回答
Github有一个名为Github pages的静态页面托管服务,你可以在设置下找到它,然后选择页面,并选择你想要为页面使用的分支并点击保存。
您可能需要使用raw.githack.com。它支持GitHub, Bitbucket, Gitlab和GitHub专家。
GitHub
之前:
存储库]/ [https://raw.githubusercontent.com/[用户]/[第]/ [filename .分机]
在你的例子中。html扩展名
后:
开发(压制)
存储库]/ [https://raw.githack.com/[用户]/[第]/ [filename .分机]
生产(CDN)
存储库]/ [https://rawcdn.githack.com/[用户]/[第]/ [filename .分机]
在你的例子中。html扩展名
Raw.githack.com还支持其他服务:
Bitbucket都
之前:
存储库]/ - https://bitbucket.org/[用户]/[[第]/ [filename .分机]
后:
开发(压制)
存储库]/ - https://bb.githack.com/[用户]/[[第]/ [filename .分机]
生产(CDN)
存储库]/ - https://bbcdn.githack.com/[用户]/[[第]/ [filename .分机]
GitLab
之前:
存储库]/ - https://gitlab.com/[用户]/[[第]/ [filename .分机]
后:
开发(压制)
存储库]/ - https://gl.githack.com/[用户]/[[第]/ [filename .分机]
生产(CDN)
存储库]/ - https://glcdn.githack.com/[用户]/[[第]/ [filename .分机]
GitHub依据
之前:
raw https://gist.githubusercontent.com/[用户]/ [gist] / [revision] / [filename。请拨分机)。
后:
开发(压制)
raw https://gist.githack.com/[用户]/ [gist] / [revision] / [filename。请拨分机)。
生产(CDN)
raw https://gistcdn.githack.com/[用户]/ [gist] / [revision] / [filename。请拨分机)。
更新:rawgit已经停产
Raw.github.com/user/repository已经不存在了
要链接,href到github中的源代码,你必须使用github链接到原始源代码,以这种方式:
raw.githubusercontent.com/user/repository/master/file.extension
例子
<html>
...
...
<head>
<script src="https://raw.githubusercontent.com/amiahmadtouseef/tutorialhtmlfive/master/petdecider/script.js"></script>
...
</head>
<body>
...
</html>
有一个叫做GitHub HTML预览的新工具,它完全可以满足你的需要。只需要在http://htmlpreview.github.io/前加上一个前缀?到任何HTML文件的URL,例如http://htmlpreview.github.io/?https://github.com/twbs/bootstrap/blob/gh-pages/2.3.2/index.html
注意:这个工具实际上是一个github。IO页面,不属于github作为一个公司。
你可以很容易地通过修改响应头,这可以用Chrome和Firefox扩展像Requestly完成。
在Chrome和Firefox中:
Chrome和Firefox的请求式安装 添加以下头部修改规则: 一)内容类型: 修改 响应 标题:内容类型 价值:text / html 源Url匹配:/raw\.githubusercontent\.com/.*\.html/ b) Content-Security-Policy: 修改 响应 标题:Content-Security-Policy 取值:default-src 'none';Style-src 'self' '不安全的内联';Img-src 'self'数据:;Script-src * '不安全的eval'; 源Url匹配:/raw\.githubusercontent\.com/.*\.html/