Mercurial Hosting > luan
diff website/src/lib/Shared.luan @ 1929:31f006c64782
translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 May 2025 18:31:05 -0600 |
parents | 50e570b598b2 |
children |
line wrap: on
line diff
--- a/website/src/lib/Shared.luan Sun Apr 27 04:24:08 2025 -0600 +++ b/website/src/lib/Shared.luan Thu May 01 18:31:05 2025 -0600 @@ -2,27 +2,54 @@ local error = Luan.error local ipairs = Luan.ipairs or error() local pairs = Luan.pairs or error() +local Time = require "luan:Time.luan" +local Http = require "luan:http/Http.luan" +local Site_translator = require "luan:gpt/Site_translator.luan" +local get_lang = Site_translator.get_lang or error() +local languages = Site_translator.languages or error() +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "Shared" local Shared = {} +Http.not_found_handler = Site_translator.not_found_handler or error() + +local started = Time.now() +Shared.started = started + function Shared.head() %> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> - @import "/site.css"; + @import "/site.css?s=<%=started%>"; </style> + <script src="/site.js?s=<%=started%>"></script> <% end local function header(crumbs) + local lang = get_lang() + local home + if lang == "en" then + home = "/" + else + home = "/"..lang.."/" + end %> <div header> <span breadcrumbs> - <a href="/">Luan</a> + <a href="<%=home%>">Luan</a> <% for _, crumb in ipairs(crumbs or {}) do %> / <%=crumb%> <% end %> + - <select onchange="setLanguage(value)"> +<% for code, name in pairs(languages) do + local selected = code==lang and "selected" or "" +%> + <option value="<%=code%>" <%=selected%> ><%=name%></option> +<% end %> + </select> </span> <span><a href="https://www.reactionary.software/">reactionary software</a> by <a href="https://linkmy.style/fschmidt">fschmidt</a></span> </div> @@ -31,7 +58,7 @@ Shared.header = header function Shared.docs_header() - header{[[<a href="/docs.html">Documentation</a>]]} + header{[[<a href="docs.html">Documentation</a>]]} end local function show_toc(content) @@ -58,8 +85,9 @@ local function nothing() end -local function show_content(content,h) - for id, info in pairs(content) do +local show_content, show_content_info + +function show_content_info(id,info,h) %> <div heading> <h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>> @@ -71,6 +99,12 @@ if subs ~= nil then show_content(subs,h+1) end +end +Shared.show_content_info = show_content_info + +function show_content(content,h) + for id, info in pairs(content) do + show_content_info(id,info,h) end end Shared.show_content = show_content