luci-base: expose effective dispatched path to client side environment
[oweals/luci.git] / modules / luci-base / luasrc / view / header.htm
1 <%#
2  Copyright 2008 Steven Barth <steven@midlink.org>
3  Copyright 2008-2019 Jo-Philipp Wich <jo@mein.io>
4  Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%
8         if not luci.dispatcher.context.template_header_sent then
9                 include("themes/" .. theme .. "/header")
10                 luci.dispatcher.context.template_header_sent = true
11         end
12
13         local applyconf = luci.config and luci.config.apply
14 %>
15
16 <script type="text/javascript" src="<%=resource%>/promis.min.js"></script>
17 <script type="text/javascript" src="<%=resource%>/luci.js"></script>
18 <script type="text/javascript">
19         L = new LuCI(<%= luci.http.write_json({
20                 token          = token,
21                 media          = media,
22                 resource       = resource,
23                 scriptname     = luci.http.getenv("SCRIPT_NAME"),
24                 pathinfo       = luci.http.getenv("PATH_INFO"),
25                 requestpath    = luci.dispatcher.context.requestpath,
26                 dispatchpath   = luci.dispatcher.context.path,
27                 pollinterval   = luci.config.main.pollinterval or 5,
28                 sessionid      = luci.dispatcher.context.authsession,
29                 apply_rollback = math.max(applyconf and applyconf.rollback or 30, 30),
30                 apply_holdoff  = math.max(applyconf and applyconf.holdoff or 4, 1),
31                 apply_timeout  = math.max(applyconf and applyconf.timeout or 5, 1),
32                 apply_display  = math.max(applyconf and applyconf.display or 1.5, 1),
33                 rollback_token = rollback_token
34         }) %>);
35 </script>