如果我在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
其他回答
你可以分支gh-pages来运行你的代码或尝试这个扩展(Chrome, Firefox): https://github.com/ryt/githtml
如果你需要的是测试,你可以将JS文件嵌入到: http://jsperf.com/
这是一个小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);
我想在github编辑HTML和js,并有一个预览。 我想在github中做它,有即时提交和保存。
尝试rawgithub.com,但rawgithub.com不是实时的(它的缓存每分钟刷新一次)。
所以我很快想出了自己的解决方案:
Node.js解决方案:https://github.com/shimondoodkin/rawgithub
你可以很容易地通过修改响应头,这可以用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/
此解决方案仅适用于chrome浏览器。我不确定其他浏览器。
在chrome浏览器中添加“修改内容类型选项”扩展。 在浏览器中打开“chrome-extension:// jnfbopfpaoeojgieggflbpcblhfhka /options.html”url。 为原始文件url添加规则。 例如: URL过滤器:https:///raw/master//fileName.html 原始类型:文本/纯 替换类型:text/html 打开您在规则(步骤3)中添加url的文件浏览器。