如果我在GitHub存储库中有一个。html文件,例如运行一组JavaScript测试,有什么方法可以直接查看该页面,从而运行测试?
例如,我是否可以看到jQuery测试套件生成的测试结果,而不需要下载或将repo复制到本地驱动器并在那里运行?
我知道这基本上会把GitHub放在静态内容托管业务中,但话又说回来,他们只需要改变他们的mime类型从文本/纯文本/html。
如果我在GitHub存储库中有一个。html文件,例如运行一组JavaScript测试,有什么方法可以直接查看该页面,从而运行测试?
例如,我是否可以看到jQuery测试套件生成的测试结果,而不需要下载或将repo复制到本地驱动器并在那里运行?
我知道这基本上会把GitHub放在静态内容托管业务中,但话又说回来,他们只需要改变他们的mime类型从文本/纯文本/html。
当前回答
我想在github编辑HTML和js,并有一个预览。 我想在github中做它,有即时提交和保存。
尝试rawgithub.com,但rawgithub.com不是实时的(它的缓存每分钟刷新一次)。
所以我很快想出了自己的解决方案:
Node.js解决方案:https://github.com/shimondoodkin/rawgithub
其他回答
Github有一个名为Github pages的静态页面托管服务,你可以在设置下找到它,然后选择页面,并选择你想要为页面使用的分支并点击保存。
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>
你可以很容易地通过修改响应头,这可以用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 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作为一个公司。
这是一个小Greasemonkey脚本,将添加一个CDN按钮的html页面上的github
目标页面的格式为:https://cdn.rawgit.com/user/repo/master/filename.js
// ==UserScript==
// @name cdn.rawgit.com
// @namespace github.com
// @include https://github.com/*/blob/*.html
// @version 1
// @grant none
// ==/UserScript==
var buttonGroup = $(".meta .actions .button-group");
var raw = buttonGroup.find("#raw-url");
var cdn = raw.clone();
cdn.attr("id", "cdn-url");
cdn.attr("href", "https://cdn.rawgit.com" + cdn.attr("href").replace("/raw/","/") );
cdn.text("CDN");
cdn.insertBefore(raw);