1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

102 lines
3.3 KiB
HTML

{# Base template for (almost) all NetBox pages #}
{% load static %}
{% load helpers %}
<!DOCTYPE html>
<html
lang="en"
data-netbox-path="{{ request.path }}"
{% if preferences|get_key:'ui.colormode' == 'dark'%}
data-netbox-color-mode="dark"
{% else %}
data-netbox-color-mode="light"
{% endif %}
>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"
/>
{# Page title #}
<title>{% block title %}Home{% endblock %} | NetBox</title>
<script>
/**
* Determine the best initial color mode to use prior to rendering.
*/
(function() {
// Browser prefers dark color scheme.
var preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
// Browser prefers light color scheme.
var preferLight = window.matchMedia('(prefers-color-scheme: light)').matches;
// Client NetBox color-mode override.
var clientMode = localStorage.getItem('netbox-color-mode');
// NetBox server-rendered value.
var serverMode = document.documentElement.getAttribute('data-netbox-color-mode');
if ((clientMode !== null) && (clientMode !== serverMode)) {
// If the client mode is set, use its value over the server's value.
return document.documentElement.setAttribute('data-netbox-color-mode', clientMode);
}
if (preferDark && serverMode === 'light') {
// If the client value matches the server value, the browser preferrs dark-mode, but
// the server value doesn't match the browser preference, use dark mode.
return document.documentElement.setAttribute('data-netbox-color-mode', 'dark');
}
if (preferLight && serverMode === 'dark') {
// If the client value matches the server value, the browser preferrs dark-mode, but
// the server value doesn't match the browser preference, use light mode.
return document.documentElement.setAttribute('data-netbox-color-mode', 'light');
}
})();
</script>
{# Static resources #}
<link
rel="stylesheet"
href="{% static 'netbox-external.css'%}"
onerror="window.location='{% url 'media_failure' %}?filename=netbox-external.css'"
/>
<link
rel="stylesheet"
href="{% static 'netbox-light.css'%}"
onerror="window.location='{% url 'media_failure' %}?filename=netbox-light.css'"
/>
<link
rel="stylesheet"
href="{% static 'netbox-dark.css'%}"
onerror="window.location='{% url 'media_failure' %}?filename=netbox-dark.css'"
/>
<link rel="icon" type="image/png" href="{% static 'netbox.ico' %}" />
{# Javascript #}
<script
type="text/javascript"
src="{% static 'netbox.js' %}"
onerror="window.location='{% url 'media_failure' %}?filename=netbox.js'">
</script>
{# Additional <head> content #}
{% block head %}{% endblock %}
</head>
<body>
{# Page layout #}
{% block layout %}{% endblock %}
{# Additional Javascript #}
{% block javascript %}{% endblock %}
{# User messages #}
{% include 'inc/messages.html' %}
{# Data container #}
<div id="netbox-data" style="display: none!important; visibility: hidden!important">
{% block data %}{% endblock %}
</div>
</body>
</html>