comparison src/lib/Shared.luan @ 16:552d6f944acb

add bump
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 17:34:15 -0600
parents 80105b716a62
children b386303be994
comparison
equal deleted inserted replaced
15:d0b8e1a8fc69 16:552d6f944acb
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local ipairs = Luan.ipairs or error()
3 local Time = require "luan:Time.luan" 4 local Time = require "luan:Time.luan"
4 local Parsers = require "luan:Parsers.luan" 5 local Parsers = require "luan:Parsers.luan"
5 local json_string = Parsers.json_string or error() 6 local json_string = Parsers.json_string or error()
6 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
7 local Utils = require "site:/lib/Utils.luan" 8 local Utils = require "site:/lib/Utils.luan"
31 <% else %> 32 <% else %>
32 <span right pulldown> 33 <span right pulldown>
33 <script>document.write(`<img src="https://cdn.discordapp.com/avatars/${localStorage.user_id}/${localStorage.user_avatar}.png" onclick="clickMenu(this)">`)</script> 34 <script>document.write(`<img src="https://cdn.discordapp.com/avatars/${localStorage.user_id}/${localStorage.user_avatar}.png" onclick="clickMenu(this)">`)</script>
34 <div pulldown_menu> 35 <div pulldown_menu>
35 <span username><script>document.write(localStorage.user_name)</script></span> 36 <span username><script>document.write(localStorage.user_name)</script></span>
37 <a href="/bump.html">Bump Servers</a>
36 <a href="/servers.html">Your Servers</a> 38 <a href="/servers.html">Your Servers</a>
37 <a href="javascript:logout()">Log out</a> 39 <a href="javascript:logout()">Log out</a>
38 </div> 40 </div>
39 </span> 41 </span>
40 <% end %> 42 <% end %>
66 %> 68 %>
67 showError( context.form, '<%=field%>', <%=json_string(message)%> ); 69 showError( context.form, '<%=field%>', <%=json_string(message)%> );
68 <% 70 <%
69 end 71 end
70 72
73 local times = {
74 {
75 time = 1000*60*60*24*365
76 unit = "year"
77 }
78 {
79 time = 1000*60*60*24*7
80 unit = "week"
81 }
82 {
83 time = 1000*60*60*24
84 unit = "day"
85 }
86 {
87 time = 1000*60*60
88 unit = "hour"
89 }
90 {
91 time = 1000*60
92 unit = "minute"
93 }
94 }
95
96 function Shared.ago(time)
97 for _, t in ipairs(times) do
98 local n = time // t.time
99 if n > 0 then
100 %><%=n%> <%=t.unit%><%
101 if n > 1 then
102 %>s<%
103 end
104 %> ago<%
105 return
106 end
107 end
108 %>just now<%
109 end
110
71 return Shared 111 return Shared