summaryrefslogtreecommitdiffstats
path: root/app/template-html.lsp
blob: bd4bb851db89df3139f6f46e4f59edfdd266830f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<% local viewtable, viewlibrary, pageinfo, session = ... 
   html=require("acf.html") %>
Status: 200 OK
Content-Type: text/html
<% if (session.id) then 
	io.write( html.cookie.set("sessionid", session.id) ) 
  else
	io.write (html.cookie.unset("sessionid"))
  end
%>

<!DOCTYPE html>
<!--[if IE 6]> <html class="ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<%
		local hostname = ""
		if viewlibrary and viewlibrary.dispatch_component then
			local result = viewlibrary.dispatch_component("alpine-baselayout/hostname/read", nil, true)
			if result and result.value then
				hostname = result.value
			end
		end
		%>

		<title><%= html.html_escape(hostname .. " - " .. pageinfo.controller .. " -> " .. pageinfo.action) %></title>
		
		<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.wwwprefix..pageinfo.staticdir) %>/reset.css">
		<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.wwwprefix..pageinfo.skin.."/"..posix.basename(pageinfo.skin)..".css") %>">

		<script type="text/javascript" src="<%= html.html_escape(pageinfo.wwwprefix) %>/js/jquery-latest.js"></script>
		<script type="text/javascript">
			$(function(){
				$(":input:not(:submit):enabled:not([readonly]):first").focus();
			});
		</script>
	</head>
	<body>

		<div id="page">
			<div id="header">
				<h1>AlpineLinux</h1>
				<p class="hostname"><%= html.html_escape(hostname or "unknown hostname") %></p>
			
				<% 
				local ctlr = pageinfo.script .. "/acf-util/logon/"
			
				if session.userinfo and session.userinfo.userid then
					io.write ( string.format("\t\t\t\t\t\t<a href=\"%s\">Log out as '" .. html.html_escape(session.userinfo.userid) .. "'</a>\n", html.html_escape(ctlr) .. "logout" ) )
				else
		   			io.write ( string.format("\t\t\t\t\t\t<a href=\"%s\">Log in</a>\n", html.html_escape(ctlr) .. "logon" ) )
				end 
				%>
			</div>	<!-- header -->

			<div id="main">
				<ul id="nav">
					<% 
					local class
					local tabs
					for x,cat in ipairs(session.menu.cats) do
						io.write (string.format("\n\t\t\t\t<li>%s\n\t\t\t\t\t<ul>\n", html.html_escape(cat.name)))	--start row
						for y,group in ipairs(cat.groups) do
							class=""
							if not tabs and group.controllers[pageinfo.prefix .. pageinfo.controller] then
								class="class='selected'"
								tabs = group.tabs
							end
							
							io.write (string.format("\t\t\t\t\t\t<li %s><a %s href=\"%s%s%s/%s\">%s</a></li>\n", class,class,html.html_escape(pageinfo.script),html.html_escape(group.tabs[1].prefix), html.html_escape(group.tabs[1].controller), html.html_escape(group.tabs[1].action), html.html_escape(group.name) ))
						end
						io.write ( "\t\t\t\t\t</ul>" )
						io.write ("\t\t\t\t</li>")
			  		end
					%>
				</ul> <!-- nav -->

				<ul id="subnav">
					<% local class="" %>
					<% 
					for x,tab in pairs(tabs or {})  do
						if tab.prefix == pageinfo.prefix and tab.controller == pageinfo.controller and tab.action == pageinfo.action then
							class="class='selected'"
						else
							class=""
						end
						
						io.write (string.format('<li %s><a %s href="%s%s%s/%s">%s</a></li>\n',class,class,html.html_escape(pageinfo.script),html.html_escape(tab.prefix),html.html_escape(tab.controller),html.html_escape(tab.action),html.html_escape(tab.name) ))
					end
					%>
				</ul> <!-- subnav -->

				<div id="content">

					<% pageinfo.viewfunc(viewtable, viewlibrary, pageinfo, session) %>

				</div>	<!-- content -->

			</div> <!-- main -->

			<p id="footer">Page generated in <%= html.html_escape(os.clock()) %> seconds on <%= html.html_escape(os.date()) %>.</p> 
		</div> <!-- page -->
	</body>
</html>