Add ability to Embed GitLab Onebox

pr-welcome

(Yoginth) #1

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


(Bhanu Sharma) #2

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

Have you checked how they render on iframely?


(cpradio) #3

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

onebox/lib/onebox/engine at master 路 discourse/onebox 路 GitHub


(Bhanu Sharma) #4

So github is treated differently?


(cpradio) #5

Yes. It has a few custom engines to one box it鈥檚 urls


(Bhanu Sharma) #6

Oh okay! I was unaware of it.


(Erlend Sogge Heggen) #7

We鈥檇 be happy to support a PR that adds custom onebox behaviors for GitLab.


(Yihan "Misaka 0x4e21" X.) #8

A plugin as well:


(Sam Saffron) #9

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!


(Yihan "Misaka 0x4e21" X.) #10

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
(It seems that the GitHub icon is wrongly displayed.)


(Sam Saffron) #11

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


(Yihan "Misaka 0x4e21" X.) #12


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.


(Kane York) #13

Hmm, this only supports gitlab.com urls, not other domains?

Here鈥檚 an example:


(Yihan "Misaka 0x4e21" X.) #14

Yes it currently supports only 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: libreCMC/libreCMC - libreCMC


(Kane York) #15

I searched for identifying elements, and there鈥檚 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..."> :wink:


(Jeff Atwood) #16

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