annotate website/src/lib/Shared.luan @ 1695:25833dd89844

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