Embedding Gitea source in external pages?

I’m running Gitea to host my git repos. Many thanks for that, OSS community!

On my blog, I’d like to discuss some code that is stored (publicly) on Gitea. Can anybody think of a way to embed that file directly from git onto my webpage? Like, adding some JS to my page, which would in turn grab that piece of code and render it just like the Gitea page itself? Like, gists?

<script src="https://gist.github.com/datenimperator/5fe86f6a318b7b27a0a934f72af3340d.js"></script>

My blog is all static pages, generated by Jekyll. So a dynamic solution incorporating server-side functionality is out of scope. Regards

Christian

1 Like

I think you can do that to link to a raw link of a file. i.e. https://gitea.com/gitea/tea/raw/branch/master/demo.gif

Thx. That’d not give me the nice visual representation of the code editor embedded in Gitea. Eg no line numbers, syntax coloring or else. I see Gitea itself is using the Monaco editor library, probably I’ll build something around that, that’ll pull source from Gitea using the raw URL that you’ve mentioned.

Yeah. It’s better for Gitea to have that feature but unfortunately there is not. But I think it’s not difficult for you to find a javascript code highlight plugin to do that.

To answer my own question: I created some Javascript along with a liitle bit of Jekyll integration to do exactly that.

{% gitea https://some.url/path/file.js %}

will be visualized as a prism-enabled syntax highlighted block of source code, retrieved directly from Gitea. Gitea Integration mit Code Highlighting · 17932348fa - software-berater.net - Gitea

I needed to get CORS header along with my Gitea response and had no luck doing so using the Gitea configuration. But I could add those headers using Traefik.

It must not be on the todo list; I requested it 3 years ago and got crickets. :face_with_diagonal_mouth:

1 Like