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