0a93165f57f676b345ac434c350bfaad4f30a779
[project/luci.git] / themes / luci-theme-bootstrap / luasrc / view / themes / bootstrap / header.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008-2016 Jo-Philipp Wich <jow@openwrt.org>
4 Copyright 2012 David Menting <david@nut-bolt.nl>
5 Licensed to the public under the Apache License 2.0.
6 -%>
7
8 <%
9 local sys = require "luci.sys"
10 local util = require "luci.util"
11 local http = require "luci.http"
12 local disp = require "luci.dispatcher"
13
14 local boardinfo = util.ubus("system", "board")
15
16 local node = disp.context.dispatched
17
18 local darkpref
19
20 if theme == "bootstrap-dark" then
21 darkpref = "true"
22 elseif theme == "bootstrap-light" then
23 darkpref = "false"
24 end
25
26 -- send as HTML5
27 http.prepare_content("text/html")
28 -%>
29 <!DOCTYPE html>
30 <html lang="<%=luci.i18n.context.lang%>"<%= ifattr(darkpref ~= nil, "data-darkmode", darkpref) %>>
31 <head>
32 <meta charset="utf-8">
33 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
34 <% if darkpref == nil then %>
35 <script type="text/javascript">
36 var mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'),
37 rootElement = document.querySelector(':root'),
38 setDarkMode = function(match) { rootElement.setAttribute('data-darkmode', match.matches) };
39
40 mediaQuery.addEventListener('change', setDarkMode);
41 setDarkMode(mediaQuery);
42 </script>
43 <% end %>
44 <meta name="viewport" content="initial-scale=1.0">
45 <link rel="stylesheet" href="<%=media%>/cascade.css">
46 <link rel="stylesheet" media="only screen and (max-device-width: 854px)" href="<%=media%>/mobile.css" type="text/css" />
47 <link rel="shortcut icon" href="<%=media%>/favicon.png">
48 <% if node and node.css then %>
49 <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
50 <% end -%>
51 <% if css then %>
52 <style title="text/css"><%= css %></style>
53 <% end -%>
54 <script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
55 <script src="<%=resource%>/cbi.js"></script>
56 </head>
57
58 <body class="lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><%- end %>" data-page="<%= pcdata(table.concat(disp.context.requestpath, "-")) %>">
59 <% if not blank_page then %>
60 <header>
61 <a class="brand" href="/"><%=striptags(boardinfo.hostname or "?")%></a>
62 <ul class="nav" id="topmenu" style="display:none"></ul>
63 <div id="indicators" class="pull-right"></div>
64 </header>
65
66 <div id="maincontent" class="container">
67 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
68 <div class="alert-message warning">
69 <h4><%:No password set!%></h4>
70 <p><%:There is no password set on this router. Please configure a root password to protect the web interface.%></p>
71 <% if disp.lookup("admin/system/admin") then %>
72 <div class="right"><a class="btn" href="<%=url("admin/system/admin")%>"><%:Go to password configuration...%></a></div>
73 <% end %>
74 </div>
75 <%- end -%>
76
77 <noscript>
78 <div class="alert-message warning">
79 <h4><%:JavaScript required!%></h4>
80 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%></p>
81 </div>
82 </noscript>
83
84 <div id="tabmenu" style="display:none"></div>
85 <% end %>