在http://github.com开发人员保留项目的html,csss,javascript和图像文件 . 我如何在浏览器中看到html输出?
例如https://github.com/necolas/css3-social-signin-buttons/blob/master/index.html
当我打开它时,它不会显示作者代码的渲染html . 它将页面显示为源代码 .
是否可以直接看到呈现的HTML?否则我总是需要下载整个zipt才能看到结果
在http://github.com开发人员保留项目的html,csss,javascript和图像文件 . 我如何在浏览器中看到html输出?
例如https://github.com/necolas/css3-social-signin-buttons/blob/master/index.html
当我打开它时,它不会显示作者代码的渲染html . 它将页面显示为源代码 .
是否可以直接看到呈现的HTML?否则我总是需要下载整个zipt才能看到结果
8 回答
我阅读了所有的评论,并认为github让普通用户创建github页面变得非常困难,直到我访问github theme Page,其中明确提到在相关仓库的设置页面下有"Github Pages"的一部分,您可以选择选项"use the master branch for GitHub Pages."和volla !! ...结账那个特别的回购https://username.github.io/reponame
screenshot to support my answer
此解决方案仅适用于Chrome浏览器 . 我不确定其他浏览器 .
在Chrome浏览器中添加"Modify Content-Type Options"扩展名 .
在浏览器中打开"chrome-extension://jnfofbopfpaoeojgieggflbpcblhfhka/options.html" url .
添加原始文件URL的规则 . 例如:
网址过滤:https:///raw/master//fileName.html
原始类型:text / plain
替换类型:text / html
打开您在规则中添加网址的文件浏览器(在步骤3中) .
此外,如果您使用Tampermonkey,则可以添加一个脚本,将
preview with http://htmlpreview.github.com/
按钮添加到'raw','blame'和'history'按钮旁边的操作菜单中 .像这样的脚本:https://gist.github.com/vanyakosmos/83ba165b288af32cf85e2cac8f02ce6d
在GitHub上预览HTML文件最舒服的方法是转到http://htmlpreview.github.com/或只是将其添加到原始URL,即:http://htmlpreview.github.com/?https://github.com/bartaz/impress.js/blob/master/index.html
如果您不想下载存档,可以使用GitHub Pages进行渲染 .
将存储库分成您的帐户 .
在您的计算机上本地克隆它
创建一个
gh-pages
分支(如果已存在,将其删除并根据master
创建一个新分支) .将分支推回GitHub .
在
http://
username.github.io/
repo 查看页面在代码中:
你可以使用RawGit:
https://rawgit.com/necolas/css3-social-signin-buttons/master/index.html
它比http://htmlpreview.github.com/更好(在撰写本文时),提供具有适当Content-Type标头的文件 . 此外,它还提供用于 生产环境 的CDN URL .
使用github pages真的很容易,'s just a bit weird the first time you do it. Sorta like the first time you had to juggle 3 kittens while learning to knit. (OK, it'并不是那么糟糕)
You need a gh-pages branch:
基本上github.com寻找存储库的gh-pages branch . 它将所有在此处找到的HTML页面作为普通HTML直接提供给浏览器 .
How do I get this gh-pages branch?
简单 . 只需创建一个名为gh-branches的github repo分支 . 当您创建此分支时指定 --orphan ,因为您实际上并不想将此分支合并回您的github分支,您只需要一个包含HTML资源的分支 .
What about all the other gunk in my repo, how does that fit in to it?
不,你可以继续删除它 . 现在这样做是安全的,因为你一直在关注并创建了一个孤儿分支,它不能合并回你的主分支并删除所有代码 .
I've created the branch, now what?
您需要将此分支推送到github.com,以便他们的自动化可以启动并开始为您托管这些页面 .
But.. My HTML is still not being served!
github需要几分钟时间来索引这些分支并启动所需的基础架构来提供内容 . 根据github,最多10分钟 .
The steps layed out by github.com
https://help.github.com/articles/creating-project-pages-manually
这不是一个直接的答案,但我认为这是一个非常甜蜜的选择 .
http://www.s3auth.com/
它允许您在基本身份验证后托管您的页面 . 非常适合私人github回购中的api文档 . 只需将s3作为api版本的一部分 .