95
|
1 local ai = "gpt"
|
|
2
|
0
|
3 local Luan = require "luan:Luan.luan"
|
|
4 local error = Luan.error
|
1
|
5 local ipairs = Luan.ipairs or error()
|
91
|
6 local pairs = Luan.pairs or error()
|
|
7 local Time = require "luan:Time.luan"
|
|
8 local Http = require "luan:http/Http.luan"
|
95
|
9 local Ai = require "luan:ai/Ai.luan"
|
|
10 Ai.set_ai(ai)
|
|
11 local require_ai = Ai.require_ai or error()
|
|
12 local Translator = require_ai "Translator.luan"
|
|
13 local Site_translator = require "luan:ai/Site_translator.luan"
|
91
|
14 local get_lang = Site_translator.get_lang or error()
|
|
15 local languages = Site_translator.languages or error()
|
0
|
16
|
|
17
|
|
18 local Shared = {}
|
|
19
|
95
|
20 if ai == "gpt" then
|
|
21 function Translator.prompt(html,language)
|
92
|
22 %>
|
|
23 Please translate the HTML below delimited by triple quotes from English to <%=language%>.
|
|
24
|
|
25 Note that the content is related to computer programming, so keep that in mind while translating. The English word "library" refers to a programming library, not a place to borrow books, so translate to the word in the target language that means programming library. So for Spanish, use "librerÃa".
|
|
26
|
|
27 Do not translate file names.
|
|
28
|
|
29 Do not translate the contents of <code> tags.
|
|
30
|
|
31 """
|
|
32 <%=html%>
|
|
33 """
|
|
34 <%
|
95
|
35 end
|
|
36 else error(ai) end
|
92
|
37
|
91
|
38 Http.not_found_handler = Site_translator.not_found_handler or error()
|
|
39
|
|
40 local started = Time.now()
|
|
41
|
0
|
42 function Shared.head()
|
|
43 %>
|
|
44 <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
45 <style>
|
91
|
46 @import "/site.css?s=<%=started%>";
|
0
|
47 </style>
|
91
|
48 <script src="/site.js?s=<%=started%>"></script>
|
0
|
49 <%
|
|
50 end
|
|
51
|
1
|
52 local function header(crumbs)
|
91
|
53 local lang = get_lang()
|
|
54 local home
|
|
55 if lang == "en" then
|
|
56 home = "/"
|
|
57 else
|
|
58 home = "/"..lang.."/"
|
|
59 end
|
0
|
60 %>
|
|
61 <div header>
|
31
|
62 <span breadcrumbs>
|
91
|
63 <a href="<%=home%>">Reactionary Software</a>
|
1
|
64 <% for _, crumb in ipairs(crumbs or {}) do %>
|
31
|
65 / <%=crumb%>
|
1
|
66 <% end %>
|
91
|
67 - <select onchange="setLanguage(value)">
|
|
68 <% for code, name in pairs(languages) do
|
|
69 local selected = code==lang and "selected" or ""
|
|
70 %>
|
|
71 <option value="<%=code%>" <%=selected%> ><%=name%></option>
|
|
72 <% end %>
|
|
73 </select>
|
31
|
74 </span>
|
34
|
75 <span>by <a href="https://linkmy.style/fschmidt">fschmidt</a></span>
|
0
|
76 </div>
|
|
77 <%
|
|
78 end
|
1
|
79 Shared.header = header
|
|
80
|
|
81 function Shared.existing_header()
|
91
|
82 header{[[<a href="existing.html">Existing</a>]]}
|
1
|
83 end
|
|
84
|
|
85 function Shared.needed_header()
|
91
|
86 header{[[<a href="needed.html">Needed</a>]]}
|
|
87 end
|
|
88
|
|
89 function Shared.luan_url()
|
|
90 local url = "https://www.luan.software"
|
|
91 local lang = get_lang()
|
|
92 if lang ~= "en" then
|
|
93 url = url.."/"..lang
|
|
94 end
|
|
95 return url
|
1
|
96 end
|
0
|
97
|
|
98 return Shared
|