git 我的 Gitlab 存储库中的 Web 访问 HTML 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24192534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:06:51  来源:igfitidea点击:

Web access HTML file in my Gitlab repo

htmlgitgitlabweb-access

提问by user3735448

I want to use Gitlabto manage web-application development. Is it possible to access the htmlfile I have created in my Gitlab repofrom the browser?

我想用来Gitlab管理网络应用程序开发。是否可以从浏览器访问html我在我的文件中创建的文件Gitlab repo

Currently there are ssh/httpurl for access to the repo like:

目前有ssh/http访问 repo 的 url,如:

ssh: [email protected]:balbal/web-app.git   
http: (ht tps://something.some.ca:balbal/web-app.git)

When I access httpsfrom a browser it will just jump into the git repo manage UI (like show you all the commits, branches and detail files)

当我https从浏览器访问时,它只会跳转到 git repo 管理 UI(例如向您展示所有提交、分支和详细文件)

What I want is web access to a particular htmlfile I have created in my repo (like if there is a index.htmlfile in a folder called 'www' in my repo). I want some URL that I can type into the browser and which will show me the index.htmlcontent. Is it possible for me to set up an web access to these htmlfiles?

我想要的是对html我在我的 repo 中创建的特定文件的Web 访问(就像我的 repoindex.html中名为“www”的文件夹中有一个文件一样)。我想要一些可以在浏览器中输入的 URL,它会向我显示index.html内容。我可以设置对这些html文件的网络访问吗?

回答by fiorix

As of now, Gitlab does not support this functionality. There's a feature request for this: http://feedback.gitlab.com/forums/176466-general/suggestions/5599145-preview-render-static-html-pages-pushed-to-repos

目前,Gitlab 不支持此功能。对此有一个功能请求:http: //feedback.gitlab.com/forums/176466-general/suggestions/5599145-preview-render-static-html-pages-pushed-to-repos

Currently, if you query Gitlab for the raw html file, it sets certain HTTP headers to make it render as text/plain instead:

目前,如果您查询 Gitlab 以获取原始 html 文件,它会设置某些 HTTP 标头以使其呈现为文本/纯文本:

$ curl -I http://my-gitlab/user/project/raw/dev/doc/_book/index.html
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 20 Apr 2015 13:17:48 GMT
Content-Type: text/plain; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-UA-Compatible: IE=edge
Content-Disposition: inline; filename="index.html"
Content-Transfer-Encoding: binary
Cache-Control: private
ETag: "b81191c550c47eae1ab4adf72dfd0c92"
Set-Cookie: request_method=HEAD; path=/
X-Request-Id: 04ae0499-2fdf-4f89-82ab-8392a8d6a076
X-Runtime: 0.019857

回答by Alex Gru

Fortunately, with GitLab 10.1, online display of HTML files is now officially supported.

幸运的是,在 GitLab 10.1 中,现在正式支持 HTML 文件的在线显示。

See the documentationfor more details.

有关更多详细信息,请参阅文档

With GitLab 10.1, we introduce the online visualization of HTML files created by pipelines for public projects, just one click away from the artifacts browser view.

在 GitLab 10.1 中,我们引入了由管道为公共项目创建的 HTML 文件的在线可视化,只需在工件浏览器视图中单击一下即可。

回答by Christophe Roussy

For quick debugging/testing purposes you may use the FireFox PourBicoplugin.

为了快速调试/测试,您可以使用 FireFox PourBico插件。

Change the response headerto text/html

将响应头更改为 text/html

Avoid doing this on the public GitLab, do this on your own GitLab deployment, GitLab was not meant to be hacked like this.

避免在公共 GitLab 上执行此操作,在您自己的 GitLab 部署上执行此操作,GitLab 不应该像这样被黑客攻击。

Also see Github pages, HTTP headers

另请参阅Github 页面、HTTP 标头

回答by Yogesh N

For Chrome, one can use extensions such as Header Hackerand set the headers to render HTML by changing the content-type in the browser. As mentioned by Christophe Roussy this is a hack and you should really have a good reason for doing this.

对于 Chrome,可以使用Header Hacker等扩展程序,并通过更改浏览器中的内容类型来设置标题以呈现 HTML。正如 Christophe Roussy 所提到的,这是一个 hack,你真的应该有一个很好的理由这样做。