Render rack elevation SVG with absolute URLs #3313

Closed
opened 2025-12-29 18:27:37 +01:00 by adam · 4 comments
Owner

Originally created by @ananace on GitHub (Feb 12, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.4

Proposed Functionality

The current SVG rendering for rack elevations results in SVGs containing URLs that are relative, this makes it a slight bit more intricate to embed those SVG images in other systems without moving the image query and embedding into the client's browser.
If instead all a tags in the elevation SVGs were rendered with absolute URLs, then the resulting image could be cached and re-served as part of a server-side render in a completely different system, without requiring rewriting the image on the server.

Use Case

With absolute URLs, rack views could be embedded into systems with different access rules than NetBox itself, letting the server retrieve and display the images in unmodified form to clients, while still easily allowing privileged users to click through into NetBox proper.

Originally created by @ananace on GitHub (Feb 12, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7.6<!-- Example: 3.6.9 --> * NetBox version: 2.7.4<!-- Example: 2.7.3 --> <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality The current SVG rendering for rack elevations results in SVGs containing URLs that are relative, this makes it a slight bit more intricate to embed those SVG images in other systems without moving the image query and embedding into the client's browser. If instead all `a` tags in the elevation SVGs were rendered with absolute URLs, then the resulting image could be cached and re-served as part of a server-side render in a completely different system, without requiring rewriting the image on the server. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case With absolute URLs, rack views could be embedded into systems with different access rules than NetBox itself, letting the server retrieve and display the images in unmodified form to clients, while still easily allowing privileged users to click through into NetBox proper.
adam added the status: acceptedtype: feature labels 2025-12-29 18:27:37 +01:00
adam closed this issue 2025-12-29 18:27:37 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 12, 2020):

My only potential concern would be that we're hard-coding URLs for non-API views in content delivered via the API. That should be okay though, since it's difficult to imagine a use case where the links within an SVG image (obviously intended for human consumption) would need to hit the API views.

@jeremystretch commented on GitHub (Feb 12, 2020): My only potential concern would be that we're hard-coding URLs for non-API views in content delivered via the API. That should be okay though, since it's difficult to imagine a use case where the links within an SVG image (obviously intended for human consumption) would need to hit the API views.
Author
Owner

@jeremystretch commented on GitHub (Feb 12, 2020):

Also: Can this be solved by adding a <base> tag to the SVG document, rather than directly specifying absolute URLs for every element?

@jeremystretch commented on GitHub (Feb 12, 2020): Also: Can this be solved by adding a `<base>` tag to the SVG document, rather than directly specifying absolute URLs for every element?
Author
Owner

@ananace commented on GitHub (Feb 12, 2020):

I had that thought as well, though I wasn't able to find any useful answers on how well the use of a <base> tag in an SVG would work.

@ananace commented on GitHub (Feb 12, 2020): I had that thought as well, though I wasn't able to find any useful answers on how well the use of a `<base>` tag in an SVG would work.
Author
Owner

@jeremystretch commented on GitHub (Feb 21, 2020):

Just took a few minutes to dig into this. AFAICT using <base> doesn't seem feasible with svgwrite: We'll have to hard-code full URLs for all links.

@jeremystretch commented on GitHub (Feb 21, 2020): Just took a few minutes to dig into this. AFAICT using `<base>` doesn't seem feasible with svgwrite: We'll have to hard-code full URLs for all links.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3313