# Add ability to Embed GitLab Onebox

**URL:** https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368
**Category:** Feature
**Tags:** pr-welcome
**Created:** [April 28, 2018, 4:29pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368 "2018-04-28T16:29:57Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Yoginth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yoginth/32/119994_2.png) [@Yoginth](https://meta.discourse.org/u/Yoginth)
#### Post date: [April 28, 2018, 4:29pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/1 "2018-04-28T16:29:57Z")

</div>

Add ability to Embed GitLab Onebox by displaying the code inside like GitHub Does in Discourse.

[https://gitlab.com/DevsPen/Theme/blob/master/about.json](https://gitlab.com/DevsPen/Theme/blob/master/about.json)

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [April 28, 2018, 5:09pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/2 "2018-04-28T17:09:48Z")

</div>

Gitlab needs to support it. Onebox probably has nothing to do with it.

Have you checked how they render on iframely?

> **[Embeds codes for today's Internet - Iframely](https://iframely.com/)**
>
> Iframely gives you simple APIs to have all the Web's best media on your site and on all your users' devices.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [April 28, 2018, 10:07pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/3 "2018-04-28T22:07:12Z")

</div>

I’m not so sure. Gitlab is similar to Github, which has its own onebox engine/rule

[onebox/lib/onebox/engine at main · discourse/onebox · GitHub](https://github.com/discourse/onebox/tree/master/lib/onebox/engine)

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [April 29, 2018, 4:05am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/4 "2018-04-29T04:05:02Z")

</div>

So github is treated differently?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [April 29, 2018, 4:45pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/5 "2018-04-29T16:45:14Z")

</div>

Yes. It has a few custom engines to one box it’s urls

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [April 29, 2018, 4:46pm UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/6 "2018-04-29T16:46:08Z")

</div>

Oh okay! I was unaware of it.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [April 30, 2018, 7:43am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/7 "2018-04-30T07:43:56Z")

</div>

We’d be happy to support a PR that adds custom onebox behaviors for GitLab.

---

<div class="post-metadata">

### Author: ![misaka4e21](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@misaka4e21](https://meta.discourse.org/u/misaka4e21)
#### Post date: [June 7, 2018, 4:11am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/8 "2018-06-07T04:11:15Z")

</div>

[https://github.com/discourse/onebox/pull/385](https://github.com/discourse/onebox/pull/385)

A plugin as well:  
[https://github.com/misaka4e21/discourse-onebox-gitlab](https://github.com/misaka4e21/discourse-onebox-gitlab)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 7, 2018, 4:57am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/9 "2018-06-07T04:57:01Z")

</div>

This is very cool, but I feel like we should just fold it all into onebox, no need to add one more plugin here.

Can you show some screenshots of how it looks?

Excellent work @misaka4e21!

---

<div class="post-metadata">

### Author: ![misaka4e21](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@misaka4e21](https://meta.discourse.org/u/misaka4e21)
#### Post date: [June 7, 2018, 5:35am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/10 "2018-06-07T05:35:41Z")

</div>

The plugin will only be necessary when the pull request is not merged. All things in the plugin are included in the PR.

 ![%E5%9C%96%E7%89%87](https://global.discourse-cdn.com/meta/original/3X/1/6/1687d3952283ad19d4fb2d69905ad53e8a34ebd2.png)  
(It seems that the GitHub icon is wrongly displayed.)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 7, 2018, 5:55am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/11 "2018-06-07T05:55:02Z")

</div>

cool lets get the icon sorted as well, also the spacing the the gutter looks really big.

---

<div class="post-metadata">

### Author: ![misaka4e21](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@misaka4e21](https://meta.discourse.org/u/misaka4e21)
#### Post date: [June 12, 2018, 7:47am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/12 "2018-06-12T07:47:03Z")

</div>

![%E5%9C%96%E7%89%87](https://global.discourse-cdn.com/meta/original/3X/4/d/4d7af6a4f5f4142dc33b2249873eb22698cf5d13.png)  
The GitHub favicon is now removed for GitLab. The independent icon of GitLab should be added to the discourse `onebox.scss` and assets instead of the onebox repo, in order to be shown.

As for the spacing issue, it is the same as current GitHub ones.

> <https://github.com/discourse/discourse/blob/main/README.md#L1>

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [June 13, 2018, 1:15am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/13 "2018-06-13T01:15:12Z")

</div>

Hmm, this only supports [gitlab.com](http://gitlab.com) urls, not other domains?

Here’s an example:

[https://git.pleroma.social/pleroma/pleroma/blob/develop/mix.exs#L28-30](https://git.pleroma.social/pleroma/pleroma/blob/develop/mix.exs#L28-30)

---

<div class="post-metadata">

### Author: ![misaka4e21](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@misaka4e21](https://meta.discourse.org/u/misaka4e21)
#### Post date: [June 13, 2018, 1:42am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/14 "2018-06-13T01:42:12Z")

</div>

Yes it currently supports only [gitlab.com](http://gitlab.com).

Should we match any URL with pattern `/<user>/<repo>/blob/<branch|commit>/<path>` without checking it to be a GitLab instance?

And, there is also other git hosting platform, such as gogs: [Making sure you're not a bot!](https://gogs.librecmc.org/libreCMC/libreCMC/src/v1.4/README.md)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [June 13, 2018, 2:23am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/15 "2018-06-13T02:23:26Z")

</div>

I searched for identifying elements, and there’s nothing good in the `<head>`, but `body[data-page="projects:blob:show"]` might be a good one.

Of cousre, Discourse has `<meta name="generator" content="Discourse...">` 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 13, 2018, 2:53am UTC](https://meta.discourse.org/t/add-ability-to-embed-gitlab-onebox/86368/16 "2018-06-13T02:53:22Z")

</div>

I think `gitlab.com` only for now is fine, we can further refine it later.
