1651
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
1653
|
4 local pairs = Luan.pairs or error()
|
1651
|
5
|
|
6
|
|
7 local Shared = {}
|
|
8
|
|
9 function Shared.head()
|
|
10 %>
|
|
11 <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
12 <style>
|
|
13 @import "/site.css";
|
|
14 </style>
|
|
15 <%
|
|
16 end
|
|
17
|
1652
|
18 local function header(crumbs)
|
1651
|
19 %>
|
|
20 <div header>
|
|
21 <a href="/">Luan</a>
|
|
22 <% for _, crumb in ipairs(crumbs or {}) do %>
|
|
23 / <%=crumb%>
|
|
24 <% end %>
|
|
25 </div>
|
|
26 <%
|
|
27 end
|
1652
|
28 Shared.header = header
|
|
29
|
|
30 function Shared.docs_header()
|
|
31 header{[[<a href="/docs.html">Documentation</a>]]}
|
|
32 end
|
1651
|
33
|
1653
|
34 local function show_toc(content)
|
|
35 %>
|
|
36 <ul>
|
|
37 <%
|
|
38 for id, info in pairs(content) do
|
|
39 %>
|
|
40 <li><a id="c_<%=id%>" href="#<%=id%>"><%=info.title%></a>
|
|
41 <%
|
|
42 local subs = info.subs
|
|
43 if subs ~= nil then
|
|
44 show_toc(subs)
|
|
45 end
|
|
46 %>
|
|
47 </li>
|
|
48 <%
|
|
49 end
|
|
50 %>
|
|
51 </ul>
|
|
52 <%
|
|
53 end
|
|
54 Shared.show_toc = show_toc
|
|
55
|
|
56 local function nothing() end
|
|
57
|
|
58 local function show_content(content,h)
|
|
59 for id, info in pairs(content) do
|
|
60 %>
|
|
61 <div heading>
|
|
62 <h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>>
|
|
63 <a href="#c_<%=id%>">contents</a>
|
|
64 </div>
|
|
65 <%
|
|
66 (info.content or nothing)()
|
|
67 local subs = info.subs
|
|
68 if subs ~= nil then
|
|
69 show_content(subs,h+1)
|
|
70 end
|
|
71 end
|
|
72 end
|
|
73 Shared.show_content = show_content
|
|
74
|
1651
|
75 return Shared
|