Page MenuHomeSoftware Heritage

Define use cases for an iframe to show source code
Open, NormalPublic

Event Timeline

moranegg triaged this task as Normal priority.Fri, May 28, 11:49 AM
moranegg created this task.

I made some quick hacks in swh-web to see if it was easily feasible to have standalone source code view that could be embedded into an iframe, the answer is yes !

So we could do it the following way:

  • add a new dedicated view for standalone source code display with no usage of X-Frame-Options HTTP header, here I used /content/<swhid> as endpoint
  • the URL of that view can then be used as an iframe src

Below are some screenshots of the result:

Standalone source code view

Standalone source code view in an iframe, inserted using the code below

<iframe style="height: 500px;" src="http://localhost:5004/content/swh:1:cnt:61c750e88335e4a32e34b04d8509c45636644f37;path=bytearray_stubs.c"></iframe>

As the purpose will be to embed source code views in external websites, we should also add a Software Heritage icon and label somewehere that always remain visible when the view is scrolled.
Another cool thing is that lines highlighting and scrolling to will also work if the lines qualifier is part of the input SWHID.
If we decide to offer that feature, we should also have a quick way to get the iframe embedding link from the main browse interface.

I made some quick hacks in swh-web to see if it was easily feasible to have standalone source code view that could be embedded into an iframe, the answer is yes !

This is great to know (and see :-)

Standalone source code view in an iframe, inserted using the code below

<iframe style="height: 500px;" src="http://localhost:5004/content/swh:1:cnt:61c750e88335e4a32e34b04d8509c45636644f37;path=bytearray_stubs.c"></iframe>

Can it work with a content SWHID with context?

As the purpose will be to embed source code views in external websites, we should also add a Software Heritage icon and label somewehere that always remain visible when the view is scrolled.

Good thinking, I agree that a SWH icon is needed.

Another cool thing is that lines highlighting and scrolling to will also work if the lines qualifier is part of the input SWHID.

That's great!

If we decide to offer that feature, we should also have a quick way to get the iframe embedding link from the main browse interface.

+1

The most used iframe might be the directory iframe.
Which might be more complicated to show.

Another question: will the iframe resize to the size (length) of the content, or will it depend on the external platform style?

Can it work with a content SWHID with context?

Yes this could be adapted to handle anchor qualifier and allow to navigate into a source tree associated to the content.
We could also handle the origin and snapshot qualifier to create a link that will open the full SWH browse Web application
in a new tab of the browser.

The most used iframe might be the directory iframe.
Which might be more complicated to show.

This should not be complicated to implement but we should provide a really minimal
UI with a simple breadcrumbs above the displayed directories and contents.

Another question: will the iframe resize to the size (length) of the content, or will it depend on the external platform style?

Size of the iframe must be handled in the external HTML/CSS code integrating it from my point of view.