Mercurial Hosting > luan
annotate website/src/lib/Shared.luan @ 1829:0eb615de1f80
add mail helo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 22 Sep 2024 20:05:54 -0600 |
parents | 50e570b598b2 |
children |
rev | line source |
---|---|
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> | |
1747 | 21 <span breadcrumbs> |
22 <a href="/">Luan</a> | |
1651 | 23 <% for _, crumb in ipairs(crumbs or {}) do %> |
1747 | 24 / <%=crumb%> |
1651 | 25 <% end %> |
1747 | 26 </span> |
1827 | 27 <span><a href="https://www.reactionary.software/">reactionary software</a> by <a href="https://linkmy.style/fschmidt">fschmidt</a></span> |
1651 | 28 </div> |
29 <% | |
30 end | |
1652 | 31 Shared.header = header |
32 | |
33 function Shared.docs_header() | |
34 header{[[<a href="/docs.html">Documentation</a>]]} | |
35 end | |
1651 | 36 |
1653 | 37 local function show_toc(content) |
38 %> | |
39 <ul> | |
40 <% | |
41 for id, info in pairs(content) do | |
42 %> | |
1812
f44dcb3fedf7
docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents:
1784
diff
changeset
|
43 <li c_<%=id%> ><a id="c_<%=id%>" href="#<%=id%>"><%=info.title%></a> |
1653 | 44 <% |
45 local subs = info.subs | |
46 if subs ~= nil then | |
47 show_toc(subs) | |
48 end | |
49 %> | |
50 </li> | |
51 <% | |
52 end | |
53 %> | |
54 </ul> | |
55 <% | |
56 end | |
57 Shared.show_toc = show_toc | |
58 | |
59 local function nothing() end | |
60 | |
61 local function show_content(content,h) | |
62 for id, info in pairs(content) do | |
63 %> | |
64 <div heading> | |
65 <h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>> | |
66 <a href="#c_<%=id%>">contents</a> | |
67 </div> | |
68 <% | |
69 (info.content or nothing)() | |
70 local subs = info.subs | |
71 if subs ~= nil then | |
72 show_content(subs,h+1) | |
73 end | |
74 end | |
75 end | |
76 Shared.show_content = show_content | |
77 | |
1651 | 78 return Shared |